Commit | Line | Data |
---|---|---|
6b779207 | 1 | ;;; GNU Guix --- Functional package management for GNU |
9ceeca08 | 2 | ;;; Copyright © 2016, 2018 Ludovic Courtès <ludo@gnu.org> |
fdfdecdb | 3 | ;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr> |
6b779207 LC |
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/>. | |
19 | ||
20 | (define-module (test-system) | |
21 | #:use-module (gnu) | |
68a58775 | 22 | #:use-module ((gnu services) #:select (service-value)) |
6b779207 LC |
23 | #:use-module (guix store) |
24 | #:use-module (srfi srfi-1) | |
25 | #:use-module (srfi srfi-64)) | |
26 | ||
27 | ;; Test the (gnu system) module. | |
28 | ||
29 | (define %root-fs | |
30 | (file-system | |
9ceeca08 | 31 | (device (file-system-label "my-root")) |
6b779207 LC |
32 | (mount-point "/") |
33 | (type "ext4"))) | |
34 | ||
35 | (define %os | |
36 | (operating-system | |
37 | (host-name "komputilo") | |
38 | (timezone "Europe/Berlin") | |
39 | (locale "en_US.utf8") | |
fdfdecdb TGR |
40 | (bootloader (bootloader-configuration |
41 | (bootloader grub-bootloader) | |
42 | (target "/dev/sdX"))) | |
6b779207 LC |
43 | (file-systems (cons %root-fs %base-file-systems)) |
44 | ||
45 | (users %base-user-accounts))) | |
46 | ||
2bdd7ac1 LC |
47 | (define %luks-device |
48 | (mapped-device | |
49 | (source "/dev/foo") (target "my-luks-device") | |
50 | (type luks-device-mapping))) | |
51 | ||
52 | (define %os-with-mapped-device | |
53 | (operating-system | |
54 | (host-name "komputilo") | |
55 | (timezone "Europe/Berlin") | |
56 | (locale "en_US.utf8") | |
fdfdecdb TGR |
57 | (bootloader (bootloader-configuration |
58 | (bootloader grub-bootloader) | |
59 | (target "/dev/sdX"))) | |
2bdd7ac1 LC |
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))) | |
66 | ||
7b44cae5 | 67 | \f |
6b779207 LC |
68 | (test-begin "system") |
69 | ||
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))) | |
75 | ||
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)))) | |
86 | ||
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)))) | |
97 | ||
2bdd7ac1 LC |
98 | (test-equal "operating-system-user-mapped-devices" |
99 | '() | |
100 | (operating-system-user-mapped-devices %os-with-mapped-device)) | |
101 | ||
102 | (test-equal "operating-system-boot-mapped-devices" | |
103 | (list %luks-device) | |
104 | (operating-system-boot-mapped-devices %os-with-mapped-device)) | |
105 | ||
106 | (test-equal "operating-system-boot-mapped-devices, implicit dependency" | |
107 | (list %luks-device) | |
108 | ||
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") | |
2bdd7ac1 LC |
117 | (mount-point "/") |
118 | (type "ext4")) | |
119 | %base-file-systems))))) | |
120 | ||
68a58775 LC |
121 | (test-equal "non-boot-file-system-service" |
122 | '() | |
123 | ||
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)))))))))) | |
142 | ||
6b779207 | 143 | (test-end) |