blob: 5d15189e195722bd68035a760ade8c5744a5a6b2 [file] [log] [blame]
[short] skip
[!race] skip
go test testrace
! go test -race testrace
stdout 'FAIL: TestRace'
! stdout 'PASS'
! stderr 'PASS'
! go test -race testrace -run XXX -bench .
stdout 'FAIL: BenchmarkRace'
! stdout 'PASS'
! stderr 'PASS'
-- testrace/race_test.go --
package testrace
import "testing"
func TestRace(t *testing.T) {
for i := 0; i < 10; i++ {
c := make(chan int)
x := 1
go func() {
x = 2
c <- 1
}()
x = 3
<-c
_ = x
}
}
func BenchmarkRace(b *testing.B) {
for i := 0; i < b.N; i++ {
c := make(chan int)
x := 1
go func() {
x = 2
c <- 1
}()
x = 3
<-c
_ = x
}
}