Skip to content

Commit fbe3136

Browse files
ianlancetaylorgopherbot
authored andcommitted
net: remove max timeout from TestDialTimeout
Just rely on the testsuite timeout. If this hangs we will hopefully get some real information. Fixes #57475 Change-Id: I18dc5cae54ad5d2d8cc472056b8a3b4d5455c8b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/476356 Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 2e51f6f commit fbe3136

File tree

1 file changed

+23
-34
lines changed

1 file changed

+23
-34
lines changed

src/net/timeout_test.go

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,17 @@ var dialTimeoutTests = []struct {
2424
delta time.Duration // for deadline
2525

2626
guard time.Duration
27-
max time.Duration
2827
}{
2928
// Tests that dial timeouts, deadlines in the past work.
30-
{-5 * time.Second, 0, -5 * time.Second, 100 * time.Millisecond},
31-
{0, -5 * time.Second, -5 * time.Second, 100 * time.Millisecond},
32-
{-5 * time.Second, 5 * time.Second, -5 * time.Second, 100 * time.Millisecond}, // timeout over deadline
33-
{-1 << 63, 0, time.Second, 100 * time.Millisecond},
34-
{0, -1 << 63, time.Second, 100 * time.Millisecond},
35-
36-
{50 * time.Millisecond, 0, 100 * time.Millisecond, time.Second},
37-
{0, 50 * time.Millisecond, 100 * time.Millisecond, time.Second},
38-
{50 * time.Millisecond, 5 * time.Second, 100 * time.Millisecond, time.Second}, // timeout over deadline
29+
{-5 * time.Second, 0, -5 * time.Second},
30+
{0, -5 * time.Second, -5 * time.Second},
31+
{-5 * time.Second, 5 * time.Second, -5 * time.Second}, // timeout over deadline
32+
{-1 << 63, 0, time.Second},
33+
{0, -1 << 63, time.Second},
34+
35+
{50 * time.Millisecond, 0, 100 * time.Millisecond},
36+
{0, 50 * time.Millisecond, 100 * time.Millisecond},
37+
{50 * time.Millisecond, 5 * time.Second, 100 * time.Millisecond}, // timeout over deadline
3938
}
4039

4140
func TestDialTimeout(t *testing.T) {
@@ -59,35 +58,25 @@ func TestDialTimeout(t *testing.T) {
5958
})
6059
}
6160

62-
ch := make(chan error)
6361
d := Dialer{Timeout: tt.timeout}
6462
if tt.delta != 0 {
6563
d.Deadline = time.Now().Add(tt.delta)
6664
}
67-
max := time.NewTimer(tt.max)
68-
defer max.Stop()
69-
go func() {
70-
// This dial never starts to send any TCP SYN
71-
// segment because of above socket filter and
72-
// test hook.
73-
c, err := d.Dial("tcp", "127.0.0.1:0")
74-
if err == nil {
75-
err = fmt.Errorf("unexpectedly established: tcp:%s->%s", c.LocalAddr(), c.RemoteAddr())
76-
c.Close()
77-
}
78-
ch <- err
79-
}()
8065

81-
select {
82-
case <-max.C:
83-
t.Fatalf("#%d: Dial didn't return in an expected time", i)
84-
case err := <-ch:
85-
if perr := parseDialError(err); perr != nil {
86-
t.Errorf("#%d: %v", i, perr)
87-
}
88-
if nerr, ok := err.(Error); !ok || !nerr.Timeout() {
89-
t.Fatalf("#%d: %v", i, err)
90-
}
66+
// This dial never starts to send any TCP SYN
67+
// segment because of above socket filter and
68+
// test hook.
69+
c, err := d.Dial("tcp", "127.0.0.1:0")
70+
if err == nil {
71+
err = fmt.Errorf("unexpectedly established: tcp:%s->%s", c.LocalAddr(), c.RemoteAddr())
72+
c.Close()
73+
}
74+
75+
if perr := parseDialError(err); perr != nil {
76+
t.Errorf("#%d: %v", i, perr)
77+
}
78+
if nerr, ok := err.(Error); !ok || !nerr.Timeout() {
79+
t.Fatalf("#%d: %v", i, err)
9180
}
9281
}
9382
}

0 commit comments

Comments
 (0)