]> Cypherpunks repositories - gostls13.git/commitdiff
net: make TestDeadlineRace shorter
authorDmitriy Vyukov <dvyukov@google.com>
Wed, 14 Aug 2013 17:20:11 +0000 (21:20 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Wed, 14 Aug 2013 17:20:11 +0000 (21:20 +0400)
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

src/pkg/net/timeout_test.go

index 76f51b38a5c1cacd134637eb30974464d51b75b0..7ea81fe34b040079c1c9e3272517bcbf4aad31df 100644 (file)
@@ -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()