Skip to content

Commit 435e61c

Browse files
mknyszekgopherbot
authored andcommitted
runtime: reject any goroutine leak test failure that failed to execute
This is far more general than the regexp, which was necessary only because runTestProg doesn't return the error. This change makes runTestProg a wrapper function around a function that *does* return the error. For #76526. Change-Id: Ib3daa75eb0fe314a28a7a368474943ba470d0d4d Reviewed-on: https://go-review.googlesource.com/c/go/+/726525 Auto-Submit: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
1 parent 54e5540 commit 435e61c

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/runtime/crash_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ func runTestProg(t *testing.T, binary, name string, env ...string) string {
9797
func runBuiltTestProg(t *testing.T, exe, name string, env ...string) string {
9898
t.Helper()
9999

100+
out, _ := runBuiltTestProgErr(t, exe, name, env...)
101+
return out
102+
}
103+
104+
func runBuiltTestProgErr(t *testing.T, exe, name string, env ...string) (string, error) {
105+
t.Helper()
106+
100107
if *flagQuick {
101108
t.Skip("-quick")
102109
}
@@ -120,7 +127,7 @@ func runBuiltTestProg(t *testing.T, exe, name string, env ...string) string {
120127
t.Fatalf("%v failed to start: %v", cmd, err)
121128
}
122129
}
123-
return string(out)
130+
return string(out), err
124131
}
125132

126133
var serializeBuild = make(chan bool, 2)

src/runtime/goroutineleakprofile_test.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,6 @@ func TestGoroutineLeakProfile(t *testing.T) {
486486
testCases := append(microTests, stressTestCases...)
487487
testCases = append(testCases, patternTestCases...)
488488

489-
// Test cases must not panic or cause fatal exceptions.
490-
failStates := regexp.MustCompile(`segmentation fault|fatal|panic|DATA RACE`)
491-
492489
runTests := func(exepath string, testCases []testCase) {
493490

494491
// Build the test program once.
@@ -515,14 +512,14 @@ func TestGoroutineLeakProfile(t *testing.T) {
515512
var output string
516513
for i := 0; i < tcase.repetitions; i++ {
517514
// Run program for one repetition and get runOutput trace.
518-
runOutput := runBuiltTestProg(t, exe, tcase.name, cmdEnv...)
515+
runOutput, err := runBuiltTestProgErr(t, exe, tcase.name, cmdEnv...)
519516
if len(runOutput) == 0 {
520517
t.Errorf("Test %s produced no output. Is the goroutine leak profile collected?", tcase.name)
521518
}
522-
523-
// Zero tolerance policy for fatal exceptions, panics, or data races.
524-
if failStates.MatchString(runOutput) {
525-
t.Errorf("unexpected fatal exception or panic\noutput:\n%s\n\n", runOutput)
519+
// Test cases must not end in a non-zero exit code, or otherwise experience a failure to
520+
// actually execute.
521+
if err != nil {
522+
t.Errorf("unexpected failure\noutput:\n%s\n\n", runOutput)
526523
}
527524

528525
output += runOutput + "\n\n"

0 commit comments

Comments
 (0)