gnu: glog: Update to 0.4.0.
[guix.git] / tests / system.scm
blob9416b950e6ab2bc9918eb163dd00f944ebeeb27e
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016, 2018 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
4 ;;;
5 ;;; This file is part of GNU Guix.
6 ;;;
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.
11 ;;;
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.
16 ;;;
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/>.
20 (define-module (test-system)
21   #:use-module (gnu)
22   #:use-module ((gnu services) #:select (service-value))
23   #:use-module (guix store)
24   #:use-module (srfi srfi-1)
25   #:use-module (srfi srfi-64))
27 ;; Test the (gnu system) module.
29 (define %root-fs
30   (file-system
31     (device (file-system-label "my-root"))
32     (mount-point "/")
33     (type "ext4")))
35 (define %os
36   (operating-system
37     (host-name "komputilo")
38     (timezone "Europe/Berlin")
39     (locale "en_US.utf8")
40     (bootloader (bootloader-configuration
41                  (bootloader grub-bootloader)
42                  (target "/dev/sdX")))
43     (file-systems (cons %root-fs %base-file-systems))
45     (users %base-user-accounts)))
47 (define %luks-device
48   (mapped-device
49    (source "/dev/foo") (target "my-luks-device")
50    (type luks-device-mapping)))
52 (define %os-with-mapped-device
53   (operating-system
54     (host-name "komputilo")
55     (timezone "Europe/Berlin")
56     (locale "en_US.utf8")
57     (bootloader (bootloader-configuration
58                  (bootloader grub-bootloader)
59                  (target "/dev/sdX")))
60     (mapped-devices (list %luks-device))
61     (file-systems (cons (file-system
62                           (inherit %root-fs)
63                           (dependencies (list %luks-device)))
64                         %base-file-systems))
65     (users %base-user-accounts)))
68 (test-begin "system")
70 (test-assert "operating-system-store-file-system"
71   ;; %BASE-FILE-SYSTEMS defines a bind-mount for /gnu/store, but this
72   ;; shouldn't be a problem.
73   (eq? %root-fs
74        (operating-system-store-file-system %os)))
76 (test-assert "operating-system-store-file-system, prefix"
77   (let* ((gnu (file-system
78                 (device "foobar")
79                 (mount-point (dirname (%store-prefix)))
80                 (type "ext5")))
81          (os  (operating-system
82                 (inherit %os)
83                 (file-systems (cons* gnu %root-fs
84                                      %base-file-systems)))))
85     (eq? gnu (operating-system-store-file-system os))))
87 (test-assert "operating-system-store-file-system, store"
88   (let* ((gnu (file-system
89                 (device "foobar")
90                 (mount-point (%store-prefix))
91                 (type "ext5")))
92          (os  (operating-system
93                 (inherit %os)
94                 (file-systems (cons* gnu %root-fs
95                                      %base-file-systems)))))
96     (eq? gnu (operating-system-store-file-system os))))
98 (test-equal "operating-system-user-mapped-devices"
99   '()
100   (operating-system-user-mapped-devices %os-with-mapped-device))
102 (test-equal "operating-system-boot-mapped-devices"
103   (list %luks-device)
104   (operating-system-boot-mapped-devices %os-with-mapped-device))
106 (test-equal "operating-system-boot-mapped-devices, implicit dependency"
107   (list %luks-device)
109   ;; Here we expect the implicit dependency between "/" and
110   ;; "/dev/mapper/my-luks-device" to be found, in spite of the lack of a
111   ;; 'dependencies' field in the root file system.
112   (operating-system-boot-mapped-devices
113    (operating-system
114      (inherit %os-with-mapped-device)
115      (file-systems (cons (file-system
116                            (device "/dev/mapper/my-luks-device")
117                            (mount-point "/")
118                            (type "ext4"))
119                          %base-file-systems)))))
121 (test-equal "non-boot-file-system-service"
122   '()
124   ;; Make sure that mapped devices with at least one needed-for-boot user are
125   ;; handled exclusively from the initrd.  See <https://bugs.gnu.org/31889>.
126   (append-map file-system-dependencies
127               (service-value
128                ((@@ (gnu system) non-boot-file-system-service)
129                 (operating-system
130                   (inherit %os-with-mapped-device)
131                   (file-systems
132                    (list (file-system
133                            (mount-point "/foo/bar")
134                            (device "qux:baz")
135                            (type "none")
136                            (dependencies (list %luks-device)))
137                          (file-system
138                            (device (file-system-label "my-root"))
139                            (mount-point "/")
140                            (type "ext4")
141                            (dependencies (list %luks-device))))))))))
143 (test-end)