diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-03-23 14:14:45 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-03-23 14:53:50 +0900 |
| commit | 75e0c5d4061d68dc4802285ec137e464f4e01b17 (patch) | |
| tree | b8307fa68188bac4c522afc36c27a5c1fb7c02da /sandbox | |
| parent | 770b37ae166a18f495865e96ccafc6f9fb9f4e88 (diff) | |
test/sandbox: parse full test case
This makes declaring multiple tests much cleaner.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'sandbox')
| -rw-r--r-- | sandbox/container_test.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sandbox/container_test.go b/sandbox/container_test.go index 13063600..ddacbcb8 100644 --- a/sandbox/container_test.go +++ b/sandbox/container_test.go @@ -117,11 +117,14 @@ func TestContainer(t *testing.T) { mnt = append(mnt, &check.Mntent{FSName: "\x00", Dir: name, Type: "\x00", Opts: "\x00", Freq: -1, Passno: -1}) } mnt = append(mnt, &check.Mntent{FSName: "proc", Dir: "/proc", Type: "proc", Opts: "rw,nosuid,nodev,noexec,relatime"}) - mntentWant := new(bytes.Buffer) - if err := json.NewEncoder(mntentWant).Encode(mnt); err != nil { - t.Fatalf("cannot serialise mntent: %v", err) + want := new(bytes.Buffer) + if err := json.NewEncoder(want).Encode(&check.TestCase{ + Mount: mnt, + Seccomp: true, + }); err != nil { + t.Fatalf("cannot serialise want: %v", err) } - container.Stdin = mntentWant + container.Stdin = want // needs /proc to check mntent container.Proc("/proc") @@ -185,8 +188,7 @@ func TestHelperCheckContainer(t *testing.T) { t.Errorf("/etc/hostname: %q, want %q", string(p), os.Args[5]) } }) - t.Run("seccomp", func(t *testing.T) { check.MustAssertSeccomp() }) - t.Run("mntent", func(t *testing.T) { check.MustAssertMounts("", "/proc/mounts", "/proc/self/fd/0") }) + t.Run("sandbox", func(t *testing.T) { (&check.T{PMountsPath: "/proc/mounts"}).MustCheckFile("/proc/self/fd/0") }) } func commandContext(ctx context.Context) *exec.Cmd { |
