aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-11-16 23:36:29 +0100
committerLudovic Courtès <ludo@gnu.org>2016-11-16 23:38:06 +0100
commit67e5f3b71d87d0a0e444df2e039c458629708cd4 (patch)
treec04dedba8d9a0bc1dd2747208e47182a31c4d56c /tests
parent9d9d0c9c982449b820eae98d0f2cfa115b618208 (diff)
downloadpatches-67e5f3b71d87d0a0e444df2e039c458629708cd4.tar
patches-67e5f3b71d87d0a0e444df2e039c458629708cd4.tar.gz
syscalls: Add bindings for SIOCGIFNETMASK and SIOCSIFNETMASK.
* guix/build/syscalls.scm (SIOCGIFNETMASK, SIOCSIFNETMASK): New variables. (set-network-interface-netmask, network-interface-netmask): New procedures. * tests/syscalls.scm ("network-interface-netmask lo") ("set-network-interface-netmask"): New tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/syscalls.scm21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/syscalls.scm b/tests/syscalls.scm
index 9eb19f9c80..fd177265f0 100644
--- a/tests/syscalls.scm
+++ b/tests/syscalls.scm
@@ -326,6 +326,27 @@
;; We get EPERM with Linux 3.18ish and EACCES with 2.6.32.
(memv (system-error-errno args) (list EPERM EACCES))))))
+(test-equal "network-interface-netmask lo"
+ (make-socket-address AF_INET (inet-pton AF_INET "255.0.0.0") 0)
+ (let* ((sock (socket AF_INET SOCK_STREAM 0))
+ (addr (network-interface-netmask sock "lo")))
+ (close-port sock)
+ addr))
+
+(test-skip (if (zero? (getuid)) 1 0))
+(test-assert "set-network-interface-netmask"
+ (let ((sock (socket AF_INET SOCK_STREAM 0)))
+ (catch 'system-error
+ (lambda ()
+ (set-network-interface-netmask sock "nonexistent"
+ (make-socket-address
+ AF_INET
+ (inet-pton AF_INET "255.0.0.0")
+ 0)))
+ (lambda args
+ (close-port sock)
+ (memv (system-error-errno args) (list EPERM EACCES))))))
+
(test-equal "network-interfaces returns one or more interfaces"
'(#t #t #t)
(match (network-interfaces)