ui: Add 'make-regexp*'.
[jackhill/guix/guix.git] / tests / guix-environment-container.sh
CommitLineData
f535dcbe
DT
1# GNU Guix --- Functional package management for GNU
2# Copyright © 2015 David Thompson <davet@gnu.org>
3#
4# This file is part of GNU Guix.
5#
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.
10#
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.
15#
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/>.
18
19#
20# Test 'guix environment'.
21#
22
23set -e
24
25guix environment --version
26
27tmpdir="t-guix-environment-$$"
28trap 'rm -r "$tmpdir"' EXIT
29
30mkdir "$tmpdir"
31
32# Make sure the exit value is preserved.
33if guix environment --container --ad-hoc --bootstrap guile-bootstrap \
34 -- guile -c '(exit 42)'
35then
36 false
37else
38 test $? = 42
39fi
40
41# Make sure that the right directories are mapped.
42mount_test_code="
43(use-modules (ice-9 rdelim)
44 (ice-9 match)
45 (srfi srfi-1))
46
47(define mappings
48 (filter-map (lambda (line)
49 (match (string-split line #\space)
50 ;; Empty line.
51 ((\"\") #f)
52 ;; Ignore these types of file systems.
53 ((_ _ (or \"tmpfs\" \"proc\" \"sysfs\" \"devtmpfs\"
54 \"devpts\" \"cgroup\" \"mqueue\") _ _ _)
55 #f)
56 ((_ mount _ _ _ _)
57 mount)))
58 (string-split (call-with-input-file \"/proc/mounts\" read-string)
59 #\newline)))
60
61(for-each (lambda (mount)
62 (display mount)
63 (newline))
64 mappings)"
65
66guix environment --container --ad-hoc --bootstrap guile-bootstrap \
67 -- guile -c "$mount_test_code" > $tmpdir/mounts
68
69test `wc -l < $tmpdir/mounts` -eq 3
70
71grep -e "$PWD$" $tmpdir/mounts # current directory
72grep $(guix build guile-bootstrap) $tmpdir/mounts
73grep -e "$NIX_STORE_DIR/.*-bash" $tmpdir/mounts # bootstrap bash
74
75rm $tmpdir/mounts