aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2026-03-27 16:25:58 -0400
committerGopher Robot <gobot@golang.org>2026-03-30 09:16:26 -0700
commit9c88851d456b462ae3aa5fe8b9d66ea953af48f6 (patch)
tree42baf8f9de24d46324f133072aaaf1c0ee0d9199 /src/runtime
parent7dbbeea110b8e03afe63f4d6c73e99c29d5030ff (diff)
downloadgo-9c88851d456b462ae3aa5fe8b9d66ea953af48f6.tar.xz
runtime/race: allow TestOutput output in either order
We have only seen the wrappersym case reported in the opposite order in practice, but since these are intentionally racy, they could theoretically all occur in the opposite order. It would be nice to have a bit more structure to these tests so the test itself could easily flip the order. However, since they are just regular expressions, for now I've simply listed both orders. Fixes #78394. Change-Id: I92e04127f275c2394a12d63d2f2a3ce56a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/761161 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/race/output_test.go115
1 files changed, 110 insertions, 5 deletions
diff --git a/src/runtime/race/output_test.go b/src/runtime/race/output_test.go
index 94ac7f0963..2a1c89638b 100644
--- a/src/runtime/race/output_test.go
+++ b/src/runtime/race/output_test.go
@@ -119,7 +119,9 @@ func racer() {
store(xptr, 42)
donechan <- true
}
-`, []string{`==================
+`, []string{
+ // Allow the race output in either order.
+ `==================
WARNING: DATA RACE
Write at 0x[0-9,a-f]+ by goroutine [0-9]:
main\.store\(\)
@@ -141,6 +143,29 @@ Goroutine [0-9] \(running\) created at:
==================
Found 1 data race\(s\)
exit status 66
+`,
+ `==================
+WARNING: DATA RACE
+Write at 0x[0-9,a-f]+ by goroutine [0-9]:
+ main\.store\(\)
+ .+/main\.go:14 \+0x[0-9,a-f]+
+ main\.main\(\)
+ .+/main\.go:10 \+0x[0-9,a-f]+
+
+Previous write at 0x[0-9,a-f]+ by main goroutine:
+ main\.store\(\)
+ .+/main\.go:14 \+0x[0-9,a-f]+
+ main\.racer\(\)
+ .+/main\.go:23 \+0x[0-9,a-f]+
+
+Goroutine [0-9] \(running\) created at:
+ main\.startRacer\(\)
+ .+/main\.go:19 \+0x[0-9,a-f]+
+ main\.main\(\)
+ .+/main\.go:9 \+0x[0-9,a-f]+
+==================
+Found 1 data race\(s\)
+exit status 66
`}},
{"exitcode", "run", "", "atexit_sleep_ms=0 exitcode=13", `
@@ -253,7 +278,9 @@ func g(c chan int) {
func h(c chan int) {
c <- x
}
-`, []string{`==================
+`, []string{
+ // Allow the race output in either order.
+ `==================
WARNING: DATA RACE
Read at 0x[0-9,a-f]+ by goroutine [0-9]:
main\.h\(\)
@@ -273,6 +300,27 @@ Goroutine [0-9] \(running\) created at:
==================
Found 1 data race\(s\)
exit status 66
+`,
+ `==================
+WARNING: DATA RACE
+Write at 0x[0-9,a-f]+ by main goroutine:
+ main\.main\(\)
+ .+/main\.go:9 \+0x[0-9,a-f]+
+
+Previous read at 0x[0-9,a-f]+ by goroutine [0-9]:
+ main\.h\(\)
+ .+/main\.go:22 \+0x[0-9,a-f]+
+ main\.g\(\)
+ .+/main\.go:18 \+0x[0-9,a-f]+
+ main\.f\(\)
+ .+/main\.go:14 \+0x[0-9,a-f]+
+
+Goroutine [0-9] \(running\) created at:
+ main\.main\(\)
+ .+/main\.go:8 \+0x[0-9,a-f]+
+==================
+Found 1 data race\(s\)
+exit status 66
`}},
// Test for https://golang.org/issue/17190
@@ -312,7 +360,9 @@ func main() {
racy++
<- done
}
-`, []string{`==================
+`, []string{
+ // Optionally allow ABI wrappers, and allow the race output in either order.
+ `==================
WARNING: DATA RACE
Read at 0x[0-9,a-f]+ by main goroutine:
main\.main\(\)
@@ -330,6 +380,24 @@ Goroutine [0-9] \(running\) created at:
runtime\.newextram\(\)
.*/runtime/proc.go:[0-9]+ \+0x[0-9,a-f]+
==================`,
+ `==================
+WARNING: DATA RACE
+Write at 0x[0-9,a-f]+ by goroutine [0-9]:
+ main\.goCallback\(\)
+ .*/main\.go:27 \+0x[0-9,a-f]+
+ _cgoexp_[0-9a-z]+_goCallback\(\)
+ .*_cgo_gotypes\.go:[0-9]+ \+0x[0-9,a-f]+
+ _cgoexp_[0-9a-z]+_goCallback\(\)
+ <autogenerated>:1 \+0x[0-9,a-f]+
+
+Previous read at 0x[0-9,a-f]+ by main goroutine:
+ main\.main\(\)
+ .*/main\.go:34 \+0x[0-9,a-f]+
+
+Goroutine [0-9] \(running\) created at:
+ runtime\.newextram\(\)
+ .*/runtime/proc.go:[0-9]+ \+0x[0-9,a-f]+
+==================`,
`==================
WARNING: DATA RACE
Read at 0x[0-9,a-f]+ by .*:
@@ -425,7 +493,9 @@ func main() {
wg.Wait()
_ = data
}
-`, []string{`==================
+`, []string{
+ // Allow the race output in either order.
+ `==================
WARNING: DATA RACE
Write at 0x[0-9,a-f]+ by goroutine [0-9]:
main\.main\.func2\(\)
@@ -438,6 +508,20 @@ Previous write at 0x[0-9,a-f]+ by main goroutine:
Goroutine [0-9] \(running\) created at:
main\.main\(\)
.*/main.go:[0-9]+ \+0x[0-9,a-f]+
+==================`,
+ `==================
+WARNING: DATA RACE
+Write at 0x[0-9,a-f]+ by main goroutine:
+ main\.main\(\)
+ .*/main\.go:23 \+0x[0-9,a-f]+
+
+Previous write at 0x[0-9,a-f]+ by goroutine [0-9]:
+ main\.main\.func2\(\)
+ .*/main\.go:21 \+0x[0-9,a-f]+
+
+Goroutine [0-9] \(running\) created at:
+ main\.main\(\)
+ .*/main.go:[0-9]+ \+0x[0-9,a-f]+
==================`}},
// Test symbolizing wrappers. Both (*T).f and main.gowrap1 are wrappers.
// go.dev/issue/60245
@@ -458,7 +542,9 @@ func (t T) f() {
x = 42
wg.Done()
}
-`, []string{`==================
+`, []string{
+ // Allow the race output in either order.
+ `==================
WARNING: DATA RACE
Write at 0x[0-9,a-f]+ by goroutine [0-9]:
main\.T\.f\(\)
@@ -476,6 +562,25 @@ Previous write at 0x[0-9,a-f]+ by main goroutine:
main\.main\(\)
.*/main.go:10 \+0x[0-9,a-f]+
+`,
+ `==================
+WARNING: DATA RACE
+Write at 0x[0-9,a-f]+ by main goroutine:
+ main\.T\.f\(\)
+ .*/main.go:15 \+0x[0-9,a-f]+
+ main\.\(\*T\)\.f\(\)
+ <autogenerated>:1 \+0x[0-9,a-f]+
+ main\.main\(\)
+ .*/main.go:10 \+0x[0-9,a-f]+
+
+Previous write at 0x[0-9,a-f]+ by goroutine [0-9]:
+ main\.T\.f\(\)
+ .*/main.go:15 \+0x[0-9,a-f]+
+ main\.\(\*T\)\.f\(\)
+ <autogenerated>:1 \+0x[0-9,a-f]+
+ main\.main\.gowrap1\(\)
+ .*/main.go:9 \+0x[0-9,a-f]+
+
`}},
{"non_inline_array_compare", "run", "", "atexit_sleep_ms=0", `
package main