Commit f439e07b authored by Mikio Hara's avatar Mikio Hara

net: make TestDNSThreadLimit execute at the end of tests

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
parent 8ce584c2
...@@ -107,30 +107,6 @@ var googleaddrsipv4 = []string{ ...@@ -107,30 +107,6 @@ var googleaddrsipv4 = []string{
"[0:0:0:0:0:ffff::%d.%d.%d.%d]:80", "[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) { func TestDialGoogleIPv4(t *testing.T) {
if testing.Short() || !*testExternal { if testing.Short() || !*testExternal {
t.Skip("skipping test to avoid external network") t.Skip("skipping test to avoid external network")
......
// 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.
}
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