1{ system ? builtins.currentSystem
2, config ? {}
3, pkgs ? import ../.. { inherit system config; }
4, systemdStage1 ? false
5}:
6
7import ./make-test-python.nix {
8 name = "fsck";
9
10 nodes.machine = { lib, ... }: {
11 virtualisation.emptyDiskImages = [ 1 ];
12
13 virtualisation.fileSystems = {
14 "/mnt" = {
15 device = "/dev/vdb";
16 fsType = "ext4";
17 autoFormat = true;
18 };
19 };
20
21 boot.initrd.systemd.enable = systemdStage1;
22 };
23
24 testScript = { nodes, ...}:
25 let
26 rootDevice = nodes.machine.virtualisation.rootDevice;
27 in
28 ''
29 machine.wait_for_unit("default.target")
30
31 with subtest("root fs is fsckd"):
32 machine.succeed("journalctl -b | grep '${if systemdStage1
33 then "fsck.*${builtins.baseNameOf rootDevice}.*clean"
34 else "fsck.ext4.*${rootDevice}"}'")
35
36 with subtest("mnt fs is fsckd"):
37 machine.succeed("journalctl -b | grep 'fsck.*vdb.*clean'")
38 machine.succeed(
39 "grep 'Requires=systemd-fsck@dev-vdb.service' /run/systemd/generator/mnt.mount"
40 )
41 machine.succeed(
42 "grep 'After=systemd-fsck@dev-vdb.service' /run/systemd/generator/mnt.mount"
43 )
44 '';
45}