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>
5 ;;; This file is part of GNU Guix.
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.
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.
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)
22 #:use-module (guix store)
23 #:use-module (srfi srfi-1)
24 #:use-module (srfi srfi-64))
26 ;; Test the (gnu system) module.
30 (device (file-system-label "my-root"))
36 (host-name "komputilo")
37 (timezone "Europe/Berlin")
39 (bootloader (bootloader-configuration
40 (bootloader grub-bootloader)
42 (file-systems (cons %root-fs %base-file-systems))
44 (users %base-user-accounts)))
48 (source "/dev/foo") (target "my-luks-device")
49 (type luks-device-mapping)))
51 (define %os-with-mapped-device
53 (host-name "komputilo")
54 (timezone "Europe/Berlin")
56 (bootloader (bootloader-configuration
57 (bootloader grub-bootloader)
59 (mapped-devices (list %luks-device))
60 (file-systems (cons (file-system
62 (dependencies (list %luks-device)))
64 (users %base-user-accounts)))
69 (test-assert "operating-system-store-file-system"
70 ;; %BASE-FILE-SYSTEMS defines a bind-mount for /gnu/store, but this
71 ;; shouldn't be a problem.
73 (operating-system-store-file-system %os)))
75 (test-assert "operating-system-store-file-system, prefix"
76 (let* ((gnu (file-system
78 (mount-point (dirname (%store-prefix)))
82 (file-systems (cons* gnu %root-fs
83 %base-file-systems)))))
84 (eq? gnu (operating-system-store-file-system os))))
86 (test-assert "operating-system-store-file-system, store"
87 (let* ((gnu (file-system
89 (mount-point (%store-prefix))
93 (file-systems (cons* gnu %root-fs
94 %base-file-systems)))))
95 (eq? gnu (operating-system-store-file-system os))))
97 (test-equal "operating-system-user-mapped-devices"
99 (operating-system-user-mapped-devices %os-with-mapped-device))
101 (test-equal "operating-system-boot-mapped-devices"
103 (operating-system-boot-mapped-devices %os-with-mapped-device))
105 (test-equal "operating-system-boot-mapped-devices, implicit dependency"
108 ;; Here we expect the implicit dependency between "/" and
109 ;; "/dev/mapper/my-luks-device" to be found, in spite of the lack of a
110 ;; 'dependencies' field in the root file system.
111 (operating-system-boot-mapped-devices
113 (inherit %os-with-mapped-device)
114 (file-systems (cons (file-system
115 (device "/dev/mapper/my-luks-device")
118 %base-file-systems)))))