2018-11-11 09:41:11 +01:00
|
|
|
{ system ? builtins.currentSystem,
|
|
|
|
config ? {},
|
|
|
|
pkgs ? import ../.. { inherit system config; }
|
|
|
|
}:
|
2014-11-19 23:18:44 +01:00
|
|
|
|
2018-11-11 09:41:11 +01:00
|
|
|
with import ../lib/testing.nix { inherit system pkgs; };
|
2014-11-19 23:18:44 +01:00
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
iso =
|
|
|
|
(import ../lib/eval-config.nix {
|
|
|
|
inherit system;
|
|
|
|
modules =
|
|
|
|
[ ../modules/installer/cd-dvd/installation-cd-minimal.nix
|
|
|
|
../modules/testing/test-instrumentation.nix
|
|
|
|
];
|
|
|
|
}).config.system.build.isoImage;
|
|
|
|
|
2019-07-15 17:56:53 +02:00
|
|
|
perlAttrs = params: "{ ${concatStringsSep "," (mapAttrsToList (name: param: "${name} => '${toString param}'") params)} }";
|
2018-02-27 19:58:23 +01:00
|
|
|
|
2019-07-15 17:56:53 +02:00
|
|
|
makeBootTest = name: extraConfig:
|
|
|
|
let
|
|
|
|
machineConfig = perlAttrs ({ qemuFlags = "-m 768"; } // extraConfig);
|
|
|
|
in
|
|
|
|
makeTest {
|
|
|
|
inherit iso;
|
|
|
|
name = "boot-" + name;
|
|
|
|
nodes = { };
|
|
|
|
testScript =
|
|
|
|
''
|
|
|
|
my $machine = createMachine(${machineConfig});
|
|
|
|
$machine->start;
|
|
|
|
$machine->waitForUnit("multi-user.target");
|
|
|
|
$machine->succeed("nix verify -r --no-trust /run/current-system");
|
2016-05-25 10:21:14 +02:00
|
|
|
|
2019-07-15 17:56:53 +02:00
|
|
|
# Test 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 10:21:14 +02:00
|
|
|
|
2019-07-15 17:56:53 +02:00
|
|
|
$machine->shutdown;
|
|
|
|
'';
|
|
|
|
};
|
2016-05-25 10:21:14 +02:00
|
|
|
|
2019-07-15 17:56:53 +02:00
|
|
|
makeNetbootTest = name: extraConfig:
|
|
|
|
let
|
2016-04-08 15:53:27 +02: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 22:05:11 +02:00
|
|
|
ipxeBootDir = pkgs.symlinkJoin {
|
|
|
|
name = "ipxeBootDir";
|
|
|
|
paths = [
|
|
|
|
config.system.build.netbootRamdisk
|
|
|
|
config.system.build.kernel
|
2019-07-15 17:56:53 +02:00
|
|
|
config.system.build.netbootIpxeScript
|
2016-05-03 22:05:11 +02:00
|
|
|
];
|
|
|
|
};
|
2019-07-15 17:56:53 +02:00
|
|
|
machineConfig = perlAttrs ({
|
2019-07-21 07:07:37 +02:00
|
|
|
qemuFlags = "-boot order=n -m 2000";
|
|
|
|
netBackendArgs = "tftp=${ipxeBootDir},bootfile=netboot.ipxe";
|
2019-07-15 17:56:53 +02:00
|
|
|
} // extraConfig);
|
2016-04-08 15:53:27 +02:00
|
|
|
in
|
|
|
|
makeTest {
|
2019-07-15 17:56:53 +02:00
|
|
|
name = "boot-netboot-" + name;
|
2016-04-08 15:53:27 +02:00
|
|
|
nodes = { };
|
|
|
|
testScript =
|
|
|
|
''
|
2019-07-15 17:56:53 +02:00
|
|
|
my $machine = createMachine(${machineConfig});
|
2016-04-08 15:53:27 +02:00
|
|
|
$machine->start;
|
|
|
|
$machine->waitForUnit("multi-user.target");
|
|
|
|
$machine->shutdown;
|
|
|
|
'';
|
|
|
|
};
|
2019-07-15 17:56:53 +02:00
|
|
|
in {
|
|
|
|
|
|
|
|
biosCdrom = makeBootTest "bios-cdrom" {
|
|
|
|
cdrom = ''glob("${iso}/iso/*.iso")'';
|
|
|
|
};
|
|
|
|
|
|
|
|
biosUsb = makeBootTest "bios-usb" {
|
|
|
|
usb = ''glob("${iso}/iso/*.iso")'';
|
|
|
|
};
|
|
|
|
|
|
|
|
uefiCdrom = makeBootTest "uefi-cdrom" {
|
|
|
|
cdrom = ''glob("${iso}/iso/*.iso"'';
|
|
|
|
bios = ''"${pkgs.OVMF.fd}/FV/OVMF.fd"'';
|
|
|
|
};
|
|
|
|
|
|
|
|
uefiUsb = makeBootTest "uefi-usb" {
|
|
|
|
usb = ''glob("${iso}/iso/*.iso")'';
|
|
|
|
bios = ''"${pkgs.OVMF.fd}/FV/OVMF.fd"'';
|
|
|
|
};
|
|
|
|
|
|
|
|
biosNetboot = makeNetbootTest "bios" {};
|
|
|
|
|
|
|
|
uefiNetboot = makeNetbootTest "uefi" {
|
|
|
|
bios = ''"${pkgs.OVMF.fd}/FV/OVMF.fd"'';
|
|
|
|
# Custom ROM is needed for EFI PXE boot. I failed to understand exactly why, because QEMU should still use iPXE for EFI.
|
2019-07-21 07:07:37 +02:00
|
|
|
netFrontendArgs = ''romfile="${pkgs.ipxe}/ipxe.efirom"'';
|
2019-07-15 17:56:53 +02:00
|
|
|
};
|
2016-05-03 22:05:11 +02:00
|
|
|
}
|