gnu: lvm2: Make sure compiled objects are stripped.
[jackhill/guix/guix.git] / tests / guix-system.sh
CommitLineData
c1202fb1 1# GNU Guix --- Functional package management for GNU
a8492735 2# Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
c1202fb1
LC
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#
9d3994f7 20# Test 'guix system', mostly error reporting.
c1202fb1
LC
21#
22
23set -e
24
25guix system --version
26
27tmpfile="t-guix-system-$$"
28errorfile="t-guix-system-error-$$"
9d3994f7
LC
29
30# Note: This directory is chosen outside $builddir so that relative file name
31# canonicalization doesn't mess up with 'current-source-directory', used by
32# 'local-file' ('load' forces 'relative' for
33# %FILE-PORT-NAME-CANONICALIZATION.)
34tmpdir="${TMPDIR:-/tmp}/t-guix-system-$$"
35mkdir "$tmpdir"
36
37trap 'rm -f "$tmpfile" "$errorfile" "$tmpdir"/*; rmdir "$tmpdir"' EXIT
c1202fb1 38
116244df
LC
39# Reporting of syntax errors.
40
c1202fb1
LC
41cat > "$tmpfile"<<EOF
42;; This is line 1, and the next one is line 2.
43 (operating-system)
44;; The 'T' is at column 3.
45EOF
46
47if guix system vm "$tmpfile" 2> "$errorfile"
48then
49 # This must not succeed.
50 exit 1
51else
52 grep "$tmpfile:2:3:.*missing.* initializers" "$errorfile"
53fi
116244df
LC
54
55
2abcc97f
LC
56# Reporting of unbound variables.
57
58cat > "$tmpfile" <<EOF
59(use-modules (gnu)) ; 1
60(use-service-modules networking) ; 2
61
62(operating-system ; 4
63 (host-name "antelope") ; 5
64 (timezone "Europe/Paris") ; 6
65 (locale "en_US.UTF-8") ; 7
66
67 (bootloader (GRUB-config (device "/dev/sdX"))) ; 9
68 (file-systems (cons (file-system
69 (device "root")
70 (title 'label)
71 (mount-point "/")
72 (type "ext4"))
73 %base-file-systems)))
74EOF
75
76if guix system build "$tmpfile" -n 2> "$errorfile"
77then false
78else
79 grep "$tmpfile:9:.*[Uu]nbound variable.*GRUB-config" "$errorfile"
80fi
81
2d2651e7 82OS_BASE='
116244df
LC
83 (host-name "antelope")
84 (timezone "Europe/Paris")
85 (locale "en_US.UTF-8")
86
87 (bootloader (grub-configuration (device "/dev/sdX")))
88 (file-systems (cons (file-system
89 (device "root")
2d2651e7 90 (title (string->symbol "label"))
116244df
LC
91 (mount-point "/")
92 (type "ext4"))
93 %base-file-systems))
2d2651e7 94'
116244df 95
2d2651e7
LC
96# Reporting of duplicate service identifiers.
97
98cat > "$tmpfile" <<EOF
99(use-modules (gnu))
100(use-service-modules networking)
101
102(operating-system
103 $OS_BASE
116244df
LC
104 (services (cons* (dhcp-client-service)
105 (dhcp-client-service) ;twice!
106 %base-services)))
107EOF
108
109if guix system vm "$tmpfile" 2> "$errorfile"
110then
111 # This must not succeed.
112 exit 1
113else
114 grep "service 'networking'.*more than once" "$errorfile"
115fi
0c09a306 116
0190c1c0 117# Reporting unmet shepherd requirements.
2d2651e7
LC
118
119cat > "$tmpfile" <<EOF
0190c1c0 120(use-modules (gnu) (gnu services shepherd))
2d2651e7
LC
121(use-service-modules networking)
122
123(define buggy-service-type
d4053c71 124 (shepherd-service-type
2d2651e7
LC
125 'buggy
126 (lambda _
d4053c71 127 (shepherd-service
2d2651e7
LC
128 (provision '(buggy!))
129 (requirement '(does-not-exist))
130 (start #t)))))
131
132(operating-system
133 $OS_BASE
134 (services (cons (service buggy-service-type #t)
135 %base-services)))
136EOF
137
138if guix system build "$tmpfile" 2> "$errorfile"
139then
140 exit 1
141else
a8492735 142 grep "service 'buggy!'.*'does-not-exist'.*not provided" "$errorfile"
2d2651e7
LC
143fi
144
145# Reporting inconsistent user accounts.
146
0c09a306
LC
147make_user_config ()
148{
149 cat > "$tmpfile" <<EOF
150(use-modules (gnu))
151(use-service-modules networking)
152
153(operating-system
154 (host-name "antelope")
155 (timezone "Europe/Paris")
156 (locale "en_US.UTF-8")
157
158 (bootloader (grub-configuration (device "/dev/sdX")))
159 (file-systems (cons (file-system
160 (device "root")
161 (title 'label)
162 (mount-point "/")
163 (type "ext4"))
164 %base-file-systems))
165 (users (list (user-account
166 (name "dave")
167 (home-directory "/home/dave")
168 (group "$1")
169 (supplementary-groups '("$2"))))))
170EOF
171}
172
173make_user_config "users" "wheel"
174guix system build "$tmpfile" -n # succeeds
175
f3f427c2
LC
176guix system build "$tmpfile" -d # succeeds
177guix system build "$tmpfile" -d | grep '\.drv$'
178
179guix system vm "$tmpfile" -d # succeeds
180guix system vm "$tmpfile" -d | grep '\.drv$'
181
0c09a306
LC
182make_user_config "group-that-does-not-exist" "users"
183if guix system build "$tmpfile" -n 2> "$errorfile"
184then false
185else grep "primary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi
186
187make_user_config "users" "group-that-does-not-exist"
188if guix system build "$tmpfile" -n 2> "$errorfile"
189then false
190else grep "supplementary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi
9d3994f7
LC
191
192# Try 'local-file' and relative file name resolution.
193
194cat > "$tmpdir/config.scm"<<EOF
195(use-modules (gnu))
196(use-service-modules networking)
197
198(operating-system
199 $OS_BASE
200 (services (cons (tor-service (local-file "my-torrc"))
201 %base-services)))
202EOF
203
204cat > "$tmpdir/my-torrc"<<EOF
205# This is an example file.
206EOF
207
208# In both cases 'my-torrc' should be properly resolved.
209guix system build "$tmpdir/config.scm" -n
210(cd "$tmpdir"; guix system build "config.scm" -n)