Skip to content

Commit

Permalink
Support TEST_PREMATURE_EXIT_FILE in syscall tests
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 352068182
  • Loading branch information
fvoznika authored and gvisor-bot committed Jan 15, 2021
1 parent f1420cf commit f03144d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
18 changes: 2 additions & 16 deletions test/runner/runner.go
Expand Up @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions test/syscalls/linux/fault.cc
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit f03144d

Please sign in to comment.