Skip to content

Commit

Permalink
runtime/testdata/testprog: increase GCFairness2 timeout to 1s
Browse files Browse the repository at this point in the history
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 <[email protected]>
Run-TryBot: Quentin Smith <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
quentinmit authored and bradfitz committed Nov 3, 2016
1 parent e83911d commit 21c114e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/runtime/testdata/testprog/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 21c114e

Please sign in to comment.