mirror of https://github.com/golang/go.git
[dev.regabi] runtime/race: adjust test pattern match for ABI wrapper
Adjust the pattern matching in one of the race output test to allow for the possible introduction of an ABI wrapper. Normally for tests that match traceback output wrappers are not an issue since they are screened out by Go's traceback mechanism, but in this case the race runtime is doing the unwinding, so the wrapper may be visible. Change-Id: I45413b5c4701d4c28cc760fccc8203493dbe2874 Reviewed-on: https://go-review.googlesource.com/c/go/+/278756 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Trust: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
306b2451c8
commit
301af2cb71
|
|
@ -7,6 +7,7 @@
|
||||||
package race_test
|
package race_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
@ -71,9 +72,24 @@ func TestOutput(t *testing.T) {
|
||||||
"GORACE="+test.gorace,
|
"GORACE="+test.gorace,
|
||||||
)
|
)
|
||||||
got, _ := cmd.CombinedOutput()
|
got, _ := cmd.CombinedOutput()
|
||||||
if !regexp.MustCompile(test.re).MatchString(string(got)) {
|
matched := false
|
||||||
t.Fatalf("failed test case %v, expect:\n%v\ngot:\n%s",
|
for _, re := range test.re {
|
||||||
test.name, test.re, got)
|
if regexp.MustCompile(re).MatchString(string(got)) {
|
||||||
|
matched = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !matched {
|
||||||
|
exp := fmt.Sprintf("expect:\n%v\n", test.re[0])
|
||||||
|
if len(test.re) > 1 {
|
||||||
|
exp = fmt.Sprintf("expected one of %d patterns:\n",
|
||||||
|
len(test.re))
|
||||||
|
for k, re := range test.re {
|
||||||
|
exp += fmt.Sprintf("pattern %d:\n%v\n", k, re)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t.Fatalf("failed test case %v, %sgot:\n%s",
|
||||||
|
test.name, exp, got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -84,7 +100,7 @@ var tests = []struct {
|
||||||
goos string
|
goos string
|
||||||
gorace string
|
gorace string
|
||||||
source string
|
source string
|
||||||
re string
|
re []string
|
||||||
}{
|
}{
|
||||||
{"simple", "run", "", "atexit_sleep_ms=0", `
|
{"simple", "run", "", "atexit_sleep_ms=0", `
|
||||||
package main
|
package main
|
||||||
|
|
@ -107,7 +123,7 @@ func racer(x *int, done chan bool) {
|
||||||
store(x, 42)
|
store(x, 42)
|
||||||
done <- true
|
done <- true
|
||||||
}
|
}
|
||||||
`, `==================
|
`, []string{`==================
|
||||||
WARNING: DATA RACE
|
WARNING: DATA RACE
|
||||||
Write at 0x[0-9,a-f]+ by goroutine [0-9]:
|
Write at 0x[0-9,a-f]+ by goroutine [0-9]:
|
||||||
main\.store\(\)
|
main\.store\(\)
|
||||||
|
|
@ -129,7 +145,7 @@ Goroutine [0-9] \(running\) created at:
|
||||||
==================
|
==================
|
||||||
Found 1 data race\(s\)
|
Found 1 data race\(s\)
|
||||||
exit status 66
|
exit status 66
|
||||||
`},
|
`}},
|
||||||
|
|
||||||
{"exitcode", "run", "", "atexit_sleep_ms=0 exitcode=13", `
|
{"exitcode", "run", "", "atexit_sleep_ms=0 exitcode=13", `
|
||||||
package main
|
package main
|
||||||
|
|
@ -143,7 +159,7 @@ func main() {
|
||||||
x = 43
|
x = 43
|
||||||
<-done
|
<-done
|
||||||
}
|
}
|
||||||
`, `exit status 13`},
|
`, []string{`exit status 13`}},
|
||||||
|
|
||||||
{"strip_path_prefix", "run", "", "atexit_sleep_ms=0 strip_path_prefix=/main.", `
|
{"strip_path_prefix", "run", "", "atexit_sleep_ms=0 strip_path_prefix=/main.", `
|
||||||
package main
|
package main
|
||||||
|
|
@ -157,9 +173,9 @@ func main() {
|
||||||
x = 43
|
x = 43
|
||||||
<-done
|
<-done
|
||||||
}
|
}
|
||||||
`, `
|
`, []string{`
|
||||||
go:7 \+0x[0-9,a-f]+
|
go:7 \+0x[0-9,a-f]+
|
||||||
`},
|
`}},
|
||||||
|
|
||||||
{"halt_on_error", "run", "", "atexit_sleep_ms=0 halt_on_error=1", `
|
{"halt_on_error", "run", "", "atexit_sleep_ms=0 halt_on_error=1", `
|
||||||
package main
|
package main
|
||||||
|
|
@ -173,10 +189,10 @@ func main() {
|
||||||
x = 43
|
x = 43
|
||||||
<-done
|
<-done
|
||||||
}
|
}
|
||||||
`, `
|
`, []string{`
|
||||||
==================
|
==================
|
||||||
exit status 66
|
exit status 66
|
||||||
`},
|
`}},
|
||||||
|
|
||||||
{"test_fails_on_race", "test", "", "atexit_sleep_ms=0", `
|
{"test_fails_on_race", "test", "", "atexit_sleep_ms=0", `
|
||||||
package main_test
|
package main_test
|
||||||
|
|
@ -193,12 +209,12 @@ func TestFail(t *testing.T) {
|
||||||
<-done
|
<-done
|
||||||
t.Log(t.Failed())
|
t.Log(t.Failed())
|
||||||
}
|
}
|
||||||
`, `
|
`, []string{`
|
||||||
==================
|
==================
|
||||||
--- FAIL: TestFail \(0...s\)
|
--- FAIL: TestFail \(0...s\)
|
||||||
.*main_test.go:14: true
|
.*main_test.go:14: true
|
||||||
.*testing.go:.*: race detected during execution of test
|
.*testing.go:.*: race detected during execution of test
|
||||||
FAIL`},
|
FAIL`}},
|
||||||
|
|
||||||
{"slicebytetostring_pc", "run", "", "atexit_sleep_ms=0", `
|
{"slicebytetostring_pc", "run", "", "atexit_sleep_ms=0", `
|
||||||
package main
|
package main
|
||||||
|
|
@ -211,11 +227,11 @@ func main() {
|
||||||
data[0] = 1
|
data[0] = 1
|
||||||
<-done
|
<-done
|
||||||
}
|
}
|
||||||
`, `
|
`, []string{`
|
||||||
runtime\.slicebytetostring\(\)
|
runtime\.slicebytetostring\(\)
|
||||||
.*/runtime/string\.go:.*
|
.*/runtime/string\.go:.*
|
||||||
main\.main\.func1\(\)
|
main\.main\.func1\(\)
|
||||||
.*/main.go:7`},
|
.*/main.go:7`}},
|
||||||
|
|
||||||
// Test for https://golang.org/issue/33309
|
// Test for https://golang.org/issue/33309
|
||||||
{"midstack_inlining_traceback", "run", "linux", "atexit_sleep_ms=0", `
|
{"midstack_inlining_traceback", "run", "linux", "atexit_sleep_ms=0", `
|
||||||
|
|
@ -241,7 +257,7 @@ func g(c chan int) {
|
||||||
func h(c chan int) {
|
func h(c chan int) {
|
||||||
c <- x
|
c <- x
|
||||||
}
|
}
|
||||||
`, `==================
|
`, []string{`==================
|
||||||
WARNING: DATA RACE
|
WARNING: DATA RACE
|
||||||
Read at 0x[0-9,a-f]+ by goroutine [0-9]:
|
Read at 0x[0-9,a-f]+ by goroutine [0-9]:
|
||||||
main\.h\(\)
|
main\.h\(\)
|
||||||
|
|
@ -261,7 +277,7 @@ Goroutine [0-9] \(running\) created at:
|
||||||
==================
|
==================
|
||||||
Found 1 data race\(s\)
|
Found 1 data race\(s\)
|
||||||
exit status 66
|
exit status 66
|
||||||
`},
|
`}},
|
||||||
|
|
||||||
// Test for https://golang.org/issue/17190
|
// Test for https://golang.org/issue/17190
|
||||||
{"external_cgo_thread", "run", "linux", "atexit_sleep_ms=0", `
|
{"external_cgo_thread", "run", "linux", "atexit_sleep_ms=0", `
|
||||||
|
|
@ -300,7 +316,25 @@ func main() {
|
||||||
racy++
|
racy++
|
||||||
<- done
|
<- done
|
||||||
}
|
}
|
||||||
`, `==================
|
`, []string{`==================
|
||||||
|
WARNING: DATA RACE
|
||||||
|
Read at 0x[0-9,a-f]+ by main goroutine:
|
||||||
|
main\.main\(\)
|
||||||
|
.*/main\.go:34 \+0x[0-9,a-f]+
|
||||||
|
|
||||||
|
Previous 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]+
|
||||||
|
|
||||||
|
Goroutine [0-9] \(running\) created at:
|
||||||
|
runtime\.newextram\(\)
|
||||||
|
.*/runtime/proc.go:[0-9]+ \+0x[0-9,a-f]+
|
||||||
|
==================`,
|
||||||
|
`==================
|
||||||
WARNING: DATA RACE
|
WARNING: DATA RACE
|
||||||
Read at 0x[0-9,a-f]+ by .*:
|
Read at 0x[0-9,a-f]+ by .*:
|
||||||
main\..*
|
main\..*
|
||||||
|
|
@ -313,7 +347,7 @@ Previous write at 0x[0-9,a-f]+ by .*:
|
||||||
Goroutine [0-9] \(running\) created at:
|
Goroutine [0-9] \(running\) created at:
|
||||||
runtime\.newextram\(\)
|
runtime\.newextram\(\)
|
||||||
.*/runtime/proc.go:[0-9]+ \+0x[0-9,a-f]+
|
.*/runtime/proc.go:[0-9]+ \+0x[0-9,a-f]+
|
||||||
==================`},
|
==================`}},
|
||||||
{"second_test_passes", "test", "", "atexit_sleep_ms=0", `
|
{"second_test_passes", "test", "", "atexit_sleep_ms=0", `
|
||||||
package main_test
|
package main_test
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
@ -331,11 +365,11 @@ func TestFail(t *testing.T) {
|
||||||
|
|
||||||
func TestPass(t *testing.T) {
|
func TestPass(t *testing.T) {
|
||||||
}
|
}
|
||||||
`, `
|
`, []string{`
|
||||||
==================
|
==================
|
||||||
--- FAIL: TestFail \(0...s\)
|
--- FAIL: TestFail \(0...s\)
|
||||||
.*testing.go:.*: race detected during execution of test
|
.*testing.go:.*: race detected during execution of test
|
||||||
FAIL`},
|
FAIL`}},
|
||||||
{"mutex", "run", "", "atexit_sleep_ms=0", `
|
{"mutex", "run", "", "atexit_sleep_ms=0", `
|
||||||
package main
|
package main
|
||||||
import (
|
import (
|
||||||
|
|
@ -366,7 +400,7 @@ func main() {
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
if (data == iterations*(threads+1)) { fmt.Println("pass") }
|
if (data == iterations*(threads+1)) { fmt.Println("pass") }
|
||||||
}`, `pass`},
|
}`, []string{`pass`}},
|
||||||
// Test for https://github.com/golang/go/issues/37355
|
// Test for https://github.com/golang/go/issues/37355
|
||||||
{"chanmm", "run", "", "atexit_sleep_ms=0", `
|
{"chanmm", "run", "", "atexit_sleep_ms=0", `
|
||||||
package main
|
package main
|
||||||
|
|
@ -395,7 +429,7 @@ func main() {
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
_ = data
|
_ = data
|
||||||
}
|
}
|
||||||
`, `==================
|
`, []string{`==================
|
||||||
WARNING: DATA RACE
|
WARNING: DATA RACE
|
||||||
Write at 0x[0-9,a-f]+ by goroutine [0-9]:
|
Write at 0x[0-9,a-f]+ by goroutine [0-9]:
|
||||||
main\.main\.func2\(\)
|
main\.main\.func2\(\)
|
||||||
|
|
@ -408,5 +442,5 @@ Previous write at 0x[0-9,a-f]+ by main goroutine:
|
||||||
Goroutine [0-9] \(running\) created at:
|
Goroutine [0-9] \(running\) created at:
|
||||||
main\.main\(\)
|
main\.main\(\)
|
||||||
.*/main.go:[0-9]+ \+0x[0-9,a-f]+
|
.*/main.go:[0-9]+ \+0x[0-9,a-f]+
|
||||||
==================`},
|
==================`}},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue