2022-04-03 18:54:34 +00:00
|
|
|
import ./make-test-python.nix ({ lib, pkgs, ... }: {
|
|
|
|
name = "systemd-initrd-simple";
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
nodes.machine = { pkgs, ... }: {
|
2022-04-03 18:54:34 +00:00
|
|
|
boot.initrd.systemd = {
|
|
|
|
enable = true;
|
|
|
|
emergencyAccess = true;
|
|
|
|
};
|
|
|
|
fileSystems = lib.mkVMOverride {
|
|
|
|
"/".autoResize = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
import subprocess
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
with subtest("handover to stage-2 systemd works"):
|
|
|
|
machine.wait_for_unit("multi-user.target")
|
|
|
|
machine.succeed("systemd-analyze | grep -q '(initrd)'") # direct handover
|
|
|
|
machine.succeed("touch /testfile") # / is writable
|
|
|
|
machine.fail("touch /nix/store/testfile") # /nix/store is not writable
|
|
|
|
# Special filesystems are mounted by systemd
|
|
|
|
machine.succeed("[ -e /run/booted-system ]") # /run
|
|
|
|
machine.succeed("[ -e /sys/class ]") # /sys
|
|
|
|
machine.succeed("[ -e /dev/null ]") # /dev
|
|
|
|
machine.succeed("[ -e /proc/1 ]") # /proc
|
|
|
|
# stage-2-init mounted more special filesystems
|
|
|
|
machine.succeed("[ -e /dev/shm ]") # /dev/shm
|
|
|
|
machine.succeed("[ -e /dev/pts/ptmx ]") # /dev/pts
|
|
|
|
machine.succeed("[ -e /run/keys ]") # /run/keys
|
2022-04-03 18:54:34 +00:00
|
|
|
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
with subtest("growfs works"):
|
|
|
|
oldAvail = machine.succeed("df --output=avail / | sed 1d")
|
|
|
|
machine.shutdown()
|
2022-04-03 18:54:34 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
subprocess.check_call(["qemu-img", "resize", "vm-state-machine/machine.qcow2", "+1G"])
|
|
|
|
|
|
|
|
machine.start()
|
|
|
|
newAvail = machine.succeed("df --output=avail / | sed 1d")
|
|
|
|
|
|
|
|
assert int(oldAvail) < int(newAvail), "File system did not grow"
|
2022-04-03 18:54:34 +00:00
|
|
|
'';
|
|
|
|
})
|