From 1302f93c4e1eae0e625b372f9bb6bb48780af30f Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Mon, 13 Dec 2021 17:32:07 -0500 Subject: cmd/dist: log CPU model when testing Knowing whether test failures are correlated with specific CPU models on has proven useful on several issues. Log it for prior to testing so it is always available. internal/sysinfo provides the CPU model, but it is not available in the bootstrap toolchain, so we can't access this unconditionally in cmd/dist. Instead use a build-tagged file, as the final version of cmd/dist will use the final toolchain. The addition of new data to the beginning of cmd/dist output will break x/build/cmd/coordinator's banner parsing, leaving extra lines in the log output, though information will not be lost. https://golang.org/cl/372538 fixes up the coordinator and should be submitted and deployed before this CL is submitted. For #46272. For #49209. For #50146. Change-Id: I515d2ec58e4c0034b76bf624ecaab38f16146074 Reviewed-on: https://go-review.googlesource.com/c/go/+/371474 Trust: Benny Siegert Reviewed-by: Benny Siegert Trust: Michael Pratt Run-TryBot: Michael Pratt TryBot-Result: Gopher Robot Reviewed-by: Austin Clements --- src/cmd/dist/test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/cmd/dist/test.go') diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go index 50a2e5936c..fed83120ed 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -218,6 +218,15 @@ func (t *tester) run() { } } + if err := t.maybeLogMetadata(); err != nil { + t.failed = true + if t.keepGoing { + log.Printf("Failed logging metadata: %v", err) + } else { + fatalf("Failed logging metadata: %v", err) + } + } + for _, dt := range t.tests { if !t.shouldRunTest(dt.name) { t.partial = true @@ -268,6 +277,16 @@ func (t *tester) shouldRunTest(name string) bool { return false } +func (t *tester) maybeLogMetadata() error { + if t.compileOnly { + // We need to run a subprocess to log metadata. Don't do that + // on compile-only runs. + return nil + } + t.out("Test execution environment.") + return logMetadata() +} + // short returns a -short flag value to use with 'go test' // or a test binary for tests intended to run in short mode. // It returns "true", unless the environment variable -- cgit v1.2.3-54-g00ecf