diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2017-02-06 23:45:00 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2017-02-07 00:08:10 +0100 |
| commit | c90db25f4cf1f98f3f4f3af38d175a14ffb8c32a (patch) | |
| tree | f419dee5d3df1f967312db49d373b44a49e93d48 /tests/containers.scm | |
| parent | b9a5efa59673dc9061714a9b0b15b43696bfd38c (diff) | |
linux-container: Add 'container-excursion*'.
* gnu/build/linux-container.scm (container-excursion*): New procedure.
* tests/containers.scm ("container-excursion*")
("container-excursion*, same namespaces"): New tests.
Diffstat (limited to 'tests/containers.scm')
| -rw-r--r-- | tests/containers.scm | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/containers.scm b/tests/containers.scm index 745b56b710d..0b3a4be12b9 100644 --- a/tests/containers.scm +++ b/tests/containers.scm | |||
| @@ -180,4 +180,31 @@ | |||
| 180 | (lambda () | 180 | (lambda () |
| 181 | (primitive-exit 42)))) | 181 | (primitive-exit 42)))) |
| 182 | 182 | ||
| 183 | (skip-if-unsupported) | ||
| 184 | (test-assert "container-excursion*" | ||
| 185 | (call-with-temporary-directory | ||
| 186 | (lambda (root) | ||
| 187 | (define (namespaces pid) | ||
| 188 | (let ((pid (number->string pid))) | ||
| 189 | (map (lambda (ns) | ||
| 190 | (readlink (string-append "/proc/" pid "/ns/" ns))) | ||
| 191 | '("user" "ipc" "uts" "net" "pid" "mnt")))) | ||
| 192 | |||
| 193 | (let* ((pid (run-container root '() | ||
| 194 | %namespaces 1 | ||
| 195 | (lambda () | ||
| 196 | (sleep 100)))) | ||
| 197 | (result (container-excursion* pid | ||
| 198 | (lambda () | ||
| 199 | (namespaces 1))))) | ||
| 200 | (kill pid SIGKILL) | ||
| 201 | (equal? result (namespaces pid)))))) | ||
| 202 | |||
| 203 | (skip-if-unsupported) | ||
| 204 | (test-equal "container-excursion*, same namespaces" | ||
| 205 | 42 | ||
| 206 | (container-excursion* (getpid) | ||
| 207 | (lambda () | ||
| 208 | (* 6 7)))) | ||
| 209 | |||
| 183 | (test-end) | 210 | (test-end) |
