From: Dmitriy Vyukov Date: Wed, 14 Aug 2013 17:20:11 +0000 (+0400) Subject: net: make TestDeadlineRace shorter X-Git-Tag: go1.2rc2~584 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9bbf1e1b725e12e207e6791da9d84f1f647df1d6;p=gostls13.git net: make TestDeadlineRace shorter 1. Do less iterations in short mode 2. Bound number of times SetDeadline is executed R=golang-dev, rsc CC=golang-dev https://golang.org/cl/12937043 --- diff --git a/src/pkg/net/timeout_test.go b/src/pkg/net/timeout_test.go index 76f51b38a5..7ea81fe34b 100644 --- a/src/pkg/net/timeout_test.go +++ b/src/pkg/net/timeout_test.go @@ -710,6 +710,10 @@ func TestDeadlineRace(t *testing.T) { t.Skipf("skipping test on %q", runtime.GOOS) } + N := 1000 + if testing.Short() { + N = 50 + } defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4)) ln := newLocalListener(t) defer ln.Close() @@ -721,7 +725,7 @@ func TestDeadlineRace(t *testing.T) { done := make(chan bool) go func() { t := time.NewTicker(2 * time.Microsecond).C - for { + for i := 0; i < N; i++ { if err := c.SetDeadline(time.Now().Add(2 * time.Microsecond)); err != nil { break } @@ -730,7 +734,7 @@ func TestDeadlineRace(t *testing.T) { done <- true }() var buf [1]byte - for i := 0; i < 1024; i++ { + for i := 0; i < N; i++ { c.Read(buf[:]) // ignore possible timeout errors } c.Close()