mirror of
https://github.com/golang/go
synced 2024-11-20 07:54:39 -07:00
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 <rlh@golang.org> Run-TryBot: Quentin Smith <quentin@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
e83911d6fc
commit
21c114e930
18
src/runtime/testdata/testprog/gc.go
vendored
18
src/runtime/testdata/testprog/gc.go
vendored
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user