diff options
Diffstat (limited to 'libgo/go/net/dial_test.go')
-rw-r--r-- | libgo/go/net/dial_test.go | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/libgo/go/net/dial_test.go b/libgo/go/net/dial_test.go index 5f5aea146a6..7212087fe0c 100644 --- a/libgo/go/net/dial_test.go +++ b/libgo/go/net/dial_test.go @@ -6,6 +6,7 @@ package net import ( "flag" + "fmt" "regexp" "runtime" "testing" @@ -32,7 +33,7 @@ func TestDialTimeout(t *testing.T) { numConns := listenerBacklog + 10 // TODO(bradfitz): It's hard to test this in a portable - // way. This is unforunate, but works for now. + // way. This is unfortunate, but works for now. switch runtime.GOOS { case "linux": // The kernel will start accepting TCP connections before userspace @@ -44,13 +45,25 @@ func TestDialTimeout(t *testing.T) { errc <- err }() } - case "darwin": + case "darwin", "windows": // At least OS X 10.7 seems to accept any number of // connections, ignoring listen's backlog, so resort // to connecting to a hopefully-dead 127/8 address. // Same for windows. + // + // Use an IANA reserved port (49151) instead of 80, because + // on our 386 builder, this Dial succeeds, connecting + // to an IIS web server somewhere. The data center + // or VM or firewall must be stealing the TCP connection. + // + // IANA Service Name and Transport Protocol Port Number Registry + // <http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml> go func() { - _, err := DialTimeout("tcp", "127.0.71.111:80", 200*time.Millisecond) + c, err := DialTimeout("tcp", "127.0.71.111:49151", 200*time.Millisecond) + if err == nil { + err = fmt.Errorf("unexpected: connected to %s!", c.RemoteAddr()) + c.Close() + } errc <- err }() default: |