2018-11-11 08:41:11 +00:00
|
|
|
{ system ? builtins.currentSystem,
|
|
|
|
config ? {},
|
|
|
|
pkgs ? import ../.. { inherit system config; }
|
|
|
|
}:
|
2014-11-19 22:18:44 +00:00
|
|
|
|
2019-10-27 12:22:46 +00:00
|
|
|
with import ../lib/testing-python.nix { inherit system pkgs; };
|
2014-11-19 22:18:44 +00:00
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
let
|
2021-09-29 13:27:43 +01:00
|
|
|
qemu-common = import ../lib/qemu-common.nix { inherit (pkgs) lib pkgs; };
|
2014-11-19 22:18:44 +00:00
|
|
|
|
|
|
|
iso =
|
|
|
|
(import ../lib/eval-config.nix {
|
|
|
|
inherit system;
|
2021-10-16 16:58:04 +01:00
|
|
|
modules = [
|
|
|
|
../modules/installer/cd-dvd/installation-cd-minimal.nix
|
|
|
|
../modules/testing/test-instrumentation.nix
|
|
|
|
];
|
2014-11-19 22:18:44 +00:00
|
|
|
}).config.system.build.isoImage;
|
|
|
|
|
2021-10-16 16:58:04 +01:00
|
|
|
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;
|
|
|
|
|
2019-10-27 12:22:46 +00:00
|
|
|
pythonDict = params: "\n {\n ${concatStringsSep ",\n " (mapAttrsToList (name: param: "\"${name}\": \"${param}\"") params)},\n }\n";
|
2018-02-27 18:58:23 +00:00
|
|
|
|
2019-07-15 16:56:53 +01:00
|
|
|
makeBootTest = name: extraConfig:
|
|
|
|
let
|
2021-05-25 19:13:29 +01:00
|
|
|
machineConfig = pythonDict ({
|
2021-09-29 13:27:43 +01:00
|
|
|
qemuBinary = qemu-common.qemuBinary pkgs.qemu_test;
|
2021-05-25 19:13:29 +01:00
|
|
|
qemuFlags = "-m 768";
|
|
|
|
} // extraConfig);
|
2019-07-15 16:56:53 +01:00
|
|
|
in
|
|
|
|
makeTest {
|
|
|
|
name = "boot-" + name;
|
|
|
|
nodes = { };
|
|
|
|
testScript =
|
|
|
|
''
|
2022-04-03 17:07:33 +01:00
|
|
|
machine = create_machine(${machineConfig})
|
2019-10-27 12:22:46 +00:00
|
|
|
machine.start()
|
|
|
|
machine.wait_for_unit("multi-user.target")
|
2021-11-10 23:57:00 +00:00
|
|
|
machine.succeed("nix store verify --no-trust -r --option experimental-features nix-command /run/current-system")
|
2016-05-25 09:21:14 +01:00
|
|
|
|
2019-10-27 12:22:46 +00:00
|
|
|
with subtest("Check whether the channel got installed correctly"):
|
|
|
|
machine.succeed("nix-instantiate --dry-run '<nixpkgs>' -A hello")
|
|
|
|
machine.succeed("nix-env --dry-run -iA nixos.procps")
|
2016-05-25 09:21:14 +01:00
|
|
|
|
2019-10-27 12:22:46 +00:00
|
|
|
machine.shutdown()
|
2019-07-15 16:56:53 +01:00
|
|
|
'';
|
|
|
|
};
|
2016-05-25 09:21:14 +01:00
|
|
|
|
2019-07-15 16:56:53 +01:00
|
|
|
makeNetbootTest = name: extraConfig:
|
|
|
|
let
|
2016-04-08 14:53:27 +01:00
|
|
|
config = (import ../lib/eval-config.nix {
|
|
|
|
inherit system;
|
|
|
|
modules =
|
|
|
|
[ ../modules/installer/netboot/netboot.nix
|
|
|
|
../modules/testing/test-instrumentation.nix
|
|
|
|
{ key = "serial"; }
|
|
|
|
];
|
|
|
|
}).config;
|
2016-05-03 21:05:11 +01:00
|
|
|
ipxeBootDir = pkgs.symlinkJoin {
|
|
|
|
name = "ipxeBootDir";
|
|
|
|
paths = [
|
|
|
|
config.system.build.netbootRamdisk
|
|
|
|
config.system.build.kernel
|
2019-07-15 16:56:53 +01:00
|
|
|
config.system.build.netbootIpxeScript
|
2016-05-03 21:05:11 +01:00
|
|
|
];
|
|
|
|
};
|
2019-10-27 12:22:46 +00:00
|
|
|
machineConfig = pythonDict ({
|
2021-09-29 13:27:43 +01:00
|
|
|
qemuBinary = qemu-common.qemuBinary pkgs.qemu_test;
|
2019-07-21 06:07:37 +01:00
|
|
|
qemuFlags = "-boot order=n -m 2000";
|
|
|
|
netBackendArgs = "tftp=${ipxeBootDir},bootfile=netboot.ipxe";
|
2019-07-15 16:56:53 +01:00
|
|
|
} // extraConfig);
|
2016-04-08 14:53:27 +01:00
|
|
|
in
|
|
|
|
makeTest {
|
2019-07-15 16:56:53 +01:00
|
|
|
name = "boot-netboot-" + name;
|
2016-04-08 14:53:27 +01:00
|
|
|
nodes = { };
|
2019-10-27 12:22:46 +00:00
|
|
|
testScript = ''
|
2022-04-03 17:07:33 +01:00
|
|
|
machine = create_machine(${machineConfig})
|
2019-10-27 12:22:46 +00:00
|
|
|
machine.start()
|
|
|
|
machine.wait_for_unit("multi-user.target")
|
|
|
|
machine.shutdown()
|
2016-04-08 14:53:27 +01:00
|
|
|
'';
|
|
|
|
};
|
2021-05-25 19:13:29 +01:00
|
|
|
uefiBinary = {
|
|
|
|
x86_64-linux = "${pkgs.OVMF.fd}/FV/OVMF.fd";
|
|
|
|
aarch64-linux = "${pkgs.OVMF.fd}/FV/QEMU_EFI.fd";
|
|
|
|
}.${pkgs.stdenv.hostPlatform.system};
|
2019-07-15 16:56:53 +01:00
|
|
|
in {
|
2021-05-25 19:13:29 +01:00
|
|
|
uefiCdrom = makeBootTest "uefi-cdrom" {
|
2019-07-22 11:21:33 +01:00
|
|
|
cdrom = "${iso}/iso/${iso.isoName}";
|
2021-05-25 19:13:29 +01:00
|
|
|
bios = uefiBinary;
|
2019-07-15 16:56:53 +01:00
|
|
|
};
|
|
|
|
|
2021-05-25 19:13:29 +01:00
|
|
|
uefiUsb = makeBootTest "uefi-usb" {
|
2019-07-22 11:21:33 +01:00
|
|
|
usb = "${iso}/iso/${iso.isoName}";
|
2021-05-25 19:13:29 +01:00
|
|
|
bios = uefiBinary;
|
2019-07-15 16:56:53 +01:00
|
|
|
};
|
|
|
|
|
2021-05-25 19:13:29 +01:00
|
|
|
uefiNetboot = makeNetbootTest "uefi" {
|
|
|
|
bios = uefiBinary;
|
|
|
|
# Custom ROM is needed for EFI PXE boot. I failed to understand exactly why, because QEMU should still use iPXE for EFI.
|
|
|
|
netFrontendArgs = "romfile=${pkgs.ipxe}/ipxe.efirom";
|
|
|
|
};
|
|
|
|
} // optionalAttrs (pkgs.stdenv.hostPlatform.system == "x86_64-linux") {
|
|
|
|
biosCdrom = makeBootTest "bios-cdrom" {
|
2019-07-22 11:21:33 +01:00
|
|
|
cdrom = "${iso}/iso/${iso.isoName}";
|
2019-07-15 16:56:53 +01:00
|
|
|
};
|
|
|
|
|
2021-05-25 19:13:29 +01:00
|
|
|
biosUsb = makeBootTest "bios-usb" {
|
2019-07-22 11:21:33 +01:00
|
|
|
usb = "${iso}/iso/${iso.isoName}";
|
2019-07-15 16:56:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
biosNetboot = makeNetbootTest "bios" {};
|
2021-10-16 16:58:04 +01:00
|
|
|
|
|
|
|
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")
|
|
|
|
|
2022-04-03 17:07:33 +01:00
|
|
|
machine = create_machine(${machineConfig})
|
2021-10-16 16:58:04 +01:00
|
|
|
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()
|
|
|
|
'';
|
|
|
|
};
|
2016-05-03 21:05:11 +01:00
|
|
|
}
|