Commit 4aa521a7 authored by Ian Lance Taylor's avatar Ian Lance Taylor

net: use DialTimeout in TestSelfConnect

This avoids problems with systems that take a long time to
find out nothing is listening, while still testing for the
self-connect misfeature since a self-connect should be fast.
With this we may be able to remove the test for non-Linux
systems.

Tested (on GNU/Linux) by editing selfConnect in
tcpsock_posix.go to always return false and verifying that
TestSelfConnect then fails with and without this change.

Idea from Uros Bizjak.

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/39200044
parent d1a91436
...@@ -147,7 +147,7 @@ func TestSelfConnect(t *testing.T) { ...@@ -147,7 +147,7 @@ func TestSelfConnect(t *testing.T) {
n = 100 n = 100
} }
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
c, err := Dial("tcp", addr) c, err := DialTimeout("tcp", addr, time.Millisecond)
if err == nil { if err == nil {
c.Close() c.Close()
t.Errorf("#%d: Dial %q succeeded", i, addr) t.Errorf("#%d: Dial %q succeeded", i, addr)
......
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