nixos/boot: Port test to python

Changed files
+17 -18
nixos
tests
+17 -18
nixos/tests/boot.nix
···
pkgs ? import ../.. { inherit system config; }
}:
-
with import ../lib/testing.nix { inherit system pkgs; };
with pkgs.lib;
let
···
];
}).config.system.build.isoImage;
-
perlAttrs = params: "{ ${concatStringsSep ", " (mapAttrsToList (name: param: "${name} => ${builtins.toJSON param}") params)} }";
makeBootTest = name: extraConfig:
let
-
machineConfig = perlAttrs ({ qemuFlags = "-m 768"; } // extraConfig);
in
makeTest {
inherit iso;
···
nodes = { };
testScript =
''
-
my $machine = createMachine(${machineConfig});
-
$machine->start;
-
$machine->waitForUnit("multi-user.target");
-
$machine->succeed("nix verify -r --no-trust /run/current-system");
-
# 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");
-
$machine->shutdown;
'';
};
···
config.system.build.netbootIpxeScript
];
};
-
machineConfig = perlAttrs ({
qemuFlags = "-boot order=n -m 2000";
netBackendArgs = "tftp=${ipxeBootDir},bootfile=netboot.ipxe";
} // extraConfig);
···
makeTest {
name = "boot-netboot-" + name;
nodes = { };
-
testScript =
-
''
-
my $machine = createMachine(${machineConfig});
-
$machine->start;
-
$machine->waitForUnit("multi-user.target");
-
$machine->shutdown;
'';
};
in {
···
pkgs ? import ../.. { inherit system config; }
}:
+
with import ../lib/testing-python.nix { inherit system pkgs; };
with pkgs.lib;
let
···
];
}).config.system.build.isoImage;
+
pythonDict = params: "\n {\n ${concatStringsSep ",\n " (mapAttrsToList (name: param: "\"${name}\": \"${param}\"") params)},\n }\n";
makeBootTest = name: extraConfig:
let
+
machineConfig = pythonDict ({ qemuFlags = "-m 768"; } // extraConfig);
in
makeTest {
inherit iso;
···
nodes = { };
testScript =
''
+
machine = create_machine(${machineConfig})
+
machine.start()
+
machine.wait_for_unit("multi-user.target")
+
machine.succeed("nix verify -r --no-trust /run/current-system")
+
with subtest("Check whether the channel got installed correctly"):
+
machine.succeed("nix-instantiate --dry-run '<nixpkgs>' -A hello")
+
machine.succeed("nix-env --dry-run -iA nixos.procps")
+
machine.shutdown()
'';
};
···
config.system.build.netbootIpxeScript
];
};
+
machineConfig = pythonDict ({
qemuFlags = "-boot order=n -m 2000";
netBackendArgs = "tftp=${ipxeBootDir},bootfile=netboot.ipxe";
} // extraConfig);
···
makeTest {
name = "boot-netboot-" + name;
nodes = { };
+
testScript = ''
+
machine = create_machine(${machineConfig})
+
machine.start()
+
machine.wait_for_unit("multi-user.target")
+
machine.shutdown()
'';
};
in {