;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2022 Reza Alizadeh Majd ;;; ;;; 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 . (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))))