2024-12-10 20:26:33 +01:00
|
|
|
{
|
|
|
|
system ? builtins.currentSystem,
|
|
|
|
config ? { },
|
|
|
|
pkgs ? import ../.. { inherit system config; },
|
|
|
|
systemdStage1 ? false,
|
2022-12-20 23:05:02 -05:00
|
|
|
}:
|
|
|
|
|
2019-11-05 00:38:50 +01:00
|
|
|
import ./make-test-python.nix {
|
2018-08-21 21:39:27 -04:00
|
|
|
name = "fsck";
|
|
|
|
|
2024-12-10 20:26:33 +01:00
|
|
|
nodes.machine =
|
|
|
|
{ lib, ... }:
|
|
|
|
{
|
|
|
|
virtualisation.emptyDiskImages = [ 1 ];
|
2018-08-21 21:39:27 -04:00
|
|
|
|
2024-12-10 20:26:33 +01:00
|
|
|
virtualisation.fileSystems = {
|
|
|
|
"/mnt" = {
|
|
|
|
device = "/dev/vdb";
|
|
|
|
fsType = "ext4";
|
|
|
|
autoFormat = true;
|
|
|
|
};
|
2018-08-21 21:39:27 -04:00
|
|
|
};
|
2022-12-20 23:05:02 -05:00
|
|
|
|
2024-12-10 20:26:33 +01:00
|
|
|
boot.initrd.systemd.enable = systemdStage1;
|
|
|
|
};
|
2018-08-21 21:39:27 -04:00
|
|
|
|
2024-12-10 20:26:33 +01:00
|
|
|
testScript =
|
|
|
|
{ nodes, ... }:
|
|
|
|
let
|
|
|
|
rootDevice = nodes.machine.virtualisation.rootDevice;
|
|
|
|
in
|
|
|
|
''
|
|
|
|
machine.wait_for_unit("default.target")
|
2018-08-21 21:39:27 -04:00
|
|
|
|
2024-12-10 20:26:33 +01:00
|
|
|
with subtest("root fs is fsckd"):
|
|
|
|
machine.succeed("journalctl -b | grep '${
|
|
|
|
if systemdStage1 then
|
|
|
|
"fsck.*${builtins.baseNameOf rootDevice}.*clean"
|
|
|
|
else
|
|
|
|
"fsck.ext4.*${rootDevice}"
|
|
|
|
}'")
|
2018-08-21 21:39:27 -04:00
|
|
|
|
2024-12-10 20:26:33 +01:00
|
|
|
with subtest("mnt fs is fsckd"):
|
|
|
|
machine.succeed("journalctl -b | grep 'fsck.*vdb.*clean'")
|
|
|
|
machine.succeed(
|
|
|
|
"grep 'Requires=systemd-fsck@dev-vdb.service' /run/systemd/generator/mnt.mount"
|
|
|
|
)
|
|
|
|
machine.succeed(
|
|
|
|
"grep 'After=systemd-fsck@dev-vdb.service' /run/systemd/generator/mnt.mount"
|
|
|
|
)
|
|
|
|
'';
|
2018-08-21 21:39:27 -04:00
|
|
|
}
|