nixos/boot: Port test to python
This commit is contained in:
parent
cdd4d4fadf
commit
d4a5ea5219
|
@ -3,7 +3,7 @@
|
||||||
pkgs ? import ../.. { inherit system config; }
|
pkgs ? import ../.. { inherit system config; }
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with import ../lib/testing.nix { inherit system pkgs; };
|
with import ../lib/testing-python.nix { inherit system pkgs; };
|
||||||
with pkgs.lib;
|
with pkgs.lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -17,11 +17,11 @@ let
|
||||||
];
|
];
|
||||||
}).config.system.build.isoImage;
|
}).config.system.build.isoImage;
|
||||||
|
|
||||||
perlAttrs = params: "{ ${concatStringsSep ", " (mapAttrsToList (name: param: "${name} => ${builtins.toJSON param}") params)} }";
|
pythonDict = params: "\n {\n ${concatStringsSep ",\n " (mapAttrsToList (name: param: "\"${name}\": \"${param}\"") params)},\n }\n";
|
||||||
|
|
||||||
makeBootTest = name: extraConfig:
|
makeBootTest = name: extraConfig:
|
||||||
let
|
let
|
||||||
machineConfig = perlAttrs ({ qemuFlags = "-m 768"; } // extraConfig);
|
machineConfig = pythonDict ({ qemuFlags = "-m 768"; } // extraConfig);
|
||||||
in
|
in
|
||||||
makeTest {
|
makeTest {
|
||||||
inherit iso;
|
inherit iso;
|
||||||
|
@ -29,16 +29,16 @@ let
|
||||||
nodes = { };
|
nodes = { };
|
||||||
testScript =
|
testScript =
|
||||||
''
|
''
|
||||||
my $machine = createMachine(${machineConfig});
|
machine = create_machine(${machineConfig})
|
||||||
$machine->start;
|
machine.start()
|
||||||
$machine->waitForUnit("multi-user.target");
|
machine.wait_for_unit("multi-user.target")
|
||||||
$machine->succeed("nix verify -r --no-trust /run/current-system");
|
machine.succeed("nix verify -r --no-trust /run/current-system")
|
||||||
|
|
||||||
# Test whether the channel got installed correctly.
|
with subtest("Check whether the channel got installed correctly"):
|
||||||
$machine->succeed("nix-instantiate --dry-run '<nixpkgs>' -A hello");
|
machine.succeed("nix-instantiate --dry-run '<nixpkgs>' -A hello")
|
||||||
$machine->succeed("nix-env --dry-run -iA nixos.procps");
|
machine.succeed("nix-env --dry-run -iA nixos.procps")
|
||||||
|
|
||||||
$machine->shutdown;
|
machine.shutdown()
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ let
|
||||||
config.system.build.netbootIpxeScript
|
config.system.build.netbootIpxeScript
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
machineConfig = perlAttrs ({
|
machineConfig = pythonDict ({
|
||||||
qemuFlags = "-boot order=n -m 2000";
|
qemuFlags = "-boot order=n -m 2000";
|
||||||
netBackendArgs = "tftp=${ipxeBootDir},bootfile=netboot.ipxe";
|
netBackendArgs = "tftp=${ipxeBootDir},bootfile=netboot.ipxe";
|
||||||
} // extraConfig);
|
} // extraConfig);
|
||||||
|
@ -68,12 +68,11 @@ let
|
||||||
makeTest {
|
makeTest {
|
||||||
name = "boot-netboot-" + name;
|
name = "boot-netboot-" + name;
|
||||||
nodes = { };
|
nodes = { };
|
||||||
testScript =
|
testScript = ''
|
||||||
''
|
machine = create_machine(${machineConfig})
|
||||||
my $machine = createMachine(${machineConfig});
|
machine.start()
|
||||||
$machine->start;
|
machine.wait_for_unit("multi-user.target")
|
||||||
$machine->waitForUnit("multi-user.target");
|
machine.shutdown()
|
||||||
$machine->shutdown;
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
|
Loading…
Reference in a new issue