From 4aa521a77d1fdc36d68f9ad2591bb28addb327e5 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 27 Dec 2013 08:49:47 -0800 Subject: [PATCH] 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 --- src/pkg/net/dial_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkg/net/dial_test.go b/src/pkg/net/dial_test.go index f1d813f412..c0a8142780 100644 --- a/src/pkg/net/dial_test.go +++ b/src/pkg/net/dial_test.go @@ -147,7 +147,7 @@ func TestSelfConnect(t *testing.T) { n = 100 } for i := 0; i < n; i++ { - c, err := Dial("tcp", addr) + c, err := DialTimeout("tcp", addr, time.Millisecond) if err == nil { c.Close() t.Errorf("#%d: Dial %q succeeded", i, addr) -- 2.48.1