From cc6e72a5f011edc06dee3bfcf8a2c06f6bab44de Mon Sep 17 00:00:00 2001 From: Ryan Beltran Date: Tue, 20 Apr 2021 16:10:49 +0000 Subject: 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 Tested-by: Ryan Beltran --- compiler_wrapper/compiler_wrapper_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'compiler_wrapper/compiler_wrapper_test.go') 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") -- cgit v1.2.3