]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/testdata/testprog: increase GCFairness2 timeout to 1s
authorQuentin Smith <quentin@golang.org>
Wed, 2 Nov 2016 20:18:22 +0000 (16:18 -0400)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 3 Nov 2016 15:48:57 +0000 (15:48 +0000)
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>

src/runtime/testdata/testprog/gc.go

index a0c1f82b56bd6242f47ee5a501bbe10b482f8477..744b6108e2bc3cf0bd9fc97b21a1c448ee9365e9 100644 (file)
@@ -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")