]> Cypherpunks repositories - gostls13.git/commitdiff
net: ignore more errors in TestDialCancel
authorIan Lance Taylor <iant@golang.org>
Wed, 17 May 2023 22:22:25 +0000 (15:22 -0700)
committerGopher Robot <gobot@golang.org>
Sat, 20 May 2023 21:42:02 +0000 (21:42 +0000)
TestDialCancel assumes that packets sent to the private IP addresses
198.18.0.254 and 2001:2::254 will be routed to /dev/null.
Not all systems are configured that way. We already ignore one
error case in the test; ignore a couple more than have appeared
on the builders. The test is still valid as long as some builders
discard the packets as expected.

Fixes #52579
Fixes #57364

Change-Id: Ibe9ed73b8b3b498623f1d18203dadf9207a0467e
Reviewed-on: https://go-review.googlesource.com/c/go/+/496037
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/net/dial_test.go

index 2eea66a097a90ead748415626d3b757825c8c528..ca9f0da3d3794bf3b55627175c702da261d5707a 100644 (file)
@@ -736,12 +736,6 @@ func TestDialerKeepAlive(t *testing.T) {
 func TestDialCancel(t *testing.T) {
        mustHaveExternalNetwork(t)
 
-       if strings.HasPrefix(testenv.Builder(), "darwin-arm64") {
-               // The darwin-arm64 machines run in an environment that's not
-               // compatible with this test.
-               t.Skipf("builder %q gives no route to host for 198.18.0.0", testenv.Builder())
-       }
-
        blackholeIPPort := JoinHostPort(slowDst4, "1234")
        if !supportsIPv4() {
                blackholeIPPort = JoinHostPort(slowDst6, "1234")
@@ -786,9 +780,18 @@ func TestDialCancel(t *testing.T) {
                        if ticks < cancelTick {
                                // Using strings.Contains is ugly but
                                // may work on plan9 and windows.
-                               if strings.Contains(err.Error(), "connection refused") {
-                                       t.Skipf("connection to %v failed fast with %v", blackholeIPPort, err)
+                               ignorable := []string{
+                                       "connection refused",
+                                       "unreachable",
+                                       "no route to host",
                                }
+                               e := err.Error()
+                               for _, ignore := range ignorable {
+                                       if strings.Contains(e, ignore) {
+                                               t.Skipf("connection to %v failed fast with %v", blackholeIPPort, err)
+                                       }
+                               }
+
                                t.Fatalf("dial error after %d ticks (%d before cancel sent): %v",
                                        ticks, cancelTick-ticks, err)
                        }