]> Cypherpunks repositories - gostls13.git/commitdiff
net: remove max timeout from TestDialTimeout
authorIan Lance Taylor <iant@golang.org>
Wed, 15 Mar 2023 05:15:21 +0000 (22:15 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 15 Mar 2023 16:19:26 +0000 (16:19 +0000)
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 <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/net/timeout_test.go

index e4825269fb590e51ce57f829cc4f606d1b58a4e2..a2bc81982936b79d6e1512fcadbc6e66d7293e18 100644 (file)
@@ -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)
                }
        }
 }