diff options
author | Fabricio Voznika <fvoznika@google.com> | 2020-06-17 19:08:14 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-06-17 19:09:37 -0700 |
commit | 22b0bb21383614f6258dee27f4a254d2da97b586 (patch) | |
tree | 62a0fb24725a592fa25793bc9547035a95022baa | |
parent | 97f6b20e89d99c4d92d6491ef3fad0933c9ba53d (diff) |
Add TempTmpMount test
This currently doesn't work with VSF2. Add test to ensure
it's not missed.
Updates #1487
PiperOrigin-RevId: 317013792
-rw-r--r-- | test/e2e/integration_test.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/e2e/integration_test.go b/test/e2e/integration_test.go index 91c956e10..60e739c6a 100644 --- a/test/e2e/integration_test.go +++ b/test/e2e/integration_test.go @@ -24,10 +24,12 @@ package integration import ( "flag" "fmt" + "io/ioutil" "net" "net/http" "os" "os/exec" + "path/filepath" "strconv" "strings" "syscall" @@ -389,6 +391,37 @@ func TestTmpFile(t *testing.T) { } } +// TestTmpMount checks that mounts inside '/tmp' are not overridden. +func TestTmpMount(t *testing.T) { + dir, err := ioutil.TempDir(testutil.TmpDir(), "tmp-mount") + if err != nil { + t.Fatalf("TempDir(): %v", err) + } + want := "123" + if err := ioutil.WriteFile(filepath.Join(dir, "file.txt"), []byte("123"), 0666); err != nil { + t.Fatalf("WriteFile(): %v", err) + } + d := dockerutil.MakeDocker(t) + defer d.CleanUp() + + opts := dockerutil.RunOpts{ + Image: "basic/alpine", + Mounts: []dockerutil.Mount{ + { + Source: dir, + Target: "/tmp/foo", + }, + }, + } + got, err := d.Run(opts, "cat", "/tmp/foo/file.txt") + if err != nil { + t.Fatalf("docker run failed: %v", err) + } + if want != got { + t.Errorf("invalid file content, want: %q, got: %q", want, got) + } +} + // TestHostOverlayfsCopyUp tests that the --overlayfs-stale-read option causes // runsc to hide the incoherence of FDs opened before and after overlayfs // copy-up on the host. |