mirror of
https://github.com/golang/go
synced 2024-11-19 03:44:40 -07:00
runtime/pprof: make TestBlockProfile less timing dependent
The test for profiling of channel blocking is timing dependent, and in particular the blockSelectRecvAsync case can fail on a slow builder (plan9_arm) when many tests are run in parallel. The child goroutine sleeps for a fixed period so the parent can be observed to block in a select call reading from the child; but if the OS process running the parent goroutine is delayed long enough, the child may wake again before the parent has reached the blocking point. By repeating the test three times, the likelihood of a blocking event is increased. Fixes #15096 Change-Id: I2ddb9576a83408d06b51ded682bf8e71e53ce59e Reviewed-on: https://go-review.googlesource.com/21604 Reviewed-by: Dmitry Vyukov <dvyukov@google.com> Run-TryBot: Dmitry Vyukov <dvyukov@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
3b02c5b1b6
commit
121c434f7a
@ -530,17 +530,22 @@ func blockChanClose() {
|
||||
}
|
||||
|
||||
func blockSelectRecvAsync() {
|
||||
const numTries = 3
|
||||
c := make(chan bool, 1)
|
||||
c2 := make(chan bool, 1)
|
||||
go func() {
|
||||
for i := 0; i < numTries; i++ {
|
||||
time.Sleep(blockDelay)
|
||||
c <- true
|
||||
}
|
||||
}()
|
||||
for i := 0; i < numTries; i++ {
|
||||
select {
|
||||
case <-c:
|
||||
case <-c2:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func blockSelectSendSync() {
|
||||
c := make(chan bool)
|
||||
|
Loading…
Reference in New Issue
Block a user