]> Cypherpunks repositories - gostls13.git/commitdiff
time: allow sleep tests to run for 200% too long
authorRuss Cox <rsc@golang.org>
Mon, 12 Dec 2011 23:33:47 +0000 (18:33 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 12 Dec 2011 23:33:47 +0000 (18:33 -0500)
Some VMs are slow.  Very slow.
Fixes #2421.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5482049

src/pkg/time/sleep_test.go

index 0e9bea48f1bd58a8a37109685aaf6724a10a2c19..b12a5a16818c651e6ae633fc6c24eccaa7939b48 100644 (file)
@@ -119,8 +119,7 @@ func TestAfterTick(t *testing.T) {
        t1 := Now()
        d := t1.Sub(t0)
        target := Delta * Count
-       slop := target * 2 / 10
-       if d < target-slop || d > target+slop {
+       if d < target*9/10 || d > target*30/10 {
                t.Fatalf("%d ticks of %s took %s, expected %s", Count, Delta, d, target)
        }
 }
@@ -197,9 +196,8 @@ func testAfterQueuing(t *testing.T) error {
                }
                dt := r.t.Sub(t0)
                target := Duration(slot) * Delta
-               slop := Delta / 4
-               if dt < target-slop || dt > target+slop {
-                       return fmt.Errorf("After(%s) arrived at %s, expected [%s,%s]", target, dt, target-slop, target+slop)
+               if dt < target-Delta/2 || dt > target+Delta*10 {
+                       return fmt.Errorf("After(%s) arrived at %s, expected [%s,%s]", target, dt, target-Delta/2, target+Delta*10)
                }
        }
        return nil