diff options
author | Fabricio Voznika <fvoznika@google.com> | 2019-01-24 14:19:07 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-01-24 14:20:16 -0800 |
commit | 01679f3b5ab957c274690a62f0fce5d332ee94af (patch) | |
tree | d8379c22c1a4df03c096984eb2cfe0b3c5582311 /test | |
parent | 79e0451bd11645b0dff34c3a6c6131ed68c822f7 (diff) |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/syscalls/BUILD | 11 | ||||
-rw-r--r-- | test/syscalls/build_defs.bzl | 11 | ||||
-rw-r--r-- | test/syscalls/linux/inotify.cc | 6 | ||||
-rw-r--r-- | test/syscalls/syscall_test_runner.go | 13 |
4 files changed, 28 insertions, 13 deletions
diff --git a/test/syscalls/BUILD b/test/syscalls/BUILD index c46ac77f7..8c391c8a6 100644 --- a/test/syscalls/BUILD +++ b/test/syscalls/BUILD @@ -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", diff --git a/test/syscalls/build_defs.bzl b/test/syscalls/build_defs.bzl index 854684d1c..6bcb7adf7 100644 --- a/test/syscalls/build_defs.bzl +++ b/test/syscalls/build_defs.bzl @@ -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", diff --git a/test/syscalls/linux/inotify.cc b/test/syscalls/linux/inotify.cc index 167ca44a8..5c66db7c8 100644 --- a/test/syscalls/linux/inotify.cc +++ b/test/syscalls/linux/inotify.cc @@ -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 = diff --git a/test/syscalls/syscall_test_runner.go b/test/syscalls/syscall_test_runner.go index e5c2358a0..e8593ec73 100644 --- a/test/syscalls/syscall_test_runner.go +++ b/test/syscalls/syscall_test_runner.go @@ -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 |