]> Cypherpunks repositories - gostls13.git/commitdiff
net: fix TestDialTimeout on windows builder
authorRuss Cox <rsc@golang.org>
Wed, 7 Mar 2012 05:41:24 +0000 (00:41 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 7 Mar 2012 05:41:24 +0000 (00:41 -0500)
I don't know what's out there, but something
is answering to 127.0.71.111:80 on our builder,
so use a different port.

Also insert a check that the dial fails, which
would have diagnosed this problem.

Fixes #3016.

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

src/pkg/net/dial_test.go

index 3881953bb521b1316fe51c5426a61f51841279ce..f9c47d02bb61a8af74a4c4b569264af82e0f6bea 100644 (file)
@@ -6,6 +6,7 @@ package net
 
 import (
        "flag"
+       "fmt"
        "regexp"
        "runtime"
        "testing"
@@ -44,13 +45,22 @@ 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 a bogus port (44444) 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.
                go func() {
-                       _, err := DialTimeout("tcp", "127.0.71.111:80", 200*time.Millisecond)
+                       c, err := DialTimeout("tcp", "127.0.71.111:44444", 200*time.Millisecond)
+                       if err == nil {
+                               err = fmt.Errorf("unexpected: connected to %s!", c.RemoteAddr())
+                               c.Close()
+                       }
                        errc <- err
                }()
        default: