1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
3 # Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
5 # This file is part of GNU Guix.
7 # GNU Guix is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or (at
10 # your option) any later version.
12 # GNU Guix is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21 # Test 'guix system', mostly error reporting.
28 tmpfile
="t-guix-system-$$"
29 errorfile
="t-guix-system-error-$$"
31 # Note: This directory is chosen outside $builddir so that relative file name
32 # canonicalization doesn't mess up with 'current-source-directory', used by
33 # 'local-file' ('load' forces 'relative' for
34 # %FILE-PORT-NAME-CANONICALIZATION.)
35 tmpdir
="${TMPDIR:-/tmp}/t-guix-system-$$"
38 trap 'rm -f "$tmpfile" "$errorfile" "$tmpdir"/*; rmdir "$tmpdir"' EXIT
40 # Reporting of syntax errors.
43 ;; This is line 1, and the next one is line 2.
45 ;; The 'T' is at column 3.
48 if guix system vm
"$tmpfile" 2> "$errorfile"
50 # This must not succeed.
53 grep "$tmpfile:2:3:.*missing.* initializers" "$errorfile"
58 ;; This is line 1, and the next one is line 2.
60 ;; This is line 3, and there is no closing paren!
63 if guix system vm
"$tmpfile" 2> "$errorfile"
65 # This must not succeed.
68 grep "$tmpfile:4:1: missing closing paren" "$errorfile"
72 # Reporting of module not found errors.
74 cat > "$tmpfile" <<EOF
77 (use-service-modules openssh)
80 if guix system build
"$tmpfile" -n 2> "$errorfile"
83 grep "$tmpfile:3:2: .*module .*openssh.*not found" "$errorfile"
84 grep "Try.*use-service-modules ssh" "$errorfile"
87 cat > "$tmpfile" <<EOF
90 (use-package-modules qemu)
93 if guix system build
"$tmpfile" -n 2> "$errorfile"
96 grep "$tmpfile:3:2: .*module .*qemu.*not found" "$errorfile"
97 grep "Try.*use-package-modules virtualization" "$errorfile"
100 # Reporting of unbound variables.
102 cat > "$tmpfile" <<EOF
103 (use-modules (gnu)) ; 1
104 (use-service-modules networking) ; 2
106 (operating-system ; 4
107 (host-name "antelope") ; 5
108 (timezone "Europe/Paris") ; 6
109 (locale "en_US.UTF-8") ; 7
111 (bootloader (GRUB-config (device "/dev/sdX"))) ; 9
112 (file-systems (cons (file-system
117 %base-file-systems)))
120 if guix system build
"$tmpfile" -n 2> "$errorfile"
123 if test "`guile -c '(display (effective-version))'`" = 2.2
125 # FIXME: With Guile 2.2.0 the error is reported on line 4.
126 # See <http://bugs.gnu.org/26107>.
127 grep "$tmpfile:[49]:[0-9]\+: GRUB-config.*[Uu]nbound variable" "$errorfile"
129 grep "$tmpfile:9:[0-9]\+: GRUB-config.*[Uu]nbound variable" "$errorfile"
134 (host-name "antelope")
135 (timezone "Europe/Paris")
136 (locale "en_US.UTF-8")
138 (bootloader (bootloader-configuration
139 (bootloader grub-bootloader)
140 (device "/dev/sdX")))
141 (file-systems (cons (file-system
143 (title (string->symbol "label"))
149 # Reporting of duplicate service identifiers.
151 cat > "$tmpfile" <<EOF
153 (use-service-modules networking)
157 (services (cons* (dhcp-client-service)
158 (dhcp-client-service) ;twice!
162 if guix system vm
"$tmpfile" 2> "$errorfile"
164 # This must not succeed.
167 grep "service 'networking'.*more than once" "$errorfile"
170 # Reporting unmet shepherd requirements.
172 cat > "$tmpfile" <<EOF
173 (use-modules (gnu) (gnu services shepherd))
174 (use-service-modules networking)
176 (define buggy-service-type
177 (shepherd-service-type
181 (provision '(buggy!))
182 (requirement '(does-not-exist))
187 (services (cons (service buggy-service-type #t)
191 if guix system build
"$tmpfile" 2> "$errorfile"
195 grep "service 'buggy!'.*'does-not-exist'.*not provided" "$errorfile"
198 # Reporting inconsistent user accounts.
202 cat > "$tmpfile" <<EOF
204 (use-service-modules networking)
207 (host-name "antelope")
208 (timezone "Europe/Paris")
209 (locale "en_US.UTF-8")
211 (bootloader (bootloader-configuration
212 (bootloader grub-bootloader)
213 (device "/dev/sdX")))
214 (file-systems (cons (file-system
220 (users (list (user-account
222 (home-directory "/home/dave")
224 (supplementary-groups '("$2"))))))
228 make_user_config
"users" "wheel"
229 guix system build
"$tmpfile" -n # succeeds
231 guix system build
"$tmpfile" -d # succeeds
232 guix system build
"$tmpfile" -d |
grep '\.drv$'
234 guix system vm
"$tmpfile" -d # succeeds
235 guix system vm
"$tmpfile" -d |
grep '\.drv$'
237 make_user_config
"group-that-does-not-exist" "users"
238 if guix system build
"$tmpfile" -n 2> "$errorfile"
240 else grep "primary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi
242 make_user_config
"users" "group-that-does-not-exist"
243 if guix system build
"$tmpfile" -n 2> "$errorfile"
245 else grep "supplementary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi
247 # Try 'local-file' and relative file name resolution.
249 cat > "$tmpdir/config.scm"<<EOF
251 (use-service-modules networking)
255 (services (cons (tor-service (local-file "my-torrc"))
259 cat > "$tmpdir/my-torrc"<<EOF
260 # This is an example file.
263 # In both cases 'my-torrc' should be properly resolved.
264 guix system build
"$tmpdir/config.scm" -n
265 (cd "$tmpdir"; guix system build
"config.scm" -n)
268 guix system search tor |
grep "^name: tor"
269 guix system search anonym network |
grep "^name: tor"