]> Cypherpunks repositories - gostls13.git/commitdiff
net: fix TestDialFailPDLeak to work when GOMAXPROCS is large
authorIan Lance Taylor <iant@golang.org>
Wed, 9 Oct 2013 20:52:29 +0000 (13:52 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 9 Oct 2013 20:52:29 +0000 (13:52 -0700)
Fixes #6553.

R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/14526048

src/pkg/net/dial_test.go

index c7296b7a9cb1b4fc722186860f416f8426c0143c..f1d813f4121f1f1db2c47da599ad3793fb38cf3b 100644 (file)
@@ -436,7 +436,8 @@ func TestDialFailPDLeak(t *testing.T) {
                t.Skipf("skipping test on %q/%q", runtime.GOOS, runtime.GOARCH)
        }
 
-       const loops = 10
+       maxprocs := runtime.GOMAXPROCS(0)
+       loops := 10 + maxprocs
        // 500 is enough to turn over the chunk of pollcache.
        // See allocPollDesc in runtime/netpoll.goc.
        const count = 500
@@ -471,7 +472,7 @@ func TestDialFailPDLeak(t *testing.T) {
                        failcount++
                }
                // there are always some allocations on the first loop
-               if failcount > 3 {
+               if failcount > maxprocs+2 {
                        t.Error("detected possible memory leak in runtime")
                        t.FailNow()
                }