Add TempTmpMount test

This currently doesn't work with VSF2. Add test to ensure
it's not missed.

Updates #1487

PiperOrigin-RevId: 317013792
This commit is contained in:
Fabricio Voznika 2020-06-17 19:08:14 -07:00 committed by gVisor bot
parent 97f6b20e89
commit 22b0bb2138
1 changed files with 33 additions and 0 deletions

View File

@ -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.