From: Brad Fitzpatrick Date: Wed, 12 Apr 2017 21:42:01 +0000 (+0000) Subject: net: delete TestDialTimeoutFDLeak X-Git-Tag: go1.9beta1~717 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7faf30246a67746d0bbd0d762e5cd7309fadfc6f;p=gostls13.git net: delete TestDialTimeoutFDLeak It's flaky and distracting. I'm not sure what it's testing, either. It hasn't saved us before. Somebody can resurrect it if they have time. Updates #15157 Change-Id: I27bbfe51e09b6259bba0f73d60d03a4d38711951 Reviewed-on: https://go-review.googlesource.com/40498 Reviewed-by: Josh Bleecher Snyder --- diff --git a/src/net/dial_test.go b/src/net/dial_test.go index e8547974b9..22140005eb 100644 --- a/src/net/dial_test.go +++ b/src/net/dial_test.go @@ -10,7 +10,6 @@ import ( "internal/poll" "internal/testenv" "io" - "net/internal/socktest" "runtime" "sync" "testing" @@ -73,70 +72,6 @@ func TestDialLocal(t *testing.T) { c.Close() } -func TestDialTimeoutFDLeak(t *testing.T) { - switch runtime.GOOS { - case "plan9": - t.Skipf("%s does not have full support of socktest", runtime.GOOS) - case "openbsd": - testenv.SkipFlaky(t, 15157) - } - - const T = 100 * time.Millisecond - - switch runtime.GOOS { - case "plan9", "windows": - origTestHookDialChannel := testHookDialChannel - testHookDialChannel = func() { time.Sleep(2 * T) } - defer func() { testHookDialChannel = origTestHookDialChannel }() - if runtime.GOOS == "plan9" { - break - } - fallthrough - default: - sw.Set(socktest.FilterConnect, func(so *socktest.Status) (socktest.AfterFilter, error) { - time.Sleep(2 * T) - return nil, poll.ErrTimeout - }) - defer sw.Set(socktest.FilterConnect, nil) - } - - // Avoid tracking open-close jitterbugs between netFD and - // socket that leads to confusion of information inside - // socktest.Switch. - // It may happen when the Dial call bumps against TCP - // simultaneous open. See selfConnect in tcpsock_posix.go. - defer func() { sw.Set(socktest.FilterClose, nil) }() - var mu sync.Mutex - var attempts int - sw.Set(socktest.FilterClose, func(so *socktest.Status) (socktest.AfterFilter, error) { - mu.Lock() - attempts++ - mu.Unlock() - return nil, nil - }) - - const N = 100 - var wg sync.WaitGroup - wg.Add(N) - for i := 0; i < N; i++ { - go func() { - defer wg.Done() - // This dial never starts to send any SYN - // segment because of above socket filter and - // test hook. - c, err := DialTimeout("tcp", "127.0.0.1:0", T) - if err == nil { - t.Errorf("unexpectedly established: tcp:%s->%s", c.LocalAddr(), c.RemoteAddr()) - c.Close() - } - }() - } - wg.Wait() - if attempts < N { - t.Errorf("got %d; want >= %d", attempts, N) - } -} - func TestDialerDualStackFDLeak(t *testing.T) { switch runtime.GOOS { case "plan9":