]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: reject any goroutine leak test failure that failed to execute
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 3 Dec 2025 22:29:19 +0000 (22:29 +0000)
committerGopher Robot <gobot@golang.org>
Fri, 5 Dec 2025 18:38:31 +0000 (10:38 -0800)
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>
src/runtime/crash_test.go
src/runtime/goroutineleakprofile_test.go

index 00e67aeca0c46e3a7d3befda6dc73c2739190ca0..91f9740616f04ab178f42edf94e8e4e1cb144e5b 100644 (file)
@@ -97,6 +97,13 @@ func runTestProg(t *testing.T, binary, name string, env ...string) string {
 func runBuiltTestProg(t *testing.T, exe, name string, env ...string) string {
        t.Helper()
 
+       out, _ := runBuiltTestProgErr(t, exe, name, env...)
+       return out
+}
+
+func runBuiltTestProgErr(t *testing.T, exe, name string, env ...string) (string, error) {
+       t.Helper()
+
        if *flagQuick {
                t.Skip("-quick")
        }
@@ -120,7 +127,7 @@ func runBuiltTestProg(t *testing.T, exe, name string, env ...string) string {
                        t.Fatalf("%v failed to start: %v", cmd, err)
                }
        }
-       return string(out)
+       return string(out), err
 }
 
 var serializeBuild = make(chan bool, 2)
index 35f7dc6879c9ece2b1e1e104290ea75138b9c8b5..a0446b36f0471e045b0c2df863f00001171e3017 100644 (file)
@@ -486,9 +486,6 @@ func TestGoroutineLeakProfile(t *testing.T) {
        testCases := append(microTests, stressTestCases...)
        testCases = append(testCases, patternTestCases...)
 
-       // Test cases must not panic or cause fatal exceptions.
-       failStates := regexp.MustCompile(`segmentation fault|fatal|panic|DATA RACE`)
-
        runTests := func(exepath string, testCases []testCase) {
 
                // Build the test program once.
@@ -515,14 +512,14 @@ func TestGoroutineLeakProfile(t *testing.T) {
                                var output string
                                for i := 0; i < tcase.repetitions; i++ {
                                        // Run program for one repetition and get runOutput trace.
-                                       runOutput := runBuiltTestProg(t, exe, tcase.name, cmdEnv...)
+                                       runOutput, err := runBuiltTestProgErr(t, exe, tcase.name, cmdEnv...)
                                        if len(runOutput) == 0 {
                                                t.Errorf("Test %s produced no output. Is the goroutine leak profile collected?", tcase.name)
                                        }
-
-                                       // Zero tolerance policy for fatal exceptions, panics, or data races.
-                                       if failStates.MatchString(runOutput) {
-                                               t.Errorf("unexpected fatal exception or panic\noutput:\n%s\n\n", runOutput)
+                                       // Test cases must not end in a non-zero exit code, or otherwise experience a failure to
+                                       // actually execute.
+                                       if err != nil {
+                                               t.Errorf("unexpected failure\noutput:\n%s\n\n", runOutput)
                                        }
 
                                        output += runOutput + "\n\n"