1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2014, 2015 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"
56 # Reporting of unbound variables.
58 cat > "$tmpfile" <<EOF
59 (use-modules (gnu)) ; 1
60 (use-service-modules networking) ; 2
63 (host-name "antelope") ; 5
64 (timezone "Europe/Paris") ; 6
65 (locale "en_US.UTF-8") ; 7
67 (bootloader (GRUB-config (device "/dev/sdX"))) ; 9
68 (file-systems (cons (file-system
76 if guix system build
"$tmpfile" -n 2> "$errorfile"
79 grep "$tmpfile:9:.*[Uu]nbound variable.*GRUB-config" "$errorfile"
83 (host-name "antelope")
84 (timezone "Europe/Paris")
85 (locale "en_US.UTF-8")
87 (bootloader (grub-configuration (device "/dev/sdX")))
88 (file-systems (cons (file-system
90 (title (string->symbol "label"))
96 # Reporting of duplicate service identifiers.
98 cat > "$tmpfile" <<EOF
100 (use-service-modules networking)
104 (services (cons* (dhcp-client-service)
105 (dhcp-client-service) ;twice!
109 if guix system vm
"$tmpfile" 2> "$errorfile"
111 # This must not succeed.
114 grep "service 'networking'.*more than once" "$errorfile"
117 # Reporting unmet shepherd requirements.
119 cat > "$tmpfile" <<EOF
120 (use-modules (gnu) (gnu services shepherd))
121 (use-service-modules networking)
123 (define buggy-service-type
124 (shepherd-service-type
128 (provision '(buggy!))
129 (requirement '(does-not-exist))
134 (services (cons (service buggy-service-type #t)
138 if guix system build
"$tmpfile" 2> "$errorfile"
142 grep "service 'buggy!'.*'does-not-exist'.*undefined" "$errorfile"
145 # Reporting inconsistent user accounts.
149 cat > "$tmpfile" <<EOF
151 (use-service-modules networking)
154 (host-name "antelope")
155 (timezone "Europe/Paris")
156 (locale "en_US.UTF-8")
158 (bootloader (grub-configuration (device "/dev/sdX")))
159 (file-systems (cons (file-system
165 (users (list (user-account
167 (home-directory "/home/dave")
169 (supplementary-groups '("$2"))))))
173 make_user_config
"users" "wheel"
174 guix system build
"$tmpfile" -n # succeeds
176 guix system build
"$tmpfile" -d # succeeds
177 guix system build
"$tmpfile" -d |
grep '\.drv$'
179 guix system vm
"$tmpfile" -d # succeeds
180 guix system vm
"$tmpfile" -d |
grep '\.drv$'
182 make_user_config
"group-that-does-not-exist" "users"
183 if guix system build
"$tmpfile" -n 2> "$errorfile"
185 else grep "primary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi
187 make_user_config
"users" "group-that-does-not-exist"
188 if guix system build
"$tmpfile" -n 2> "$errorfile"
190 else grep "supplementary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi
192 # Try 'local-file' and relative file name resolution.
194 cat > "$tmpdir/config.scm"<<EOF
196 (use-service-modules networking)
200 (services (cons (tor-service (local-file "my-torrc"))
204 cat > "$tmpdir/my-torrc"<<EOF
205 # This is an example file.
208 # In both cases 'my-torrc' should be properly resolved.
209 guix system build
"$tmpdir/config.scm" -n
210 (cd "$tmpdir"; guix system build
"config.scm" -n)