]> Cypherpunks repositories - gostls13.git/commitdiff
net: make TestDNSThreadLimit execute at the end of tests
authorMikio Hara <mikioh.mikioh@gmail.com>
Wed, 18 Dec 2013 04:05:47 +0000 (13:05 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Wed, 18 Dec 2013 04:05:47 +0000 (13:05 +0900)
Because TestDNSThreadLimit consumes tons of file descriptors and
makes other tests flaky when CGO_ENABLE=0 or being with netgo tag.

Fixes #6580.

R=golang-dev, bradfitz, adg, minux.ma
CC=golang-dev
https://golang.org/cl/14639044

src/pkg/net/dialgoogle_test.go
src/pkg/net/z_last_test.go [new file with mode: 0644]

index b4ebad0e0dc8733920ab31d3dcaaeb435b0bb2da..79d150f8aad0a1281c10c206eb83539d8b697379 100644 (file)
@@ -107,30 +107,6 @@ var googleaddrsipv4 = []string{
        "[0:0:0:0:0:ffff::%d.%d.%d.%d]:80",
 }
 
-func TestDNSThreadLimit(t *testing.T) {
-       if testing.Short() || !*testExternal {
-               t.Skip("skipping test to avoid external network")
-       }
-
-       const N = 10000
-       c := make(chan int, N)
-       for i := 0; i < N; i++ {
-               go func(i int) {
-                       LookupIP(fmt.Sprintf("%d.net-test.golang.org", i))
-                       c <- 1
-               }(i)
-       }
-       // Don't bother waiting for the stragglers; stop at 0.9 N.
-       for i := 0; i < N*9/10; i++ {
-               if i%100 == 0 {
-                       //println("TestDNSThreadLimit:", i)
-               }
-               <-c
-       }
-
-       // If we're still here, it worked.
-}
-
 func TestDialGoogleIPv4(t *testing.T) {
        if testing.Short() || !*testExternal {
                t.Skip("skipping test to avoid external network")
diff --git a/src/pkg/net/z_last_test.go b/src/pkg/net/z_last_test.go
new file mode 100644 (file)
index 0000000..bb00f11
--- /dev/null
@@ -0,0 +1,34 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package net
+
+import (
+       "fmt"
+       "testing"
+)
+
+func TestDNSThreadLimit(t *testing.T) {
+       if testing.Short() || !*testExternal {
+               t.Skip("skipping test to avoid external network")
+       }
+
+       const N = 10000
+       c := make(chan int, N)
+       for i := 0; i < N; i++ {
+               go func(i int) {
+                       LookupIP(fmt.Sprintf("%d.net-test.golang.org", i))
+                       c <- 1
+               }(i)
+       }
+       // Don't bother waiting for the stragglers; stop at 0.9 N.
+       for i := 0; i < N*9/10; i++ {
+               if i%100 == 0 {
+                       //println("TestDNSThreadLimit:", i)
+               }
+               <-c
+       }
+
+       // If we're still here, it worked.
+}