Files
bootvine/demo/test.nix
T

49 lines
1.7 KiB
Nix

{ demoHost }:
{
name = "bootvine";
enableOCR = true;
nodes.machine =
{ lib, ... }:
{
imports = [ demoHost ];
systemd.settings.Manager.ShowStatus = lib.mkForce true;
virtualisation = {
memorySize = 2048;
qemu.options = [
"-vga none"
"-device virtio-vga,xres=1280,yres=800"
];
};
};
testScript = ''
machine.start()
machine.wait_for_text("initrd")
machine.screenshot("initrd")
machine.wait_for_text("stage 2")
machine.screenshot("stage-2")
machine.wait_for_unit("greetd.service")
machine.wait_until_succeeds("systemctl show -p ActiveState --value bootvine | grep -qx inactive")
journal = machine.succeed("journalctl -b -u bootvine -o cat")
print(journal)
watched = [line for line in journal.splitlines() if line.startswith("bootvine: watching")]
assert any(" in initrd " in line for line in watched), "never ran in the initrd"
assert any(" in stage 2 " in line for line in watched), "never reconnected after the root switch"
pids = {line.split(" as pid ")[1].split()[0] for line in watched}
assert len(pids) == 1, f"the initrd process did not survive the root switch: {pids}"
assert "handing the console over" in journal, "never handed the console over"
machine.succeed("test \"$(systemctl show -p Result --value bootvine)\" = success")
console_level = machine.succeed("cut -f1 /proc/sys/kernel/printk").strip()
assert console_level != "1", f"kernel console level was not restored: {console_level}"
show_status = machine.succeed("systemctl show -p ShowStatus --value").strip()
assert show_status == "yes", f"systemd status output was not restored: {show_status}"
machine.screenshot("handed-over")
'';
}