From 121c434f7add815c3147b01a097a8998018bcc6b Mon Sep 17 00:00:00 2001 From: Richard Miller Date: Wed, 6 Apr 2016 18:58:22 +0100 Subject: [PATCH] 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 Run-TryBot: Dmitry Vyukov TryBot-Result: Gobot Gobot --- src/runtime/pprof/pprof_test.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go index 23bc72c1e4..8b2f3d5291 100644 --- a/src/runtime/pprof/pprof_test.go +++ b/src/runtime/pprof/pprof_test.go @@ -530,15 +530,20 @@ func blockChanClose() { } func blockSelectRecvAsync() { + const numTries = 3 c := make(chan bool, 1) c2 := make(chan bool, 1) go func() { - time.Sleep(blockDelay) - c <- true + for i := 0; i < numTries; i++ { + time.Sleep(blockDelay) + c <- true + } }() - select { - case <-c: - case <-c2: + for i := 0; i < numTries; i++ { + select { + case <-c: + case <-c2: + } } } -- 2.48.1