From: Ian Lance Taylor Date: Wed, 15 Mar 2023 05:15:21 +0000 (-0700) Subject: net: remove max timeout from TestDialTimeout X-Git-Tag: go1.21rc1~1271 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=fbe313664664477616bb170903728be74a5f5963;p=gostls13.git 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 Reviewed-by: Cherry Mui Auto-Submit: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Bryan Mills Reviewed-by: Ian Lance Taylor --- diff --git a/src/net/timeout_test.go b/src/net/timeout_test.go index e4825269fb..a2bc819829 100644 --- a/src/net/timeout_test.go +++ b/src/net/timeout_test.go @@ -24,18 +24,17 @@ var dialTimeoutTests = []struct { delta time.Duration // for deadline guard time.Duration - max time.Duration }{ // Tests that dial timeouts, deadlines in the past work. - {-5 * time.Second, 0, -5 * time.Second, 100 * time.Millisecond}, - {0, -5 * time.Second, -5 * time.Second, 100 * time.Millisecond}, - {-5 * time.Second, 5 * time.Second, -5 * time.Second, 100 * time.Millisecond}, // timeout over deadline - {-1 << 63, 0, time.Second, 100 * time.Millisecond}, - {0, -1 << 63, time.Second, 100 * time.Millisecond}, - - {50 * time.Millisecond, 0, 100 * time.Millisecond, time.Second}, - {0, 50 * time.Millisecond, 100 * time.Millisecond, time.Second}, - {50 * time.Millisecond, 5 * time.Second, 100 * time.Millisecond, time.Second}, // timeout over deadline + {-5 * time.Second, 0, -5 * time.Second}, + {0, -5 * time.Second, -5 * time.Second}, + {-5 * time.Second, 5 * time.Second, -5 * time.Second}, // timeout over deadline + {-1 << 63, 0, time.Second}, + {0, -1 << 63, time.Second}, + + {50 * time.Millisecond, 0, 100 * time.Millisecond}, + {0, 50 * time.Millisecond, 100 * time.Millisecond}, + {50 * time.Millisecond, 5 * time.Second, 100 * time.Millisecond}, // timeout over deadline } func TestDialTimeout(t *testing.T) { @@ -59,35 +58,25 @@ func TestDialTimeout(t *testing.T) { }) } - ch := make(chan error) d := Dialer{Timeout: tt.timeout} if tt.delta != 0 { d.Deadline = time.Now().Add(tt.delta) } - max := time.NewTimer(tt.max) - defer max.Stop() - go func() { - // This dial never starts to send any TCP SYN - // segment because of above socket filter and - // test hook. - c, err := d.Dial("tcp", "127.0.0.1:0") - if err == nil { - err = fmt.Errorf("unexpectedly established: tcp:%s->%s", c.LocalAddr(), c.RemoteAddr()) - c.Close() - } - ch <- err - }() - select { - case <-max.C: - t.Fatalf("#%d: Dial didn't return in an expected time", i) - case err := <-ch: - if perr := parseDialError(err); perr != nil { - t.Errorf("#%d: %v", i, perr) - } - if nerr, ok := err.(Error); !ok || !nerr.Timeout() { - t.Fatalf("#%d: %v", i, err) - } + // This dial never starts to send any TCP SYN + // segment because of above socket filter and + // test hook. + c, err := d.Dial("tcp", "127.0.0.1:0") + if err == nil { + err = fmt.Errorf("unexpectedly established: tcp:%s->%s", c.LocalAddr(), c.RemoteAddr()) + c.Close() + } + + if perr := parseDialError(err); perr != nil { + t.Errorf("#%d: %v", i, perr) + } + if nerr, ok := err.(Error); !ok || !nerr.Timeout() { + t.Fatalf("#%d: %v", i, err) } } }