aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/sandbox/case/default.nix
blob: 6c7cf127ee4d20a6fdc085173da0d0e70407d6f4 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
system: lib: testProgram:
let
  fs = mode: dir: data: {
    mode = lib.fromHexString mode;
    inherit
      dir
      data
      ;
  };

  ignore = "//ignore";

  ent = root: target: vfs_optstr: fstype: source: fs_optstr: {
    id = -1;
    parent = -1;
    inherit
      root
      target
      vfs_optstr
      fstype
      source
      fs_optstr
      ;
  };

  callTestCase =
    path: identity:
    let
      tc = import path {
        inherit
          fs
          ent
          ignore
          ;
      };
    in
    {
      name = "check-sandbox-${tc.name}";
      inherit identity;
      verbose = true;
      inherit (tc)
        tty
        device
        mapRealUid
        useCommonPaths
        userns
        ;
      share = testProgram;
      packages = [ ];
      path = "${testProgram}/bin/hakurei-test";
      args = [
        "test"
        "-t"
        (toString (builtins.toFile "hakurei-${tc.name}-want.json" (builtins.toJSON tc.want)))
        "-s"
        tc.expectedFilter.${system}
      ];
    };

  testCaseName = name: "cat.gensokyo.hakurei.test." + name;
in
{
  ${testCaseName "preset"} = callTestCase ./preset.nix 1;
  ${testCaseName "tty"} = callTestCase ./tty.nix 2;
  ${testCaseName "mapuid"} = callTestCase ./mapuid.nix 3;
  ${testCaseName "device"} = callTestCase ./device.nix 4;
  ${testCaseName "pdlike"} = callTestCase ./pdlike.nix 5;
}