From 75e0c5d4061d68dc4802285ec137e464f4e01b17 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sun, 23 Mar 2025 14:14:45 +0900 Subject: test/sandbox: parse full test case This makes declaring multiple tests much cleaner. Signed-off-by: Ophestra --- sandbox/container_test.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'sandbox') 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 { -- cgit v1.3.1