diff options
author | Zhaofeng Li <hello@zhaofeng.li> | 2021-10-16 08:58:04 -0700 |
---|---|---|
committer | Zhaofeng Li <hello@zhaofeng.li> | 2022-01-06 17:44:17 -0800 |
commit | 048cb042d61d00543d8b03985dd7d0128d85469c (patch) | |
tree | f83cf8a37c94da636f4a6c09ca3e3e1c85f00b7b /nixos/tests/boot.nix | |
parent | 2cb7743e9c0f5c525c33ae2bccc7af30aefd97f0 (diff) |
nixos/tests/boot: Add ubootExtlinux test
Diffstat (limited to 'nixos/tests/boot.nix')
-rw-r--r-- | nixos/tests/boot.nix | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/nixos/tests/boot.nix b/nixos/tests/boot.nix index 9945a1dcd62f7..cf55656671318 100644 --- a/nixos/tests/boot.nix +++ b/nixos/tests/boot.nix @@ -12,12 +12,22 @@ let iso = (import ../lib/eval-config.nix { inherit system; - modules = - [ ../modules/installer/cd-dvd/installation-cd-minimal.nix - ../modules/testing/test-instrumentation.nix - ]; + modules = [ + ../modules/installer/cd-dvd/installation-cd-minimal.nix + ../modules/testing/test-instrumentation.nix + ]; }).config.system.build.isoImage; + sd = + (import ../lib/eval-config.nix { + inherit system; + modules = [ + ../modules/installer/sd-card/sd-image-x86_64.nix + ../modules/testing/test-instrumentation.nix + { sdImage.compressImage = false; } + ]; + }).config.system.build.sdImage; + pythonDict = params: "\n {\n ${concatStringsSep ",\n " (mapAttrsToList (name: param: "\"${name}\": \"${param}\"") params)},\n }\n"; makeBootTest = name: extraConfig: @@ -110,4 +120,30 @@ in { }; biosNetboot = makeNetbootTest "bios" {}; + + ubootExtlinux = let + sdImage = "${sd}/sd-image/${sd.imageName}"; + mutableImage = "/tmp/linked-image.qcow2"; + + machineConfig = pythonDict { + bios = "${pkgs.ubootQemuX86}/u-boot.rom"; + qemuFlags = "-m 768 -machine type=pc,accel=tcg -drive file=${mutableImage},if=ide,format=qcow2"; + }; + in makeTest { + name = "boot-uboot-extlinux"; + nodes = { }; + testScript = '' + import os + + # Create a mutable linked image backed by the read-only SD image + if os.system("qemu-img create -f qcow2 -F raw -b ${sdImage} ${mutableImage}") != 0: + raise RuntimeError("Could not create mutable linked image") + + machine = create_machine(${machineConfig}) + machine.start() + machine.wait_for_unit("multi-user.target") + machine.succeed("nix store verify -r --no-trust --option experimental-features nix-command /run/current-system") + machine.shutdown() + ''; + }; } |