From: Quentin Smith Date: Wed, 2 Nov 2016 20:18:22 +0000 (-0400) Subject: runtime/testdata/testprog: increase GCFairness2 timeout to 1s X-Git-Tag: go1.8beta1~352 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=21c114e930fc1b118c2b8b8716d7b1b3b38027e0;p=gostls13.git runtime/testdata/testprog: increase GCFairness2 timeout to 1s OpenBSD's scheduler causes preemption to take 20+ms, so 30ms is not enough time for 3 goroutines to run. This change continues to sleep for 30ms, but if it finds that the 3 goroutines have not run, it sleeps for an additional 1s before declaring failure. Updates #17712 Change-Id: I3e886e40d05192b7cb71b4f242af195836ef62a8 Reviewed-on: https://go-review.googlesource.com/32634 Reviewed-by: Rick Hudson Run-TryBot: Quentin Smith TryBot-Result: Gobot Gobot --- diff --git a/src/runtime/testdata/testprog/gc.go b/src/runtime/testdata/testprog/gc.go index a0c1f82b56..744b6108e2 100644 --- a/src/runtime/testdata/testprog/gc.go +++ b/src/runtime/testdata/testprog/gc.go @@ -98,11 +98,25 @@ func GCFairness2() { // If the scheduling rules change, this may not be enough time // to let all goroutines run, but for now we cycle through // them rapidly. + // + // OpenBSD's scheduler makes every usleep() take at least + // 20ms, so we need a long time to ensure all goroutines have + // run. If they haven't run after 30ms, give it another 1000ms + // and check again. time.Sleep(30 * time.Millisecond) + var fail bool for i := range count { if atomic.LoadInt64(&count[i]) == 0 { - fmt.Printf("goroutine %d did not run\n", i) - return + fail = true + } + } + if fail { + time.Sleep(1 * time.Second) + for i := range count { + if atomic.LoadInt64(&count[i]) == 0 { + fmt.Printf("goroutine %d did not run\n", i) + return + } } } fmt.Println("OK")