From d694046152c1772048d0e443fa32c9cff59f2fc2 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 17 May 2023 15:22:25 -0700 Subject: [PATCH] net: ignore more errors in TestDialCancel 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 Run-TryBot: Ian Lance Taylor Auto-Submit: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: Dmitri Shuralyov Reviewed-by: Bryan Mills Reviewed-by: Ian Lance Taylor TryBot-Result: Gopher Robot --- src/net/dial_test.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/net/dial_test.go b/src/net/dial_test.go index 2eea66a097..ca9f0da3d3 100644 --- a/src/net/dial_test.go +++ b/src/net/dial_test.go @@ -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) } -- 2.50.0