summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-09-14 22:12:35 +0200
committerLudovic Courtès <ludo@gnu.org>2014-09-14 23:49:02 +0200
commit973eea34781078091869143602d4f1dfdfd82e19 (patch)
tree468c8642b4db173840fe81081165a3ef457cc2f8 /tests
parent7585016f53e2e8be1f82ed303ae084464422c2a8 (diff)
downloadpatches-973eea34781078091869143602d4f1dfdfd82e19.tar
patches-973eea34781078091869143602d4f1dfdfd82e19.tar.gz
syscalls: Add 'network-interface-flags'.
* guix/build/syscalls.scm (SIOCGIFFLAGS, IFF_UP, IFF_BROADCAST, IFF_LOOPBACK, IF_NAMESIZE): New variables. (network-interface-flags, loopback-network-interface?): New procedures. * tests/syscalls.scm ("network-interface-flags", "loopback-network-interface?"): New tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/syscalls.scm17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/syscalls.scm b/tests/syscalls.scm
index fa6b67bf39..c3550ac31a 100644
--- a/tests/syscalls.scm
+++ b/tests/syscalls.scm
@@ -48,6 +48,23 @@
(((? string? names) ..1)
(member "lo" names))))
+(test-assert "network-interface-flags"
+ (let* ((sock (socket SOCK_STREAM AF_INET 0))
+ (flags (network-interface-flags sock "lo")))
+ (close-port sock)
+ (and (not (zero? (logand flags IFF_LOOPBACK)))
+ (not (zero? (logand flags IFF_UP))))))
+
+(test-equal "loopback-network-interface?"
+ ENODEV
+ (and (loopback-network-interface? "lo")
+ (catch 'system-error
+ (lambda ()
+ (loopback-network-interface? "nonexistent")
+ #f)
+ (lambda args
+ (system-error-errno args)))))
+
(test-end)