1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2015 David Thompson <davet@gnu.org>
4 # This file is part of GNU Guix.
6 # GNU Guix is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or (at
9 # your option) any later version.
11 # GNU Guix is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 # Test 'guix environment'.
25 guix environment
--version
27 if ! guile
-c '((@@ (guix scripts environment) assert-container-features))'
29 # User containers are not supported; skip this test.
33 tmpdir
="t-guix-environment-$$"
34 trap 'rm -r "$tmpdir"' EXIT
38 # Make sure the exit value is preserved.
39 if guix environment
--container --ad-hoc --bootstrap guile-bootstrap \
40 -- guile
-c '(exit 42)'
47 # Make sure file-not-found errors in mounts are reported.
48 if guix environment
--container --ad-hoc --bootstrap guile-bootstrap \
49 --expose=/does-not-exist
-- guile
-c 1 2> "$tmpdir/error"
53 grep "/does-not-exist" "$tmpdir/error"
54 grep "[Nn]o such file" "$tmpdir/error"
57 # Make sure that the right directories are mapped.
59 (use-modules (ice-9 rdelim)
64 (filter-map (lambda (line)
65 (match (string-split line #\space)
68 ;; Ignore the root file system.
71 ;; Ignore these types of file systems, except if they
72 ;; correspond to a parent file system.
73 ((_ mount (or \"tmpfs\" \"proc\" \"sysfs\" \"devtmpfs\"
74 \"devpts\" \"cgroup\" \"mqueue\") _ _ _)
75 (and (string-prefix? (getcwd) mount)
79 (string-split (call-with-input-file \"/proc/mounts\" read-string)
82 (for-each (lambda (mount)
87 guix environment
--container --ad-hoc --bootstrap guile-bootstrap \
88 -- guile
-c "$mount_test_code" > $tmpdir/mounts
91 test `wc -l < $tmpdir/mounts` -eq 4
93 current_dir
="`cd $PWD; pwd -P`"
94 grep -e "$current_dir$" $tmpdir/mounts
# current directory
95 grep $
(guix build guile-bootstrap
) $tmpdir/mounts
96 grep -e "$NIX_STORE_DIR/.*-bash" $tmpdir/mounts
# bootstrap bash
101 (use-modules (system foreign))
102 ;; Purposely make Guile crash with a segfault. :)
103 (pointer->string (make-pointer 123) 123)"
105 if guix environment
--bootstrap --container \
106 --ad-hoc guile-bootstrap
-- guile
-c "$abnormal_exit_code"