at 23.11-beta 1.9 kB view raw
1import ./make-test-python.nix ({ lib, pkgs, ... }: { 2 name = "systemd-initrd-simple"; 3 4 nodes.machine = { pkgs, ... }: { 5 testing.initrdBackdoor = true; 6 boot.initrd.systemd.enable = true; 7 virtualisation.fileSystems."/".autoResize = true; 8 }; 9 10 testScript = '' 11 import subprocess 12 13 with subtest("testing initrd backdoor"): 14 machine.wait_for_unit("initrd.target") 15 machine.succeed("systemctl status initrd-fs.target") 16 machine.switch_root() 17 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 33 with subtest("groups work"): 34 machine.fail("journalctl -b 0 | grep 'systemd-udevd.*Unknown group.*ignoring'") 35 36 with subtest("growfs works"): 37 oldAvail = machine.succeed("df --output=avail / | sed 1d") 38 machine.shutdown() 39 40 subprocess.check_call(["qemu-img", "resize", "vm-state-machine/machine.qcow2", "+1G"]) 41 42 machine.start() 43 machine.switch_root() 44 newAvail = machine.succeed("df --output=avail / | sed 1d") 45 46 assert int(oldAvail) < int(newAvail), "File system did not grow" 47 ''; 48})