git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/tests/boot: Add ubootExtlinux test
commit048cb042d61d00543d8b03985dd7d0128d85469c authorZhaofeng Li <hello@zhaofeng.li> dateSat 16 Oct 2021, 08:58 (5 years ago) parent2cb7743
1 file changed+40−4
nixos/tests/boot.nix+40−4
nixos/tests/boot.nix+40−4
@@ -12,12 +12,22 @@ let
1212 iso =
1313 (import ../lib/eval-config.nix {
1414 inherit system;
15− modules =
16− [ ../modules/installer/cd-dvd/installation-cd-minimal.nix
17− ../modules/testing/test-instrumentation.nix
18− ];
15+ modules = [
16+ ../modules/installer/cd-dvd/installation-cd-minimal.nix
17+ ../modules/testing/test-instrumentation.nix
18+ ];
1919 }).config.system.build.isoImage;
2020
21+ sd =
22+ (import ../lib/eval-config.nix {
23+ inherit system;
24+ modules = [
25+ ../modules/installer/sd-card/sd-image-x86_64.nix
26+ ../modules/testing/test-instrumentation.nix
27+ { sdImage.compressImage = false; }
28+ ];
29+ }).config.system.build.sdImage;
30+
2131 pythonDict = params: "\n {\n ${concatStringsSep ",\n " (mapAttrsToList (name: param: "\"${name}\": \"${param}\"") params)},\n }\n";
2232
2333 makeBootTest = name: extraConfig:
@@ -110,4 +120,30 @@ in {
110120 };
111121
112122 biosNetboot = makeNetbootTest "bios" {};
123+
124+ ubootExtlinux = let
125+ sdImage = "${sd}/sd-image/${sd.imageName}";
126+ mutableImage = "/tmp/linked-image.qcow2";
127+
128+ machineConfig = pythonDict {
129+ bios = "${pkgs.ubootQemuX86}/u-boot.rom";
130+ qemuFlags = "-m 768 -machine type=pc,accel=tcg -drive file=${mutableImage},if=ide,format=qcow2";
131+ };
132+ in makeTest {
133+ name = "boot-uboot-extlinux";
134+ nodes = { };
135+ testScript = ''
136+ import os
137+
138+ # Create a mutable linked image backed by the read-only SD image
139+ if os.system("qemu-img create -f qcow2 -F raw -b ${sdImage} ${mutableImage}") != 0:
140+ raise RuntimeError("Could not create mutable linked image")
141+
142+ machine = create_machine(${machineConfig})
143+ machine.start()
144+ machine.wait_for_unit("multi-user.target")
145+ machine.succeed("nix store verify -r --no-trust --option experimental-features nix-command /run/current-system")
146+ machine.shutdown()
147+ '';
148+ };
113149}