diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2019-07-15 16:14:31 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2019-07-19 11:53:47 +0200 |
| commit | bacfec8611530dc3e849fb804b51f50b299796f0 (patch) | |
| tree | 0d114dfcf5692742ade19a7dfad829b2546835a2 /tests/containers.scm | |
| parent | b41c7beb0b5b7a16656d6acf53f77eaf2a58e125 (diff) | |
linux-container: Add 'eval/container'.
* gnu/system/linux-container.scm (eval/container): New procedure.
* tests/containers.scm ("eval/container, exit status")
("eval/container, writable user mapping"): New tests.
Diffstat (limited to 'tests/containers.scm')
| -rw-r--r-- | tests/containers.scm | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/containers.scm b/tests/containers.scm index 37408f380d3..c6c738f2349 100644 --- a/tests/containers.scm +++ b/tests/containers.scm | |||
| @@ -21,7 +21,15 @@ | |||
| 21 | #:use-module (guix utils) | 21 | #:use-module (guix utils) |
| 22 | #:use-module (guix build syscalls) | 22 | #:use-module (guix build syscalls) |
| 23 | #:use-module (gnu build linux-container) | 23 | #:use-module (gnu build linux-container) |
| 24 | #:use-module ((gnu system linux-container) | ||
| 25 | #:select (eval/container)) | ||
| 24 | #:use-module (gnu system file-systems) | 26 | #:use-module (gnu system file-systems) |
| 27 | #:use-module (guix store) | ||
| 28 | #:use-module (guix monads) | ||
| 29 | #:use-module (guix gexp) | ||
| 30 | #:use-module (guix derivations) | ||
| 31 | #:use-module (guix tests) | ||
| 32 | #:use-module (srfi srfi-1) | ||
| 25 | #:use-module (srfi srfi-64) | 33 | #:use-module (srfi srfi-64) |
| 26 | #:use-module (ice-9 match)) | 34 | #:use-module (ice-9 match)) |
| 27 | 35 | ||
| @@ -219,4 +227,46 @@ | |||
| 219 | (lambda () | 227 | (lambda () |
| 220 | (* 6 7)))) | 228 | (* 6 7)))) |
| 221 | 229 | ||
| 230 | (skip-if-unsupported) | ||
| 231 | (test-equal "eval/container, exit status" | ||
| 232 | 42 | ||
| 233 | (let* ((store (open-connection-for-tests)) | ||
| 234 | (status (run-with-store store | ||
| 235 | (eval/container #~(exit 42))))) | ||
| 236 | (close-connection store) | ||
| 237 | (status:exit-val status))) | ||
| 238 | |||
| 239 | (skip-if-unsupported) | ||
| 240 | (test-assert "eval/container, writable user mapping" | ||
| 241 | (call-with-temporary-directory | ||
| 242 | (lambda (directory) | ||
| 243 | (define store | ||
| 244 | (open-connection-for-tests)) | ||
| 245 | (define result | ||
| 246 | (string-append directory "/r")) | ||
| 247 | (define requisites* | ||
| 248 | (store-lift requisites)) | ||
| 249 | |||
| 250 | (call-with-output-file result (const #t)) | ||
| 251 | (run-with-store store | ||
| 252 | (mlet %store-monad ((status (eval/container | ||
| 253 | #~(begin | ||
| 254 | (use-modules (ice-9 ftw)) | ||
| 255 | (call-with-output-file "/result" | ||
| 256 | (lambda (port) | ||
| 257 | (write (scandir #$(%store-prefix)) | ||
| 258 | port)))) | ||
| 259 | #:mappings | ||
| 260 | (list (file-system-mapping | ||
| 261 | (source result) | ||
| 262 | (target "/result") | ||
| 263 | (writable? #t))))) | ||
| 264 | (reqs (requisites* | ||
| 265 | (list (derivation->output-path | ||
| 266 | (%guile-for-build)))))) | ||
| 267 | (close-connection store) | ||
| 268 | (return (and (zero? (pk 'status status)) | ||
| 269 | (lset= string=? (cons* "." ".." (map basename reqs)) | ||
| 270 | (pk (call-with-input-file result read)))))))))) | ||
| 271 | |||
| 222 | (test-end) | 272 | (test-end) |
