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
33 with subtest("groups work"):
34 machine.fail("journalctl -b 0 | grep 'systemd-udevd.*Unknown group.*ignoring'")
36 with subtest("growfs works"):
37 oldAvail = machine.succeed("df --output=avail / | sed 1d")
40 subprocess.check_call(["qemu-img", "resize", "vm-state-machine/machine.qcow2", "+1G"])
44 newAvail = machine.succeed("df --output=avail / | sed 1d")
46 assert int(oldAvail) < int(newAvail), "File system did not grow"