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 unbound variables.
73 cat > "$tmpfile" <<EOF
74 (use-modules (gnu)) ; 1
75 (use-service-modules networking) ; 2
78 (host-name "antelope") ; 5
79 (timezone "Europe/Paris") ; 6
80 (locale "en_US.UTF-8") ; 7
82 (bootloader (GRUB-config (device "/dev/sdX"))) ; 9
83 (file-systems (cons (file-system
91 if guix system build
"$tmpfile" -n 2> "$errorfile"
94 if test "`guile -c '(display (effective-version))'`" = 2.2
96 # FIXME: With Guile 2.2.0 the error is reported on line 4.
97 # See <http://bugs.gnu.org/26107>.
98 grep "$tmpfile:[49]:.*[Uu]nbound variable.*GRUB-config" "$errorfile"
100 grep "$tmpfile:9:.*[Uu]nbound variable.*GRUB-config" "$errorfile"
105 (host-name "antelope")
106 (timezone "Europe/Paris")
107 (locale "en_US.UTF-8")
109 (bootloader (grub-configuration (device "/dev/sdX")))
110 (file-systems (cons (file-system
112 (title (string->symbol "label"))
118 # Reporting of duplicate service identifiers.
120 cat > "$tmpfile" <<EOF
122 (use-service-modules networking)
126 (services (cons* (dhcp-client-service)
127 (dhcp-client-service) ;twice!
131 if guix system vm
"$tmpfile" 2> "$errorfile"
133 # This must not succeed.
136 grep "service 'networking'.*more than once" "$errorfile"
139 # Reporting unmet shepherd requirements.
141 cat > "$tmpfile" <<EOF
142 (use-modules (gnu) (gnu services shepherd))
143 (use-service-modules networking)
145 (define buggy-service-type
146 (shepherd-service-type
150 (provision '(buggy!))
151 (requirement '(does-not-exist))
156 (services (cons (service buggy-service-type #t)
160 if guix system build
"$tmpfile" 2> "$errorfile"
164 grep "service 'buggy!'.*'does-not-exist'.*not provided" "$errorfile"
167 # Reporting inconsistent user accounts.
171 cat > "$tmpfile" <<EOF
173 (use-service-modules networking)
176 (host-name "antelope")
177 (timezone "Europe/Paris")
178 (locale "en_US.UTF-8")
180 (bootloader (grub-configuration (device "/dev/sdX")))
181 (file-systems (cons (file-system
187 (users (list (user-account
189 (home-directory "/home/dave")
191 (supplementary-groups '("$2"))))))
195 make_user_config
"users" "wheel"
196 guix system build
"$tmpfile" -n # succeeds
198 guix system build
"$tmpfile" -d # succeeds
199 guix system build
"$tmpfile" -d |
grep '\.drv$'
201 guix system vm
"$tmpfile" -d # succeeds
202 guix system vm
"$tmpfile" -d |
grep '\.drv$'
204 make_user_config
"group-that-does-not-exist" "users"
205 if guix system build
"$tmpfile" -n 2> "$errorfile"
207 else grep "primary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi
209 make_user_config
"users" "group-that-does-not-exist"
210 if guix system build
"$tmpfile" -n 2> "$errorfile"
212 else grep "supplementary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi
214 # Try 'local-file' and relative file name resolution.
216 cat > "$tmpdir/config.scm"<<EOF
218 (use-service-modules networking)
222 (services (cons (tor-service (local-file "my-torrc"))
226 cat > "$tmpdir/my-torrc"<<EOF
227 # This is an example file.
230 # In both cases 'my-torrc' should be properly resolved.
231 guix system build
"$tmpdir/config.scm" -n
232 (cd "$tmpdir"; guix system build
"config.scm" -n)
235 guix system search tor |
grep "^name: tor"
236 guix system search anonym network |
grep "^name: tor"