1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2014, 2015, 2016 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 if test "`guile -c '(display (effective-version))'`" = 2.2
81 # FIXME: With Guile 2.2.0 the error is reported on line 4.
82 # See <http://bugs.gnu.org/26107>.
83 grep "$tmpfile:[49]:.*[Uu]nbound variable.*GRUB-config" "$errorfile"
85 grep "$tmpfile:9:.*[Uu]nbound variable.*GRUB-config" "$errorfile"
90 (host-name "antelope")
91 (timezone "Europe/Paris")
92 (locale "en_US.UTF-8")
94 (bootloader (grub-configuration (device "/dev/sdX")))
95 (file-systems (cons (file-system
97 (title (string->symbol "label"))
103 # Reporting of duplicate service identifiers.
105 cat > "$tmpfile" <<EOF
107 (use-service-modules networking)
111 (services (cons* (dhcp-client-service)
112 (dhcp-client-service) ;twice!
116 if guix system vm
"$tmpfile" 2> "$errorfile"
118 # This must not succeed.
121 grep "service 'networking'.*more than once" "$errorfile"
124 # Reporting unmet shepherd requirements.
126 cat > "$tmpfile" <<EOF
127 (use-modules (gnu) (gnu services shepherd))
128 (use-service-modules networking)
130 (define buggy-service-type
131 (shepherd-service-type
135 (provision '(buggy!))
136 (requirement '(does-not-exist))
141 (services (cons (service buggy-service-type #t)
145 if guix system build
"$tmpfile" 2> "$errorfile"
149 grep "service 'buggy!'.*'does-not-exist'.*not provided" "$errorfile"
152 # Reporting inconsistent user accounts.
156 cat > "$tmpfile" <<EOF
158 (use-service-modules networking)
161 (host-name "antelope")
162 (timezone "Europe/Paris")
163 (locale "en_US.UTF-8")
165 (bootloader (grub-configuration (device "/dev/sdX")))
166 (file-systems (cons (file-system
172 (users (list (user-account
174 (home-directory "/home/dave")
176 (supplementary-groups '("$2"))))))
180 make_user_config
"users" "wheel"
181 guix system build
"$tmpfile" -n # succeeds
183 guix system build
"$tmpfile" -d # succeeds
184 guix system build
"$tmpfile" -d |
grep '\.drv$'
186 guix system vm
"$tmpfile" -d # succeeds
187 guix system vm
"$tmpfile" -d |
grep '\.drv$'
189 make_user_config
"group-that-does-not-exist" "users"
190 if guix system build
"$tmpfile" -n 2> "$errorfile"
192 else grep "primary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi
194 make_user_config
"users" "group-that-does-not-exist"
195 if guix system build
"$tmpfile" -n 2> "$errorfile"
197 else grep "supplementary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi
199 # Try 'local-file' and relative file name resolution.
201 cat > "$tmpdir/config.scm"<<EOF
203 (use-service-modules networking)
207 (services (cons (tor-service (local-file "my-torrc"))
211 cat > "$tmpdir/my-torrc"<<EOF
212 # This is an example file.
215 # In both cases 'my-torrc' should be properly resolved.
216 guix system build
"$tmpdir/config.scm" -n
217 (cd "$tmpdir"; guix system build
"config.scm" -n)