Increase gofer coverage in tests

Lots of tests use /tmp for the tests. Force /tmp to be
mounted over fsgofer instead of tmpfs.

PiperOrigin-RevId: 230788985
Change-Id: Id6597ed88133232d15e808c48126bf77cb32673e
This commit is contained in:
Fabricio Voznika
2019-01-24 14:20:16 -08:00
committed by Shentubot
parent 79e0451bd1
commit 01679f3b5a
4 changed files with 28 additions and 13 deletions
+9 -2
View File
@@ -42,6 +42,7 @@ syscall_test(test = "//test/syscalls/linux:chmod_test")
syscall_test(
size = "medium",
test = "//test/syscalls/linux:chown_test",
use_tmpfs = True, # chwon tests require gofer to be running as root.
)
syscall_test(test = "//test/syscalls/linux:chroot_test")
@@ -137,7 +138,10 @@ syscall_test(
syscall_test(test = "//test/syscalls/linux:kill_test")
syscall_test(test = "//test/syscalls/linux:link_test")
syscall_test(
test = "//test/syscalls/linux:link_test",
use_tmpfs = True, # gofer needs CAP_DAC_READ_SEARCH to use AT_EMPTY_PATH with linkat(2)
)
syscall_test(test = "//test/syscalls/linux:lseek_test")
@@ -151,7 +155,10 @@ syscall_test(test = "//test/syscalls/linux:mincore_test")
syscall_test(test = "//test/syscalls/linux:mkdir_test")
syscall_test(test = "//test/syscalls/linux:mknod_test")
syscall_test(
test = "//test/syscalls/linux:mknod_test",
use_tmpfs = True, # mknod is not supported over gofer.
)
syscall_test(
size = "medium",
+6 -5
View File
@@ -2,12 +2,12 @@
# syscall_test is a macro that will create targets to run the given test target
# on the host (native) and runsc.
def syscall_test(test, shard_count = 5, size = "small"):
_syscall_test(test, shard_count, size, "native")
_syscall_test(test, shard_count, size, "kvm")
_syscall_test(test, shard_count, size, "ptrace")
def syscall_test(test, shard_count = 5, size = "small", use_tmpfs = False):
_syscall_test(test, shard_count, size, "native", False)
_syscall_test(test, shard_count, size, "kvm", use_tmpfs)
_syscall_test(test, shard_count, size, "ptrace", use_tmpfs)
def _syscall_test(test, shard_count, size, platform):
def _syscall_test(test, shard_count, size, platform, use_tmpfs):
test_name = test.split(":")[1]
# Prepend "runsc" to non-native platform names.
@@ -39,6 +39,7 @@ def _syscall_test(test, shard_count, size, platform):
# Arguments are passed directly to syscall_test_runner binary.
"--test-name=" + test_name,
"--platform=" + platform,
"--use-tmpfs=" + str(use_tmpfs),
"--debug=false",
"--strace=false",
"--parallel=true",
+4 -2
View File
@@ -1222,7 +1222,8 @@ TEST(Inotify, LinkGeneratesAttribAndCreateEvents) {
const int rc = link(file1.path().c_str(), link1.path().c_str());
// link(2) is only supported on tmpfs in the sandbox.
SKIP_IF(IsRunningOnGvisor() && rc != 0 && errno == EPERM);
SKIP_IF(IsRunningOnGvisor() && rc != 0 &&
(errno == EPERM || errno == ENOENT));
ASSERT_THAT(rc, SyscallSucceeds());
const std::vector<Event> events =
@@ -1238,7 +1239,8 @@ TEST(Inotify, HardlinksReuseSameWatch) {
TempPath link1(root.path() + "/link1");
const int rc = link(file1.path().c_str(), link1.path().c_str());
// link(2) is only supported on tmpfs in the sandbox.
SKIP_IF(IsRunningOnGvisor() && rc != 0 && errno == EPERM);
SKIP_IF(IsRunningOnGvisor() && rc != 0 &&
(errno == EPERM || errno == ENOENT));
ASSERT_THAT(rc, SyscallSucceeds());
const FileDescriptor fd =
+9 -4
View File
@@ -45,6 +45,7 @@ var (
debug = flag.Bool("debug", false, "enable debug logs")
strace = flag.Bool("strace", false, "enable strace logs")
platform = flag.String("platform", "ptrace", "platform to run on")
useTmpfs = flag.Bool("use-tmpfs", false, "mounts tmpfs for /tmp")
parallel = flag.Bool("parallel", false, "run tests in parallel")
runscPath = flag.String("runsc", "", "path to runsc binary")
)
@@ -109,10 +110,14 @@ func runTestCaseRunsc(testBin string, tc gtest.TestCase, t *testing.T) {
// write to the rootfs, and expect EACCES, not EROFS.
spec.Root.Readonly = false
// 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"},
// Test spec comes with pre-defined mounts that we don't want. Reset it.
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"},
}
}
// Set environment variable that indicates we are