diff options
author | Ryan Beltran <ryanbeltran@chromium.org> | 2021-04-20 16:10:49 +0000 |
---|---|---|
committer | Ryan Beltran <ryanbeltran@chromium.org> | 2021-04-21 17:13:10 +0000 |
commit | cc6e72a5f011edc06dee3bfcf8a2c06f6bab44de (patch) | |
tree | 388ce47515d41c0def748e244837060d8559c11b /compiler_wrapper/compiler_wrapper_test.go | |
parent | 1f5fbfa3cc0abb67d84c0726a6506a8a8adcc86a (diff) | |
download | toolchain-utils-cc6e72a5f011edc06dee3bfcf8a2c06f6bab44de.tar.gz |
compiler_wrapper: disable rusage when goma enabled
This disables rusage logging when Goma is enabled as goma makes the
resulting logs meaningless.
BUG=None
TEST=Updated and ran go tests
Change-Id: If55a820676faa6b40d471db48749d384b7e2c671
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2840684
Reviewed-by: George Burgess <gbiv@chromium.org>
Tested-by: Ryan Beltran <ryanbeltran@chromium.org>
Diffstat (limited to 'compiler_wrapper/compiler_wrapper_test.go')
-rw-r--r-- | compiler_wrapper/compiler_wrapper_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/compiler_wrapper/compiler_wrapper_test.go b/compiler_wrapper/compiler_wrapper_test.go index dc2a9dd5..fd59cfe1 100644 --- a/compiler_wrapper/compiler_wrapper_test.go +++ b/compiler_wrapper/compiler_wrapper_test.go @@ -10,6 +10,7 @@ import ( "fmt" "io" "os" + "path" "path/filepath" "strings" "syscall" @@ -96,6 +97,33 @@ func TestLogMissingCCacheExecError(t *testing.T) { }) } +func TestGomaDisablesRusage(t *testing.T) { + withTestContext(t, func(ctx *testContext) { + gomaPath := path.Join(ctx.tempDir, "gomacc") + ctx.writeFile(gomaPath, "") + ctx.env = []string{"GOMACC_PATH=" + gomaPath} + logFileName := filepath.Join(ctx.tempDir, "rusage.log") + ctx.env = []string{ + "TOOLCHAIN_RUSAGE_OUTPUT=" + logFileName, + "GOMACC_PATH=" + gomaPath, + } + cmd := ctx.must(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, mainCc))) + // Ensure Goma was used + if err := verifyPath(cmd, gomaPath); err != nil { + t.Fatal(err) + } + if err := verifyArgOrder(cmd, gccX86_64+".real", mainCc); err != nil { + t.Error(err) + } + // Ensure rusage log was not created + if _, err := os.Stat(logFileName); err == nil { + t.Errorf("Logfile shouldn't have been created at TOOLCHAIN_RUSAGE_OUTPUT path %q but was", logFileName) + } else if !os.IsNotExist(err) { + t.Fatalf("error checking for rusage logfile at %q: %v", logFileName, err) + } + }) +} + func TestLogRusageAndForceDisableWError(t *testing.T) { withTestContext(t, func(ctx *testContext) { logFileName := filepath.Join(ctx.tempDir, "rusage.log") |