diff options
author | Adin Scannell <ascannell@google.com> | 2020-06-11 19:03:46 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-06-11 19:05:18 -0700 |
commit | 5a894e35a090232085fbb20c71d1787c266bd995 (patch) | |
tree | 89e50cc09b7935794e5eaca279f39f8dd7f49c2c /test/runner | |
parent | 77c206e3719962d27cc60781ca59712b040587ab (diff) |
Remove generated logs when test succeeds.
PiperOrigin-RevId: 316022884
Diffstat (limited to 'test/runner')
-rw-r--r-- | test/runner/runner.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/test/runner/runner.go b/test/runner/runner.go index 948e3a8ef..332f1df89 100644 --- a/test/runner/runner.go +++ b/test/runner/runner.go @@ -160,8 +160,9 @@ func runRunsc(tc gtest.TestCase, spec *specs.Spec) error { args = append(args, "-fsgofer-host-uds") } - if outDir, ok := syscall.Getenv("TEST_UNDECLARED_OUTPUTS_DIR"); ok { - tdir := filepath.Join(outDir, strings.Replace(name, "/", "_", -1)) + undeclaredOutputsDir, ok := syscall.Getenv("TEST_UNDECLARED_OUTPUTS_DIR") + if ok { + tdir := filepath.Join(undeclaredOutputsDir, strings.Replace(name, "/", "_", -1)) if err := os.MkdirAll(tdir, 0755); err != nil { return fmt.Errorf("could not create test dir: %v", err) } @@ -201,7 +202,9 @@ func runRunsc(tc gtest.TestCase, spec *specs.Spec) error { cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr sig := make(chan os.Signal, 1) + defer close(sig) signal.Notify(sig, syscall.SIGTERM) + defer signal.Stop(sig) go func() { s, ok := <-sig if !ok { @@ -237,9 +240,11 @@ func runRunsc(tc gtest.TestCase, spec *specs.Spec) error { }() err = cmd.Run() - - signal.Stop(sig) - close(sig) + if err == nil { + // If the test passed, then we erase the log directory. This speeds up + // uploading logs in continuous integration & saves on disk space. + os.RemoveAll(undeclaredOutputsDir) + } return err } |