1 import ./make-test-python.nix ({ lib, pkgs, ... }: {
2 name = "systemd-initrd-simple";
4 nodes.machine = { pkgs, ... }: {
5 testing.initrdBackdoor = true;
6 boot.initrd.systemd.enable = true;
7 virtualisation.fileSystems."/".autoResize = true;
13 with subtest("testing initrd backdoor"):
14 machine.wait_for_unit("initrd.target")
15 machine.succeed("systemctl status initrd-fs.target")
18 with subtest("handover to stage-2 systemd works"):
19 machine.wait_for_unit("multi-user.target")
20 machine.succeed("systemd-analyze | grep -q '(initrd)'") # direct handover
21 machine.succeed("touch /testfile") # / is writable
22 machine.fail("touch /nix/store/testfile") # /nix/store is not writable
23 # Special filesystems are mounted by systemd
24 machine.succeed("[ -e /run/booted-system ]") # /run
25 machine.succeed("[ -e /sys/class ]") # /sys
26 machine.succeed("[ -e /dev/null ]") # /dev
27 machine.succeed("[ -e /proc/1 ]") # /proc
28 # stage-2-init mounted more special filesystems
29 machine.succeed("[ -e /dev/shm ]") # /dev/shm
30 machine.succeed("[ -e /dev/pts/ptmx ]") # /dev/pts
31 machine.succeed("[ -e /run/keys ]") # /run/keys
32 # /nixos-closure didn't leak into stage-2
33 machine.succeed("[ ! -e /nixos-closure ]")
35 with subtest("groups work"):
36 machine.fail("journalctl -b 0 | grep 'systemd-udevd.*Unknown group.*ignoring'")
38 with subtest("growfs works"):
39 oldAvail = machine.succeed("df --output=avail / | sed 1d")
42 subprocess.check_call(["qemu-img", "resize", "vm-state-machine/machine.qcow2", "+1G"])
46 newAvail = machine.succeed("df --output=avail / | sed 1d")
48 assert int(oldAvail) < int(newAvail), "File system did not grow"