diff options
author | Russ Cox <rsc@golang.org> | 2014-09-16 14:02:59 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-09-16 14:02:59 -0400 |
commit | 7e8c9d930ee08dd6068c70868d6c5d37bc3331ef (patch) | |
tree | 0973c0c706bbab81be60742787d50a3175a3db17 /src | |
parent | 341882f9f5e64357b7520b79bc9c43ec8cc59b07 (diff) | |
download | go-7e8c9d930ee08dd6068c70868d6c5d37bc3331ef.tar.gz |
net: make TestSelfConnect less fragile
We believe TestSelfConnect can accidentally connect to
something else listening on or dialing from that port.
Fixes issue 8680.
LGTM=bradfitz
R=bradfitz
CC=golang-codereviews, rlh
https://codereview.appspot.com/136700043
Diffstat (limited to 'src')
-rw-r--r-- | src/net/dial_test.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/net/dial_test.go b/src/net/dial_test.go index c5c3236cc..19e289f2e 100644 --- a/src/net/dial_test.go +++ b/src/net/dial_test.go @@ -119,6 +119,7 @@ func TestSelfConnect(t *testing.T) { // TODO(brainman): do not know why it hangs. t.Skip("skipping known-broken test on windows") } + // Test that Dial does not honor self-connects. // See the comment in DialTCP. @@ -149,8 +150,12 @@ func TestSelfConnect(t *testing.T) { for i := 0; i < n; i++ { c, err := DialTimeout("tcp", addr, time.Millisecond) if err == nil { + if c.LocalAddr().String() == addr { + t.Errorf("#%d: Dial %q self-connect", i, addr) + } else { + t.Logf("#%d: Dial %q succeeded - possibly racing with other listener", i, addr) + } c.Close() - t.Errorf("#%d: Dial %q succeeded", i, addr) } } } |