diff options
author | Michael Pratt <mpratt@google.com> | 2019-02-25 18:05:58 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-02-25 18:06:43 -0800 |
commit | 563c9ed1d6814776aa22d3a272fe55c15143fe79 (patch) | |
tree | 9dcb6dae50a302a302e9b564f7e7816857c50e6b /test/syscalls/syscall_test_runner.go | |
parent | 26be25e4ecec2fa66ee819e980de353d657aa1f6 (diff) |
Use a custom, world-accessible, /tmp mount
This solves two problems:
1. Using the host /tmp directly meant that concurrent tests could
collide attempting to use the same file, and that misbehaving tests
never have their /tmp output cleaned up.
2. Host /tmp is not world-accessible on all hosts. Some tests (e.g.,
sticky) access files in /tmp from other users, so we need to ensure
that its /tmp is world-accessible.
PiperOrigin-RevId: 235637873
Change-Id: I7555224685ac5b93af88c403196b09ce1bb2bfe7
Diffstat (limited to 'test/syscalls/syscall_test_runner.go')
-rw-r--r-- | test/syscalls/syscall_test_runner.go | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/test/syscalls/syscall_test_runner.go b/test/syscalls/syscall_test_runner.go index 16228ef46..9fe801b26 100644 --- a/test/syscalls/syscall_test_runner.go +++ b/test/syscalls/syscall_test_runner.go @@ -115,10 +115,34 @@ func runTestCaseRunsc(testBin string, tc gtest.TestCase, t *testing.T) { spec.Mounts = nil if *useTmpfs { // Forces '/tmp' to be mounted as tmpfs, otherwise test that rely on - // features available in gVisor's tmpfs and not gofers, may fail. - spec.Mounts = []specs.Mount{ - {Destination: "/tmp", Type: "tmpfs"}, + // features only available in gVisor's internal tmpfs may fail. + spec.Mounts = append(spec.Mounts, specs.Mount{ + Destination: "/tmp", + Type: "tmpfs", + }) + } else { + // Use a gofer-backed directory as '/tmp'. + // + // Tests might be running in parallel, so make sure each has a + // unique test temp dir. + // + // Some tests (e.g., sticky) access this mount from other + // users, so make sure it is world-accessible. + tmpDir, err := ioutil.TempDir(testutil.TmpDir(), "") + if err != nil { + t.Fatalf("could not create temp dir: %v", err) } + defer os.RemoveAll(tmpDir) + + if err := os.Chmod(tmpDir, 0777); err != nil { + t.Fatalf("could not chmod temp dir: %v", err) + } + + spec.Mounts = append(spec.Mounts, specs.Mount{ + Type: "bind", + Destination: "/tmp", + Source: tmpDir, + }) } // Set environment variable that indicates we are |