Commit 0f9bf615 authored by nikstur's avatar nikstur Committed by Bjørn Forsman
Browse files

nixos/tests: add squashfs test

parent 3b6bc9b5
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -128,4 +128,43 @@ with pkgs.lib;
        assert "erofs" in file_contents
      '';
    };

  squashfs =
    let
      fsImage = "/tmp/non-default-filesystem.img";
    in
    makeTest {
      name = "non-default-filesystems-squashfs";

      meta.maintainers = with maintainers; [ nikstur ];

      nodes.machine = {
        virtualisation.qemu.drives = [{
          name = "non-default-filesystem";
          file = fsImage;
          deviceExtraOpts.serial = "non-default";
        }];

        virtualisation.fileSystems."/non-default" = {
          device = "/dev/disk/by-id/virtio-non-default";
          fsType = "squashfs";
          neededForBoot = true;
        };
      };

      testScript = ''
        import subprocess

        with open("filesystem", "w") as f:
          f.write("squashfs")

        subprocess.run([
          "${pkgs.squashfsTools}/bin/mksquashfs",
          "filesystem",
          "${fsImage}",
        ])

        assert "squashfs" in machine.succeed("cat /non-default/filesystem")
      '';
    };
}