Skip to content

Commit ddbd436

Browse files
symphorienajs124
authored andcommitted
nixos/tests/os-prober.nix: port to python
1 parent c59ea8b commit ddbd436

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

nixos/tests/os-prober.nix

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ./make-test.nix ({pkgs, lib, ...}:
1+
import ./make-test-python.nix ({pkgs, lib, ...}:
22
let
33
# A filesystem image with a (presumably) bootable debian
44
debianImage = pkgs.vmTools.diskImageFuns.debian9i386 {
@@ -34,9 +34,6 @@ let
3434
'';
3535
};
3636

37-
# options to add the disk to the test vm
38-
QEMU_OPTS = "-drive index=2,file=${debianImage}/disk-image.qcow2,read-only,if=virtio";
39-
4037
# a part of the configuration of the test vm
4138
simpleConfig = {
4239
boot.loader.grub = {
@@ -71,7 +68,7 @@ in {
7168
machine = { config, pkgs, ... }: (simpleConfig // {
7269
imports = [ ../modules/profiles/installation-device.nix
7370
../modules/profiles/base.nix ];
74-
virtualisation.memorySize = 1024;
71+
virtualisation.memorySize = 1300;
7572
# The test cannot access the network, so any packages
7673
# nixos-rebuild needs must be included in the VM.
7774
system.extraDependencies = with pkgs;
@@ -99,22 +96,28 @@ in {
9996

10097
testScript = ''
10198
# hack to add the secondary disk
102-
$machine->{startCommand} = "QEMU_OPTS=\"\$QEMU_OPTS \"${lib.escapeShellArg QEMU_OPTS} ".$machine->{startCommand};
99+
os.environ[
100+
"QEMU_OPTS"
101+
] = "-drive index=2,file=${debianImage}/disk-image.qcow2,read-only,if=virtio"
103102
104-
$machine->start;
105-
$machine->succeed("udevadm settle");
106-
$machine->waitForUnit("multi-user.target");
103+
machine.start()
104+
machine.succeed("udevadm settle")
105+
machine.wait_for_unit("multi-user.target")
106+
print(machine.succeed("lsblk"))
107107
108108
# check that os-prober works standalone
109-
$machine->succeed("${pkgs.os-prober}/bin/os-prober | grep /dev/vdb1");
109+
machine.succeed(
110+
"${pkgs.os-prober}/bin/os-prober | grep /dev/vdb1"
111+
)
110112
111113
# rebuild and test that debian is available in the grub menu
112-
$machine->succeed("nixos-generate-config");
113-
$machine->copyFileFromHost(
114+
machine.succeed("nixos-generate-config")
115+
machine.copy_from_host(
114116
"${configFile}",
115-
"/etc/nixos/configuration.nix");
116-
$machine->succeed("nixos-rebuild boot >&2");
117+
"/etc/nixos/configuration.nix",
118+
)
119+
machine.succeed("nixos-rebuild boot >&2")
117120
118-
$machine->succeed("egrep 'menuentry.*debian' /boot/grub/grub.cfg");
121+
machine.succeed("egrep 'menuentry.*debian' /boot/grub/grub.cfg")
119122
'';
120123
})

0 commit comments

Comments
 (0)