Add a test. Broken because unmounts don't work with the squashes?

This commit is contained in:
Graham Christensen 2020-06-07 20:09:58 -04:00
parent 3a1ad3ad53
commit 6f61d2d19a
No known key found for this signature in database
GPG Key ID: FE918C3A98C1030F
2 changed files with 65 additions and 4 deletions

View File

@ -3,7 +3,10 @@
{ config, lib, pkgs, ... }:
with lib;
let
inherit (lib) mkOption literalExample;
netbootpkgs = pkgs.callPackage ./pkgs {};
in
{
options = {
@ -81,20 +84,20 @@ with lib;
[ config.system.build.toplevel ];
# Create the squashfs image that contains the Nix store.
system.build.squashfsStore = pkgs.makeSquashes {
system.build.squashfsStore = netbootpkgs.makeSquashfsManifest {
name = "iso-manifeiist";
storeContents = config.netboot.storeContents;
};
# Create the initrd
system.build.netbootRamdisk = pkgs.makeInitrd {
inherit (config.boot.initrd) compressor;
prepend = [
"${config.system.build.initialRamdisk}/initrd"
"${(
pkgs.makeBetterInitrd {
netbootpkgs.makeCpioRecursive {
name = "better-initrd";
inherit (config.boot.initrd) compressor;
root = config.system.build.squashfsStore;
}
)}/initrd"
@ -118,6 +121,15 @@ with lib;
boot
'';
system.build.ipxeBootDir = pkgs.symlinkJoin {
name = "ipxeBootDir";
paths = [
config.system.build.netbootRamdisk
config.system.build.kernel
config.system.build.netbootIpxeScript
];
};
boot.loader.timeout = 10;
boot.postBootCommands =

49
test.nix Normal file
View File

@ -0,0 +1,49 @@
{ pkgs ? import <nixpkgs> {}
, system ? "x86_64-linux"
}:
let
inherit (pkgs.lib) concatStringsSep mapAttrsToList;
testlib = import "${pkgs.path}/nixos/lib/testing-python.nix" { inherit system pkgs; };
pythonDict = params: "\n {\n ${concatStringsSep ",\n " (mapAttrsToList (name: param: "\"${name}\": \"${param}\"") params)},\n }\n";
makeNetbootTest = name: extraConfig:
let
config = (
import "${pkgs.path}/nixos/lib/eval-config.nix" {
inherit system;
modules = [
./quickly.nix
"${pkgs.path}/nixos/modules/testing/test-instrumentation.nix"
{ key = "serial"; }
];
}
).config;
machineConfig = pythonDict (
{
qemuFlags = "-boot order=n -m 2000";
netBackendArgs = "tftp=${config.system.build.ipxeBootDir},bootfile=netboot.ipxe";
} // extraConfig
);
in
testlib.makeTest {
name = "boot-netboot-" + name;
nodes = {};
testScript = ''
machine = create_machine(${machineConfig})
machine.start()
machine.wait_for_unit("multi-user.target")
machine.shutdown()
'';
};
in
{
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.
netFrontendArgs = "romfile=${pkgs.ipxe}/ipxe.efirom";
};
}