Commit fc7b9fc2 authored by Russ Cox's avatar Russ Cox

time: allow sleep tests to run for 200% too long

Some VMs are slow.  Very slow.
Fixes #2421.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5482049
parent b1ae728d
...@@ -119,8 +119,7 @@ func TestAfterTick(t *testing.T) { ...@@ -119,8 +119,7 @@ func TestAfterTick(t *testing.T) {
t1 := Now() t1 := Now()
d := t1.Sub(t0) d := t1.Sub(t0)
target := Delta * Count target := Delta * Count
slop := target * 2 / 10 if d < target*9/10 || d > target*30/10 {
if d < target-slop || d > target+slop {
t.Fatalf("%d ticks of %s took %s, expected %s", Count, Delta, d, target) t.Fatalf("%d ticks of %s took %s, expected %s", Count, Delta, d, target)
} }
} }
...@@ -197,9 +196,8 @@ func testAfterQueuing(t *testing.T) error { ...@@ -197,9 +196,8 @@ func testAfterQueuing(t *testing.T) error {
} }
dt := r.t.Sub(t0) dt := r.t.Sub(t0)
target := Duration(slot) * Delta target := Duration(slot) * Delta
slop := Delta / 4 if dt < target-Delta/2 || dt > target+Delta*10 {
if dt < target-slop || dt > target+slop { return fmt.Errorf("After(%s) arrived at %s, expected [%s,%s]", target, dt, target-Delta/2, target+Delta*10)
return fmt.Errorf("After(%s) arrived at %s, expected [%s,%s]", target, dt, target-slop, target+slop)
} }
} }
return nil return nil
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment