summaryrefslogtreecommitdiffstats
path: root/nixos/tests/fsck.nix
blob: 35d63b7985a9801387561a355cef91c8ec37dd58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{ lib, systemdStage1, ... }:

{
  name = "fsck" + lib.optionalString systemdStage1 "-systemd-stage-1";

  nodes.machine = {
    virtualisation.emptyDiskImages = [ 1 ];

    virtualisation.fileSystems = {
      "/mnt" = {
        device = "/dev/vdb";
        fsType = "ext4";
        autoFormat = true;
      };
    };

    boot.initrd.systemd.enable = systemdStage1;
  };

  testScript =
    { nodes, ... }:
    let
      rootDevice = nodes.machine.virtualisation.rootDevice;
    in
    ''
      machine.wait_for_unit("default.target")

      with subtest("root fs is fsckd"):
          machine.succeed("journalctl -b | grep '${
            if systemdStage1 then "fsck.*${baseNameOf rootDevice}.*clean" else "fsck.ext4.*${rootDevice}"
          }'")

      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"
          )
    '';
}