%%%% Starting test syscalls Group begin: syscalls Test begin: test-name: "mount, ENOENT" source-file: "tests/syscalls.scm" source-line: 33 source-form: (test-equal "mount, ENOENT" ENOENT (catch (quote system-error) (lambda () (mount "/dev/null" "/does-not-exist" "ext2") #f) (compose system-error-errno list))) Test end: result-kind: pass actual-value: 2 expected-value: 2 Test begin: test-name: "umount, ENOENT/EPERM" source-file: "tests/syscalls.scm" source-line: 41 source-form: (test-assert "umount, ENOENT/EPERM" (catch (quote system-error) (lambda () (umount "/does-not-exist") #f) (lambda args (memv (system-error-errno args) (list EPERM ENOENT))))) Test end: result-kind: pass actual-value: (1 2) Test begin: test-name: "mount-points" source-file: "tests/syscalls.scm" source-line: 50 source-form: (test-assert "mount-points" (any (cute member <> (mount-points)) (quote ("/" "/proc" "/sys" "/dev")))) Test end: result-kind: pass actual-value: ("/" "/run/lock" "/sys/fs/pstore" "/run/shm" "/run/rpc_pipefs" "/proc/sys/fs/binfmt_misc" "/sys/fs/cgroup" "/run/cgmanager/fs" "/run/user/116" "/run/user/1000" "/media/alexvong1995/e6466814-8885-4b47-ad1c-a8ad4e3f4552") Test begin: test-name: "swapon, ENOENT/EPERM" source-file: "tests/syscalls.scm" source-line: 56 source-form: (test-assert "swapon, ENOENT/EPERM" (catch (quote system-error) (lambda () (swapon "/does-not-exist") #f) (lambda args (memv (system-error-errno args) (list EPERM ENOENT))))) Test end: result-kind: pass actual-value: (1 2) Test begin: test-name: "swapoff, ENOENT/EINVAL/EPERM" source-file: "tests/syscalls.scm" source-line: 64 source-form: (test-assert "swapoff, ENOENT/EINVAL/EPERM" (catch (quote system-error) (lambda () (swapoff "/does-not-exist") #f) (lambda args (memv (system-error-errno args) (list EPERM EINVAL ENOENT))))) Test end: result-kind: pass actual-value: (1 22 2) Test begin: test-name: "mkdtemp!" source-file: "tests/syscalls.scm" source-line: 72 source-form: (test-assert "mkdtemp!" (let* ((tmp (or (getenv "TMPDIR") "/tmp")) (dir (mkdtemp! (string-append tmp "/guix-test-XXXXXX")))) (and (file-exists? dir) (begin (rmdir dir) #t)))) Test end: result-kind: pass actual-value: #t Test begin: test-name: "clone" source-file: "tests/syscalls.scm" source-line: 85 source-form: (test-assert "clone" (match (clone (logior CLONE_NEWUSER SIGCHLD)) (0 (primitive-exit 42)) (pid (and (not (equal? (readlink (user-namespace pid)) (readlink (user-namespace (getpid))))) (match (waitpid pid) ((_ . status) (= 42 (status:exit-val status)))))))) Test end: result-kind: fail actual-value: #f actual-error: (system-error "readlink" "~A" ("No such file or directory") (2)) Test begin: test-name: "setns" source-file: "tests/syscalls.scm" source-line: 98 source-form: (test-assert "setns" (match (clone (logior CLONE_NEWUSER SIGCHLD)) (0 (primitive-exit 0)) (clone-pid (match (pipe) ((in . out) (match (primitive-fork) (0 (close in) (call-with-input-file (user-namespace clone-pid) (lambda (port) (setns (port->fdes port) 0))) (write (quote done) out) (close out) (primitive-exit 0)) (fork-pid (close out) (read in) (let ((result (and (equal? (readlink (user-namespace clone-pid)) (readlink (user-namespace fork-pid)))))) (waitpid clone-pid) (waitpid fork-pid) result)))))))) Test end: result-kind: fail actual-value: #f actual-error: (system-error "readlink" "~A" ("No such file or directory") (2)) %%%% Starting test syscalls Group begin: syscalls Test begin: test-name: "mount, ENOENT" source-file: "tests/syscalls.scm" source-line: 33 source-form: (test-equal "mount, ENOENT" ENOENT (catch (quote system-error) (lambda () (mount "/dev/null" "/does-not-exist" "ext2") #f) (compose system-error-errno list))) Test end: result-kind: pass actual-value: 2 expected-value: 2 Test begin: test-name: "umount, ENOENT/EPERM" source-file: "tests/syscalls.scm" source-line: 41 source-form: (test-assert "umount, ENOENT/EPERM" (catch (quote system-error) (lambda () (umount "/does-not-exist") #f) (lambda args (memv (system-error-errno args) (list EPERM ENOENT))))) Test end: result-kind: pass actual-value: (1 2) Test begin: test-name: "mount-points" source-file: "tests/syscalls.scm" source-line: 50 source-form: (test-assert "mount-points" (any (cute member <> (mount-points)) (quote ("/" "/proc" "/sys" "/dev")))) Test end: result-kind: pass actual-value: ("/" "/run/lock" "/sys/fs/pstore" "/run/shm" "/run/rpc_pipefs" "/proc/sys/fs/binfmt_misc" "/sys/fs/cgroup" "/run/cgmanager/fs" "/run/user/116" "/run/user/1000" "/media/alexvong1995/e6466814-8885-4b47-ad1c-a8ad4e3f4552") Test begin: test-name: "swapon, ENOENT/EPERM" source-file: "tests/syscalls.scm" source-line: 56 source-form: (test-assert "swapon, ENOENT/EPERM" (catch (quote system-error) (lambda () (swapon "/does-not-exist") #f) (lambda args (memv (system-error-errno args) (list EPERM ENOENT))))) Test end: result-kind: pass actual-value: (1 2) Test begin: test-name: "swapoff, ENOENT/EINVAL/EPERM" source-file: "tests/syscalls.scm" source-line: 64 source-form: (test-assert "swapoff, ENOENT/EINVAL/EPERM" (catch (quote system-error) (lambda () (swapoff "/does-not-exist") #f) (lambda args (memv (system-error-errno args) (list EPERM EINVAL ENOENT))))) Test end: result-kind: pass actual-value: (1 22 2) Test begin: test-name: "mkdtemp!" source-file: "tests/syscalls.scm" source-line: 72 source-form: (test-assert "mkdtemp!" (let* ((tmp (or (getenv "TMPDIR") "/tmp")) (dir (mkdtemp! (string-append tmp "/guix-test-XXXXXX")))) (and (file-exists? dir) (begin (rmdir dir) #t)))) Test end: result-kind: pass actual-value: #t Test begin: test-name: "clone" source-file: "tests/syscalls.scm" source-line: 85 source-form: (test-assert "clone" (match (clone (logior CLONE_NEWUSER SIGCHLD)) (0 (primitive-exit 42)) (pid (and (not (equal? (readlink (user-namespace pid)) (readlink (user-namespace (getpid))))) (match (waitpid pid) ((_ . status) (= 42 (status:exit-val status)))))))) Test end: result-kind: fail actual-value: #f actual-error: (system-error "readlink" "~A" ("No such file or directory") (2)) Test begin: test-name: "setns" source-file: "tests/syscalls.scm" source-line: 98 source-form: (test-assert "setns" (match (clone (logior CLONE_NEWUSER SIGCHLD)) (0 (primitive-exit 0)) (clone-pid (match (pipe) ((in . out) (match (primitive-fork) (0 (close in) (call-with-input-file (user-namespace clone-pid) (lambda (port) (setns (port->fdes port) 0))) (write (quote done) out) (close out) (primitive-exit 0)) (fork-pid (close out) (read in) (let ((result (and (equal? (readlink (user-namespace clone-pid)) (readlink (user-namespace fork-pid)))))) (waitpid clone-pid) (waitpid fork-pid) result)))))))) Test end: result-kind: fail actual-value: #f actual-error: (system-error "open-file" "~A: ~S" ("No such file or directory" "/proc/-1/ns/user") (2)) Test begin: test-name: "pivot-root" source-file: "tests/syscalls.scm" source-line: 127 source-form: (test-assert "pivot-root" (match (pipe) ((in . out) (match (clone (logior CLONE_NEWUSER CLONE_NEWNS SIGCHLD)) (0 (close in) (call-with-temporary-directory (lambda (root) (let ((put-old (string-append root "/real-root"))) (mount "none" root "tmpfs") (mkdir put-old) (call-with-output-file (string-append root "/test") (lambda (port) (display "testing\n" port))) (pivot-root root put-old) (write (file-exists? "/test") out) (close out)))) (primitive-exit 0)) (pid (close out) (let ((result (read in))) (close in) (and (zero? (match (waitpid pid) ((_ . status) (status:exit-val status)))) (eq? #t result)))))))) Test end: result-kind: fail actual-value: #f actual-error: (system-error "waitpid" "~A" ("No child processes") (10)) Test begin: test-name: "all-network-interface-names" source-file: "tests/syscalls.scm" source-line: 155 source-form: (test-assert "all-network-interface-names" (match (all-network-interface-names) (((? string? names) ..1) (member "lo" names)))) Test end: result-kind: pass actual-value: ("lo") Test begin: test-name: "network-interface-names" source-file: "tests/syscalls.scm" source-line: 160 source-form: (test-assert "network-interface-names" (match (network-interface-names) (((? string? names) ..1) (lset<= string=? names (all-network-interface-names))))) Test end: result-kind: pass actual-value: #t Test begin: test-name: "network-interface-flags" source-file: "tests/syscalls.scm" source-line: 165 source-form: (test-assert "network-interface-flags" (let* ((sock (socket AF_INET SOCK_STREAM 0)) (flags (network-interface-flags sock "lo"))) (close-port sock) (and (not (zero? (logand flags IFF_LOOPBACK))) (not (zero? (logand flags IFF_UP)))))) Test end: result-kind: pass actual-value: #t Test begin: test-name: "loopback-network-interface?" source-file: "tests/syscalls.scm" source-line: 172 source-form: (test-equal "loopback-network-interface?" ENODEV (and (loopback-network-interface? "lo") (catch (quote system-error) (lambda () (loopback-network-interface? "nonexistent") #f) (lambda args (system-error-errno args))))) Test end: result-kind: pass actual-value: 19 expected-value: 19 Test begin: test-name: "set-network-interface-flags" source-file: "tests/syscalls.scm" source-line: 183 source-form: (test-assert "set-network-interface-flags" (let ((sock (socket AF_INET SOCK_STREAM 0))) (catch (quote system-error) (lambda () (set-network-interface-flags sock "lo" IFF_UP)) (lambda args (close-port sock) (memv (system-error-errno args) (list EPERM EACCES)))))) Test end: result-kind: pass actual-value: (1 13) Test begin: test-name: "network-interface-address lo" source-file: "tests/syscalls.scm" source-line: 193 source-form: (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 end: result-kind: pass actual-value: #(2 2130706433 0) expected-value: #(2 2130706433 0) Test begin: test-name: "set-network-interface-address" source-file: "tests/syscalls.scm" source-line: 201 source-form: (test-assert "set-network-interface-address" (let ((sock (socket AF_INET SOCK_STREAM 0))) (catch (quote 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) (memv (system-error-errno args) (list EPERM EACCES)))))) Test end: result-kind: pass actual-value: (1 13) Test begin: test-name: "network-interfaces returns one or more interfaces" source-file: "tests/syscalls.scm" source-line: 215 source-form: (test-equal "network-interfaces returns one or more interfaces" (quote (#t #t #t)) (match (network-interfaces) ((interfaces ..1) (list (every interface? interfaces) (every string? (map interface-name interfaces)) (every vector? (map interface-address interfaces)))))) Test end: result-kind: pass actual-value: (#t #t #t) expected-value: (#t #t #t) Test begin: test-name: "network-interfaces returns \"lo\"" source-file: "tests/syscalls.scm" source-line: 223 source-form: (test-equal "network-interfaces returns \"lo\"" (list #t (make-socket-address AF_INET (inet-pton AF_INET "127.0.0.1") 0)) (match (filter (lambda (interface) (string=? "lo" (interface-name interface))) (network-interfaces)) ((loopbacks ..1) (list (every (lambda (lo) (not (zero? (logand IFF_LOOPBACK (interface-flags lo))))) loopbacks) (match (find (lambda (lo) (= AF_INET (sockaddr:fam (interface-address lo)))) loopbacks) (#f #f) (lo (interface-address lo))))))) Test end: result-kind: pass actual-value: (#t #(2 2130706433 0)) expected-value: (#t #(2 2130706433 0)) Group end: syscalls # of expected passes 15 # of unexpected failures 3