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 lib pkgs; };
21 qemu = qemu-common.qemuBinary pkgs.qemu_test;
24 "-m" (toString memory)
25 "-netdev" ("user,id=net0" + (lib.optionalString (pxe != null) ",tftp=${pxe},bootfile=netboot.ipxe"))
26 "-device" ("virtio-net-pci,netdev=net0" + (lib.optionalString (pxe != null && uefi) ",romfile=${pkgs.ipxe}/ipxe.efirom"))
27 ] ++ lib.optionals (cdrom != null) [
29 ] ++ lib.optionals (usb != null) [
31 "-drive" "id=usbdisk,file=${usb},if=none,readonly"
32 "-device" "usb-storage,drive=usbdisk"
33 ] ++ lib.optionals (pxe != null) [
35 ] ++ lib.optionals uefi [
36 "-drive" "if=pflash,format=raw,unit=0,readonly=on,file=${pkgs.OVMF.firmware}"
37 "-drive" "if=pflash,format=raw,unit=1,readonly=on,file=${pkgs.OVMF.variables}"
40 flagsStr = lib.concatStringsSep " " flags;
41 in "${qemu} ${flagsStr}";
44 (import ../lib/eval-config.nix {
47 ../modules/installer/cd-dvd/installation-cd-minimal.nix
48 ../modules/testing/test-instrumentation.nix
50 }).config.system.build.isoImage;
53 (import ../lib/eval-config.nix {
56 ../modules/installer/sd-card/sd-image-x86_64.nix
57 ../modules/testing/test-instrumentation.nix
58 { sdImage.compressImage = false; }
60 }).config.system.build.sdImage;
62 makeBootTest = name: config:
64 startCommand = mkStartCommand config;
67 name = "boot-" + name;
71 machine = create_machine("${startCommand}")
73 machine.wait_for_unit("multi-user.target")
74 machine.succeed("nix store verify --no-trust -r --option experimental-features nix-command /run/current-system")
76 with subtest("Check whether the channel got installed correctly"):
77 machine.succeed("nix-instantiate --dry-run '<nixpkgs>' -A hello")
78 machine.succeed("nix-env --dry-run -iA nixos.procps")
84 makeNetbootTest = name: extraConfig:
86 config = (import ../lib/eval-config.nix {
89 [ ../modules/installer/netboot/netboot.nix
90 ../modules/testing/test-instrumentation.nix
94 ipxeBootDir = pkgs.symlinkJoin {
97 config.system.build.netbootRamdisk
98 config.system.build.kernel
99 config.system.build.netbootIpxeScript
102 startCommand = mkStartCommand ({
107 name = "boot-netboot-" + name;
110 machine = create_machine("${startCommand}")
112 machine.wait_for_unit("multi-user.target")
117 uefiCdrom = makeBootTest "uefi-cdrom" {
119 cdrom = "${iso}/iso/${iso.isoName}";
122 uefiUsb = makeBootTest "uefi-usb" {
124 usb = "${iso}/iso/${iso.isoName}";
127 uefiNetboot = makeNetbootTest "uefi" {
130 } // lib.optionalAttrs (pkgs.stdenv.hostPlatform.system == "x86_64-linux") {
131 biosCdrom = makeBootTest "bios-cdrom" {
132 cdrom = "${iso}/iso/${iso.isoName}";
135 biosUsb = makeBootTest "bios-usb" {
136 usb = "${iso}/iso/${iso.isoName}";
139 biosNetboot = makeNetbootTest "bios" {};
142 sdImage = "${sd}/sd-image/${sd.imageName}";
143 mutableImage = "/tmp/linked-image.qcow2";
145 startCommand = mkStartCommand {
147 "-bios" "${pkgs.ubootQemuX86}/u-boot.rom"
148 "-machine" "type=pc,accel=tcg"
149 "-drive" "file=${mutableImage},if=virtio"
153 name = "boot-uboot-extlinux";
158 # Create a mutable linked image backed by the read-only SD image
159 if os.system("qemu-img create -f qcow2 -F raw -b ${sdImage} ${mutableImage}") != 0:
160 raise RuntimeError("Could not create mutable linked image")
162 machine = create_machine("${startCommand}")
164 machine.wait_for_unit("multi-user.target")
165 machine.succeed("nix store verify -r --no-trust --option experimental-features nix-command /run/current-system")
169 # kernel can't find rootfs after boot - investigate?