Commit 6b9623cc authored by Alex Brainman's avatar Alex Brainman

go.net/context: adjust TestAlloc so it passes on windows

Do not assume that a particular code path is selected
in WithTimeout.

Also Windows cannot wait for less then 15 millisecond,
so use that instead of 1 nanosecond in test. Otherwise
test takes too long while it looks like it is quick.

Fixes golang/go#8033.

LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=golang-codereviews
https://golang.org/cl/103470044
parent 5755bc4e
......@@ -310,12 +310,12 @@ func TestAllocs(t *testing.T) {
gccgoLimit: 3,
},
{
desc: "WithTimeout(bg, 1*time.Nanosecond)",
desc: "WithTimeout(bg, 15*time.Millisecond)",
f: func() {
c, _ := WithTimeout(bg, 1*time.Nanosecond)
c, _ := WithTimeout(bg, 15*time.Millisecond)
<-c.Done()
},
limit: 7,
limit: 9,
gccgoLimit: 13,
},
{
......@@ -345,7 +345,7 @@ func TestAllocs(t *testing.T) {
// TOOD(iant): Remove this when gccgo does do escape analysis.
limit = test.gccgoLimit
}
if n := testing.AllocsPerRun(1000, test.f); n > limit {
if n := testing.AllocsPerRun(100, test.f); n > limit {
t.Errorf("%s allocs = %f want %d", test.desc, n, int(limit))
}
}
......
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