Commit | Line | Data |
---|---|---|
6b779207 LC |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2016 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) | |
22 | #:use-module (guix store) | |
23 | #:use-module (srfi srfi-1) | |
24 | #:use-module (srfi srfi-64)) | |
25 | ||
26 | ;; Test the (gnu system) module. | |
27 | ||
28 | (define %root-fs | |
29 | (file-system | |
30 | (device "my-root") | |
31 | (title 'label) | |
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") | |
117 | (title 'device) | |
118 | (mount-point "/") | |
119 | (type "ext4")) | |
120 | %base-file-systems))))) | |
121 | ||
6b779207 | 122 | (test-end) |