3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/nixos/tests/fsck.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.2 KiB
Nix
Raw Normal View History

2022-12-21 04:05:02 +00:00
{ system ? builtins.currentSystem
, config ? {}
, pkgs ? import ../.. { inherit system config; }
, systemdStage1 ? false
}:
2019-11-04 23:38:50 +00:00
import ./make-test-python.nix {
name = "fsck";
2022-03-20 23:15:30 +00:00
nodes.machine = { lib, ... }: {
virtualisation.emptyDiskImages = [ 1 ];
virtualisation.fileSystems = {
"/mnt" = {
device = "/dev/vdb";
fsType = "ext4";
autoFormat = true;
};
};
2022-12-21 04:05:02 +00:00
boot.initrd.systemd.enable = systemdStage1;
};
testScript = { nodes, ...}:
let
rootDevice = nodes.machine.virtualisation.rootDevice;
in
''
2019-11-04 23:38:50 +00:00
machine.wait_for_unit("default.target")
2019-11-04 23:38:50 +00:00
with subtest("root fs is fsckd"):
2022-12-21 04:05:02 +00:00
machine.succeed("journalctl -b | grep '${if systemdStage1
then "fsck.*${builtins.baseNameOf rootDevice}.*clean"
else "fsck.ext4.*${rootDevice}"}'")
2019-11-04 23:38:50 +00:00
with subtest("mnt fs is fsckd"):
machine.succeed("journalctl -b | grep 'fsck.*vdb.*clean'")
2019-11-04 23:38:50 +00:00
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"
)
'';
}