build-self: Avoid recompilations of 'compute-guix-derivation'.
[jackhill/guix/guix.git] / tests / system.scm
CommitLineData
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)
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
9ceeca08 30 (device (file-system-label "my-root"))
6b779207
LC
31 (mount-point "/")
32 (type "ext4")))
33
34(define %os
35 (operating-system
36 (host-name "komputilo")
37 (timezone "Europe/Berlin")
38 (locale "en_US.utf8")
fdfdecdb
TGR
39 (bootloader (bootloader-configuration
40 (bootloader grub-bootloader)
41 (target "/dev/sdX")))
6b779207
LC
42 (file-systems (cons %root-fs %base-file-systems))
43
44 (users %base-user-accounts)))
45
2bdd7ac1
LC
46(define %luks-device
47 (mapped-device
48 (source "/dev/foo") (target "my-luks-device")
49 (type luks-device-mapping)))
50
51(define %os-with-mapped-device
52 (operating-system
53 (host-name "komputilo")
54 (timezone "Europe/Berlin")
55 (locale "en_US.utf8")
fdfdecdb
TGR
56 (bootloader (bootloader-configuration
57 (bootloader grub-bootloader)
58 (target "/dev/sdX")))
2bdd7ac1
LC
59 (mapped-devices (list %luks-device))
60 (file-systems (cons (file-system
61 (inherit %root-fs)
62 (dependencies (list %luks-device)))
63 %base-file-systems))
64 (users %base-user-accounts)))
65
7b44cae5 66\f
6b779207
LC
67(test-begin "system")
68
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.
72 (eq? %root-fs
73 (operating-system-store-file-system %os)))
74
75(test-assert "operating-system-store-file-system, prefix"
76 (let* ((gnu (file-system
77 (device "foobar")
78 (mount-point (dirname (%store-prefix)))
79 (type "ext5")))
80 (os (operating-system
81 (inherit %os)
82 (file-systems (cons* gnu %root-fs
83 %base-file-systems)))))
84 (eq? gnu (operating-system-store-file-system os))))
85
86(test-assert "operating-system-store-file-system, store"
87 (let* ((gnu (file-system
88 (device "foobar")
89 (mount-point (%store-prefix))
90 (type "ext5")))
91 (os (operating-system
92 (inherit %os)
93 (file-systems (cons* gnu %root-fs
94 %base-file-systems)))))
95 (eq? gnu (operating-system-store-file-system os))))
96
2bdd7ac1
LC
97(test-equal "operating-system-user-mapped-devices"
98 '()
99 (operating-system-user-mapped-devices %os-with-mapped-device))
100
101(test-equal "operating-system-boot-mapped-devices"
102 (list %luks-device)
103 (operating-system-boot-mapped-devices %os-with-mapped-device))
104
105(test-equal "operating-system-boot-mapped-devices, implicit dependency"
106 (list %luks-device)
107
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
112 (operating-system
113 (inherit %os-with-mapped-device)
114 (file-systems (cons (file-system
115 (device "/dev/mapper/my-luks-device")
2bdd7ac1
LC
116 (mount-point "/")
117 (type "ext4"))
118 %base-file-systems)))))
119
6b779207 120(test-end)