summaryrefslogtreecommitdiff
path: root/tests/syscalls.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-12-19 14:26:11 +0100
committerLudovic Courtès <ludo@gnu.org>2014-12-19 17:15:53 +0100
commitc9bf64d6d777baf2603b5d6a52c5c5b9adf649cd (patch)
tree7ec2fb81bebc8d5237df98e7a372fb06ab53985a /tests/syscalls.scm
parentcdae969ae5191d50375c0cb7182d0ac82558875d (diff)
syscalls: Add more procedures for network interfaces.
* guix/build/syscalls.scm (sizeof*, type-size, write-type, write-types, read-type, read-types, define-c-struct): New macros. (SIOCSIFFLAGS, SIOCGIFADDR, SIOCSIFADDR): New variables. (sockaddr-in, sockaddr-in6): New C structs. (write-socket-address!, read-socket-address, set-network-interface-flags, set-network-interface-address, network-interface-address, configure-network-interface): New procedures.
Diffstat (limited to 'tests/syscalls.scm')
-rw-r--r--tests/syscalls.scm34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/syscalls.scm b/tests/syscalls.scm
index d65ec82740..21d6637ff6 100644
--- a/tests/syscalls.scm
+++ b/tests/syscalls.scm
@@ -74,7 +74,7 @@
(lset<= string=? names (all-network-interfaces)))))
(test-assert "network-interface-flags"
- (let* ((sock (socket SOCK_STREAM AF_INET 0))
+ (let* ((sock (socket AF_INET SOCK_STREAM 0))
(flags (network-interface-flags sock "lo")))
(close-port sock)
(and (not (zero? (logand flags IFF_LOOPBACK)))
@@ -90,6 +90,38 @@
(lambda args
(system-error-errno args)))))
+(test-skip (if (zero? (getuid)) 1 0))
+(test-equal "set-network-interface-flags"
+ EPERM
+ (let ((sock (socket AF_INET SOCK_STREAM 0)))
+ (catch 'system-error
+ (lambda ()
+ (set-network-interface-flags sock "lo" IFF_UP))
+ (lambda args
+ (close-port sock)
+ (system-error-errno args)))))
+
+(test-equal "network-interface-address lo"
+ (make-socket-address AF_INET (inet-pton AF_INET "127.0.0.1") 0)
+ (let* ((sock (socket AF_INET SOCK_STREAM 0))
+ (addr (network-interface-address sock "lo")))
+ (close-port sock)
+ addr))
+
+(test-equal "set-network-interface-address"
+ EPERM
+ (let ((sock (socket AF_INET SOCK_STREAM 0)))
+ (catch 'system-error
+ (lambda ()
+ (set-network-interface-address sock "nonexistent"
+ (make-socket-address
+ AF_INET
+ (inet-pton AF_INET "127.12.14.15")
+ 0)))
+ (lambda args
+ (close-port sock)
+ (system-error-errno args)))))
+
(test-end)