-
Notifications
You must be signed in to change notification settings - Fork 2
/
testvm.nix
23 lines (23 loc) · 940 Bytes
/
testvm.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{ hostPkgs ? import <nixpkgs> { config = {}; overlays = []; }, testflags ? "", fstype ? "ext4" }:
hostPkgs.testers.runNixOSTest ({config, ...}: {
name = "styxvmtest";
defaults._module.args = { inherit fstype; };
nodes.machine = ./vm-testsuite.nix;
extraDriverArgs = let
m = config.nodes.machine;
origScript = "${m.system.build.vm}/bin/run-${m.networking.hostName}-vm";
mkfs = if fstype == "ext4" then
"${hostPkgs.e2fsprogs}/bin/mkfs.ext4"
else if fstype == "btrfs" then
"${hostPkgs.btrfs-progs}/bin/mkfs.btrfs"
else throw "unknown fs type";
newScript = hostPkgs.runCommand "testvm-start-script" {} ''
sed 's|/nix/store/[^ /]*/bin/mkfs[.]ext4|${mkfs}|' < ${origScript} > $out
chmod a+x $out
'';
in ["--start-scripts ${newScript}"];
testScript = ''
machine.wait_for_unit("default.target")
machine.succeed("runstyxtest ${testflags}")
'';
})