nixos/tests/os-prober.nix: port to python
This commit is contained in:
parent
c59ea8b8a0
commit
ddbd436dc4
@ -1,4 +1,4 @@
|
|||||||
import ./make-test.nix ({pkgs, lib, ...}:
|
import ./make-test-python.nix ({pkgs, lib, ...}:
|
||||||
let
|
let
|
||||||
# A filesystem image with a (presumably) bootable debian
|
# A filesystem image with a (presumably) bootable debian
|
||||||
debianImage = pkgs.vmTools.diskImageFuns.debian9i386 {
|
debianImage = pkgs.vmTools.diskImageFuns.debian9i386 {
|
||||||
@ -34,9 +34,6 @@ let
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
# options to add the disk to the test vm
|
|
||||||
QEMU_OPTS = "-drive index=2,file=${debianImage}/disk-image.qcow2,read-only,if=virtio";
|
|
||||||
|
|
||||||
# a part of the configuration of the test vm
|
# a part of the configuration of the test vm
|
||||||
simpleConfig = {
|
simpleConfig = {
|
||||||
boot.loader.grub = {
|
boot.loader.grub = {
|
||||||
@ -71,7 +68,7 @@ in {
|
|||||||
machine = { config, pkgs, ... }: (simpleConfig // {
|
machine = { config, pkgs, ... }: (simpleConfig // {
|
||||||
imports = [ ../modules/profiles/installation-device.nix
|
imports = [ ../modules/profiles/installation-device.nix
|
||||||
../modules/profiles/base.nix ];
|
../modules/profiles/base.nix ];
|
||||||
virtualisation.memorySize = 1024;
|
virtualisation.memorySize = 1300;
|
||||||
# The test cannot access the network, so any packages
|
# The test cannot access the network, so any packages
|
||||||
# nixos-rebuild needs must be included in the VM.
|
# nixos-rebuild needs must be included in the VM.
|
||||||
system.extraDependencies = with pkgs;
|
system.extraDependencies = with pkgs;
|
||||||
@ -99,22 +96,28 @@ in {
|
|||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
# hack to add the secondary disk
|
# hack to add the secondary disk
|
||||||
$machine->{startCommand} = "QEMU_OPTS=\"\$QEMU_OPTS \"${lib.escapeShellArg QEMU_OPTS} ".$machine->{startCommand};
|
os.environ[
|
||||||
|
"QEMU_OPTS"
|
||||||
|
] = "-drive index=2,file=${debianImage}/disk-image.qcow2,read-only,if=virtio"
|
||||||
|
|
||||||
$machine->start;
|
machine.start()
|
||||||
$machine->succeed("udevadm settle");
|
machine.succeed("udevadm settle")
|
||||||
$machine->waitForUnit("multi-user.target");
|
machine.wait_for_unit("multi-user.target")
|
||||||
|
print(machine.succeed("lsblk"))
|
||||||
|
|
||||||
# check that os-prober works standalone
|
# check that os-prober works standalone
|
||||||
$machine->succeed("${pkgs.os-prober}/bin/os-prober | grep /dev/vdb1");
|
machine.succeed(
|
||||||
|
"${pkgs.os-prober}/bin/os-prober | grep /dev/vdb1"
|
||||||
|
)
|
||||||
|
|
||||||
# rebuild and test that debian is available in the grub menu
|
# rebuild and test that debian is available in the grub menu
|
||||||
$machine->succeed("nixos-generate-config");
|
machine.succeed("nixos-generate-config")
|
||||||
$machine->copyFileFromHost(
|
machine.copy_from_host(
|
||||||
"${configFile}",
|
"${configFile}",
|
||||||
"/etc/nixos/configuration.nix");
|
"/etc/nixos/configuration.nix",
|
||||||
$machine->succeed("nixos-rebuild boot >&2");
|
)
|
||||||
|
machine.succeed("nixos-rebuild boot >&2")
|
||||||
|
|
||||||
$machine->succeed("egrep 'menuentry.*debian' /boot/grub/grub.cfg");
|
machine.succeed("egrep 'menuentry.*debian' /boot/grub/grub.cfg")
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user