1 { system ? builtins.currentSystem,
3 pkgs ? import ../.. { inherit system config; }
6 with import ../lib/testing-python.nix { inherit system pkgs; };
10 qemu-common = import ../lib/qemu-common.nix { inherit (pkgs) lib pkgs; };
13 (import ../lib/eval-config.nix {
16 ../modules/installer/cd-dvd/installation-cd-minimal.nix
17 ../modules/testing/test-instrumentation.nix
19 }).config.system.build.isoImage;
22 (import ../lib/eval-config.nix {
25 ../modules/installer/sd-card/sd-image-x86_64.nix
26 ../modules/testing/test-instrumentation.nix
27 { sdImage.compressImage = false; }
29 }).config.system.build.sdImage;
31 pythonDict = params: "\n {\n ${concatStringsSep ",\n " (mapAttrsToList (name: param: "\"${name}\": \"${param}\"") params)},\n }\n";
33 makeBootTest = name: extraConfig:
35 machineConfig = pythonDict ({
36 qemuBinary = qemu-common.qemuBinary pkgs.qemu_test;
41 name = "boot-" + name;
45 machine = create_machine(${machineConfig})
47 machine.wait_for_unit("multi-user.target")
48 machine.succeed("nix store verify --no-trust -r --option experimental-features nix-command /run/current-system")
50 with subtest("Check whether the channel got installed correctly"):
51 machine.succeed("nix-instantiate --dry-run '<nixpkgs>' -A hello")
52 machine.succeed("nix-env --dry-run -iA nixos.procps")
58 makeNetbootTest = name: extraConfig:
60 config = (import ../lib/eval-config.nix {
63 [ ../modules/installer/netboot/netboot.nix
64 ../modules/testing/test-instrumentation.nix
68 ipxeBootDir = pkgs.symlinkJoin {
71 config.system.build.netbootRamdisk
72 config.system.build.kernel
73 config.system.build.netbootIpxeScript
76 machineConfig = pythonDict ({
77 qemuBinary = qemu-common.qemuBinary pkgs.qemu_test;
78 qemuFlags = "-boot order=n -m 2000";
79 netBackendArgs = "tftp=${ipxeBootDir},bootfile=netboot.ipxe";
83 name = "boot-netboot-" + name;
86 machine = create_machine(${machineConfig})
88 machine.wait_for_unit("multi-user.target")
93 x86_64-linux = "${pkgs.OVMF.fd}/FV/OVMF.fd";
94 aarch64-linux = "${pkgs.OVMF.fd}/FV/QEMU_EFI.fd";
95 }.${pkgs.stdenv.hostPlatform.system};
97 uefiCdrom = makeBootTest "uefi-cdrom" {
98 cdrom = "${iso}/iso/${iso.isoName}";
102 uefiUsb = makeBootTest "uefi-usb" {
103 usb = "${iso}/iso/${iso.isoName}";
107 uefiNetboot = makeNetbootTest "uefi" {
109 # Custom ROM is needed for EFI PXE boot. I failed to understand exactly why, because QEMU should still use iPXE for EFI.
110 netFrontendArgs = "romfile=${pkgs.ipxe}/ipxe.efirom";
112 } // optionalAttrs (pkgs.stdenv.hostPlatform.system == "x86_64-linux") {
113 biosCdrom = makeBootTest "bios-cdrom" {
114 cdrom = "${iso}/iso/${iso.isoName}";
117 biosUsb = makeBootTest "bios-usb" {
118 usb = "${iso}/iso/${iso.isoName}";
121 biosNetboot = makeNetbootTest "bios" {};
124 sdImage = "${sd}/sd-image/${sd.imageName}";
125 mutableImage = "/tmp/linked-image.qcow2";
127 machineConfig = pythonDict {
128 bios = "${pkgs.ubootQemuX86}/u-boot.rom";
129 qemuFlags = "-m 768 -machine type=pc,accel=tcg -drive file=${mutableImage},if=ide,format=qcow2";
132 name = "boot-uboot-extlinux";
137 # Create a mutable linked image backed by the read-only SD image
138 if os.system("qemu-img create -f qcow2 -F raw -b ${sdImage} ${mutableImage}") != 0:
139 raise RuntimeError("Could not create mutable linked image")
141 machine = create_machine(${machineConfig})
143 machine.wait_for_unit("multi-user.target")
144 machine.succeed("nix store verify -r --no-trust --option experimental-features nix-command /run/current-system")