summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2021-01-15 13:01:21 -0800
committergVisor bot <gvisor-bot@google.com>2021-01-15 13:03:58 -0800
commitf03144d886791afcdd37962388e9a6294a08c49f (patch)
tree0c23b8a254f9af076e2facb040cf06a1f22e3d9d
parentf1420cf48418c01694eaf3110ac411915b217d36 (diff)
Support TEST_PREMATURE_EXIT_FILE in syscall tests
PiperOrigin-RevId: 352068182
-rw-r--r--test/runner/runner.go18
-rw-r--r--test/syscalls/linux/fault.cc7
2 files changed, 9 insertions, 16 deletions
diff --git a/test/runner/runner.go b/test/runner/runner.go
index 7ab2c3edf..e72c59200 100644
--- a/test/runner/runner.go
+++ b/test/runner/runner.go
@@ -49,7 +49,6 @@ var (
overlay = flag.Bool("overlay", false, "wrap filesystem mounts with writable tmpfs overlay")
vfs2 = flag.Bool("vfs2", false, "enable VFS2")
fuse = flag.Bool("fuse", false, "enable FUSE")
- parallel = flag.Bool("parallel", false, "run tests in parallel")
runscPath = flag.String("runsc", "", "path to runsc binary")
addUDSTree = flag.Bool("add-uds-tree", false, "expose a tree of UDS utilities for use in tests")
@@ -83,13 +82,8 @@ func runTestCaseNative(testBin string, tc gtest.TestCase, t *testing.T) {
if !found {
env = append(env, newEnvVar)
}
- // Remove env variables that cause the gunit binary to write output
- // files, since they will stomp on eachother, and on the output files
- // from this go test.
- env = filterEnv(env, []string{"GUNIT_OUTPUT", "TEST_PREMATURE_EXIT_FILE", "XML_OUTPUT_FILE"})
-
// Remove shard env variables so that the gunit binary does not try to
- // intepret them.
+ // interpret them.
env = filterEnv(env, []string{"TEST_SHARD_INDEX", "TEST_TOTAL_SHARDS", "GTEST_SHARD_INDEX", "GTEST_TOTAL_SHARDS"})
if *addUDSTree {
@@ -390,13 +384,8 @@ func runTestCaseRunsc(testBin string, tc gtest.TestCase, t *testing.T) {
env = append(env, vfsVar+"=VFS1")
}
- // Remove env variables that cause the gunit binary to write output
- // files, since they will stomp on eachother, and on the output files
- // from this go test.
- env = filterEnv(env, []string{"GUNIT_OUTPUT", "TEST_PREMATURE_EXIT_FILE", "XML_OUTPUT_FILE"})
-
// Remove shard env variables so that the gunit binary does not try to
- // intepret them.
+ // interpret them.
env = filterEnv(env, []string{"TEST_SHARD_INDEX", "TEST_TOTAL_SHARDS", "GTEST_SHARD_INDEX", "GTEST_TOTAL_SHARDS"})
// Set TEST_TMPDIR to /tmp, as some of the syscall tests require it to
@@ -507,9 +496,6 @@ func main() {
tests = append(tests, testing.InternalTest{
Name: fmt.Sprintf("%s_%s", tc.Suite, tc.Name),
F: func(t *testing.T) {
- if *parallel {
- t.Parallel()
- }
if *platform == "native" {
// Run the test case on host.
runTestCaseNative(testBin, tc, t)
diff --git a/test/syscalls/linux/fault.cc b/test/syscalls/linux/fault.cc
index a85750382..bd87d5e60 100644
--- a/test/syscalls/linux/fault.cc
+++ b/test/syscalls/linux/fault.cc
@@ -52,6 +52,13 @@ void sigact_handler(int sig, siginfo_t* siginfo, void* context) {
uintptr_t fault_addr = reinterpret_cast<uintptr_t>(&Fault);
EXPECT_GE(pc, fault_addr);
EXPECT_LT(pc, fault_addr + 64);
+
+ // The following file is used to detect tests that exit prematurely. Since
+ // we need to call exit() here, delete the file by hand.
+ const char* exit_file = getenv("TEST_PREMATURE_EXIT_FILE");
+ if (exit_file != nullptr) {
+ ASSERT_THAT(unlink(exit_file), SyscallSucceeds());
+ }
exit(0);
}
}