1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
| | ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2022 Reza Alizadeh Majd <r.majd@pantherx.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu tests bootloader)
#:use-module (gnu)
#:use-module (gnu bootloader u-boot)
#:use-module (gnu system vm)
#:use-module (gnu tests)
#:use-module (guix scripts system reconfigure)
#:export (%test-uboot-with-fdtdir
%test-uboot-without-fdtdir))
(define %u-boot-with-fdtdir-bootloader
(bootloader
(inherit u-boot-bootloader)))
(define %u-boot-without-fdtdir-bootloader
(bootloader
(inherit u-boot-bootloader)
(device-tree-support? #f)))
(define (u-boot-os with-fdtdir?)
(operating-system
(inherit %simple-os)
(bootloader (bootloader-configuration
(bootloader (if with-fdtdir?
%u-boot-with-fdtdir-bootloader
%u-boot-without-fdtdir-bootloader))))))
(define* (run-uboot-fdtdir-test name #:key (with-fdtdir? #t))
"Run u-boot-bootloader installation with/without FDTDIR record for
extlinux.conf"
(define os
(marionette-operating-system
(u-boot-os with-fdtdir?)))
(define vm (virtual-machine
(operating-system os)
(volatile? #f)))
(define (test script)
(with-imported-modules '((gnu build marionette))
#~(begin
(use-modules (gnu build marionette)
(srfi srfi-64))
(define marionette
(make-marionette (list #$vm)))
(test-runner-current (system-test-runner #$output))
(test-begin #$name)
(test-assert "bootloader installed"
(marionette-eval
'(primitive-load #$script)
marionette))
(test-assert "extlinux.conf file created"
(marionette-eval
'(file-exists? "/boot/extlinux/extlinux.conf")
marionette))
(let ((content (wait-for-file "/boot/extlinux/extlinux.conf" marionette
#:read 'get-string-all
#:timeout 30)))
(if #$with-fdtdir?
(test-assert "FDTDIR exists"
(string-contains content "FDTDIR"))
(test-assert "FDTDIR removed"
(not (string-contains content "FDTDIR")))))
(test-end #$name))))
(let* ((bootcfg (operating-system-bootcfg os '()))
(bootloader ((compose bootloader-configuration-bootloader
operating-system-bootloader) os))
(bootcfg-file (bootloader-configuration-file bootloader)))
(gexp->derivation "uboot"
(test (install-bootloader-program #f #f #f bootcfg bootcfg-file
'(#f) "/")))))
(define %test-uboot-with-fdtdir
(system-test
(name "uboot-with-fdtdir")
(description "test uboot installation with fdtdir")
(value
(run-uboot-fdtdir-test "uboot-with-fdtdir"
#:with-fdtdir? #t))))
(define %test-uboot-without-fdtdir
(system-test
(name "uboot-without-fdtdir")
(description "test uboot installation without fdtdir")
(value
(run-uboot-fdtdir-test "uboot-without-fdtdir"
#:with-fdtdir? #f))))
|