summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorDavid Thompson <davet@gnu.org>2015-05-31 20:26:47 -0400
committerDavid Thompson <dthompson2@worcester.edu>2015-07-07 20:35:08 -0400
commit8950ed11c6a0d51be056b3509f3ab269787696e9 (patch)
tree8f0581a17e1d23a067bc42157c6f77e4a8528491 /tests
parent0e88cbf8c13a6d252f3d48c36e6432ec5a9e149f (diff)
downloadguix-8950ed11c6a0d51be056b3509f3ab269787696e9.tar.gz
build: syscalls: Add clone.
* guix/build/syscalls.scm (clone): New procedure.
  (CLONE_NEWNS, CLONE_NEWUTS, CLONE_NEWIPC, CLONE_NEWUSER, CLONE_NEWPID,
  CLONE_NEWNET): New variables.
* tests/syscalls.scm ("clone"): New test.
Diffstat (limited to 'tests')
-rw-r--r--tests/syscalls.scm15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/syscalls.scm b/tests/syscalls.scm
index 049ca93267..4bc6f0332c 100644
--- a/tests/syscalls.scm
+++ b/tests/syscalls.scm
@@ -76,6 +76,21 @@
            (rmdir dir)
            #t))))
 
+(define (user-namespace pid)
+  (string-append "/proc/" (number->string pid) "/ns/user"))
+
+(test-assert "clone"
+  (match (clone (logior CLONE_NEWUSER SIGCHLD))
+    (0 (primitive-exit 42))
+    (pid
+     ;; Check if user namespaces are different.
+     (and (not (equal? (readlink (user-namespace pid))
+                       (readlink (user-namespace (getpid)))))
+          (match (waitpid pid)
+            ((_ . status)
+             (= 42 (status:exit-val status))))))))
+
+
 (test-assert "all-network-interfaces"
   (match (all-network-interfaces)
     (((? string? names) ..1)