1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@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 system', mostly error reporting.
27 tmpfile
="t-guix-system-$$"
28 errorfile
="t-guix-system-error-$$"
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.)
34 tmpdir
="${TMPDIR:-/tmp}/t-guix-system-$$"
37 trap 'rm -f "$tmpfile" "$errorfile" "$tmpdir"/*; rmdir "$tmpdir"' EXIT
39 # Reporting of syntax errors.
42 ;; This is line 1, and the next one is line 2.
44 ;; The 'T' is at column 3.
47 if guix system vm
"$tmpfile" 2> "$errorfile"
49 # This must not succeed.
52 grep "$tmpfile:2:3:.*missing.* initializers" "$errorfile"
57 ;; This is line 1, and the next one is line 2.
59 ;; This is line 3, and there is no closing paren!
62 if guix system vm
"$tmpfile" 2> "$errorfile"
64 # This must not succeed.
67 grep "$tmpfile:4:1: missing closing paren" "$errorfile"
71 # Reporting of module not found errors.
73 cat > "$tmpfile" <<EOF
76 (use-service-modules openssh)
79 if guix system build
"$tmpfile" -n 2> "$errorfile"
82 grep "$tmpfile:3:2: .*module .*openssh.*not found" "$errorfile"
83 grep "Try.*use-service-modules ssh" "$errorfile"
86 cat > "$tmpfile" <<EOF
89 (use-package-modules qemu)
92 if guix system build
"$tmpfile" -n 2> "$errorfile"
95 grep "$tmpfile:3:2: .*module .*qemu.*not found" "$errorfile"
96 grep "Try.*use-package-modules virtualization" "$errorfile"
99 # Reporting of unbound variables.
101 cat > "$tmpfile" <<EOF
102 (use-modules (gnu)) ; 1
103 (use-service-modules networking) ; 2
105 (operating-system ; 4
106 (host-name "antelope") ; 5
107 (timezone "Europe/Paris") ; 6
108 (locale "en_US.UTF-8") ; 7
110 (bootloader (GRUB-config (device "/dev/sdX"))) ; 9
111 (file-systems (cons (file-system
116 %base-file-systems)))
119 if guix system build
"$tmpfile" -n 2> "$errorfile"
122 if test "`guile -c '(display (effective-version))'`" = 2.2
124 # FIXME: With Guile 2.2.0 the error is reported on line 4.
125 # See <http://bugs.gnu.org/26107>.
126 grep "$tmpfile:[49]:.*[Uu]nbound variable.*GRUB-config" "$errorfile"
128 grep "$tmpfile:9:.*[Uu]nbound variable.*GRUB-config" "$errorfile"
133 (host-name "antelope")
134 (timezone "Europe/Paris")
135 (locale "en_US.UTF-8")
137 (bootloader (grub-configuration (device "/dev/sdX")))
138 (file-systems (cons (file-system
140 (title (string->symbol "label"))
146 # Reporting of duplicate service identifiers.
148 cat > "$tmpfile" <<EOF
150 (use-service-modules networking)
154 (services (cons* (dhcp-client-service)
155 (dhcp-client-service) ;twice!
159 if guix system vm
"$tmpfile" 2> "$errorfile"
161 # This must not succeed.
164 grep "service 'networking'.*more than once" "$errorfile"
167 # Reporting unmet shepherd requirements.
169 cat > "$tmpfile" <<EOF
170 (use-modules (gnu) (gnu services shepherd))
171 (use-service-modules networking)
173 (define buggy-service-type
174 (shepherd-service-type
178 (provision '(buggy!))
179 (requirement '(does-not-exist))
184 (services (cons (service buggy-service-type #t)
188 if guix system build
"$tmpfile" 2> "$errorfile"
192 grep "service 'buggy!'.*'does-not-exist'.*not provided" "$errorfile"
195 # Reporting inconsistent user accounts.
199 cat > "$tmpfile" <<EOF
201 (use-service-modules networking)
204 (host-name "antelope")
205 (timezone "Europe/Paris")
206 (locale "en_US.UTF-8")
208 (bootloader (grub-configuration (device "/dev/sdX")))
209 (file-systems (cons (file-system
215 (users (list (user-account
217 (home-directory "/home/dave")
219 (supplementary-groups '("$2"))))))
223 make_user_config
"users" "wheel"
224 guix system build
"$tmpfile" -n # succeeds
226 guix system build
"$tmpfile" -d # succeeds
227 guix system build
"$tmpfile" -d |
grep '\.drv$'
229 guix system vm
"$tmpfile" -d # succeeds
230 guix system vm
"$tmpfile" -d |
grep '\.drv$'
232 make_user_config
"group-that-does-not-exist" "users"
233 if guix system build
"$tmpfile" -n 2> "$errorfile"
235 else grep "primary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi
237 make_user_config
"users" "group-that-does-not-exist"
238 if guix system build
"$tmpfile" -n 2> "$errorfile"
240 else grep "supplementary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi
242 # Try 'local-file' and relative file name resolution.
244 cat > "$tmpdir/config.scm"<<EOF
246 (use-service-modules networking)
250 (services (cons (tor-service (local-file "my-torrc"))
254 cat > "$tmpdir/my-torrc"<<EOF
255 # This is an example file.
258 # In both cases 'my-torrc' should be properly resolved.
259 guix system build
"$tmpdir/config.scm" -n
260 (cd "$tmpdir"; guix system build
"config.scm" -n)
263 guix system search tor |
grep "^name: tor"
264 guix system search anonym network |
grep "^name: tor"