diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/net/error_plan9_test.go | 8 | ||||
| -rw-r--r-- | src/net/error_unix_test.go | 8 | ||||
| -rw-r--r-- | src/net/error_windows_test.go | 9 | ||||
| -rw-r--r-- | src/net/timeout_test.go | 10 |
4 files changed, 33 insertions, 2 deletions
diff --git a/src/net/error_plan9_test.go b/src/net/error_plan9_test.go index 1270af19e5..aa3912c332 100644 --- a/src/net/error_plan9_test.go +++ b/src/net/error_plan9_test.go @@ -21,3 +21,11 @@ func isPlatformError(err error) bool { func isENOBUFS(err error) bool { return false // ENOBUFS is Unix-specific } + +func isECONNRESET(err error) bool { + return false // ECONNRESET is Unix-specific +} + +func isWSAECONNREFUSED(err error) bool { + return false // WSAECONNREFUSED is Windows-specific +} diff --git a/src/net/error_unix_test.go b/src/net/error_unix_test.go index 291a7234f2..20daf13c18 100644 --- a/src/net/error_unix_test.go +++ b/src/net/error_unix_test.go @@ -37,3 +37,11 @@ func samePlatformError(err, want error) bool { func isENOBUFS(err error) bool { return errors.Is(err, syscall.ENOBUFS) } + +func isECONNRESET(err error) bool { + return errors.Is(err, syscall.ECONNRESET) +} + +func isWSAECONNREFUSED(err error) bool { + return false // WSAECONNREFUSED is Windows-specific +} diff --git a/src/net/error_windows_test.go b/src/net/error_windows_test.go index 25825f96f8..e99ea492bb 100644 --- a/src/net/error_windows_test.go +++ b/src/net/error_windows_test.go @@ -27,3 +27,12 @@ func isENOBUFS(err error) bool { // defined in the syscall package we may as well check for it. return errors.Is(err, syscall.ENOBUFS) } + +func isECONNRESET(err error) bool { + return errors.Is(err, syscall.ECONNRESET) +} + +func isWSAECONNREFUSED(err error) bool { + const WSAECONNREFUSED = syscall.Errno(10061) + return errors.Is(err, WSAECONNREFUSED) +} diff --git a/src/net/timeout_test.go b/src/net/timeout_test.go index 4218025fc0..cee1f49a05 100644 --- a/src/net/timeout_test.go +++ b/src/net/timeout_test.go @@ -13,7 +13,6 @@ import ( "io" "os" "runtime" - "strings" "sync" "testing" "time" @@ -89,7 +88,7 @@ func TestDialTimeout(t *testing.T) { } } - if strings.Contains(err.Error(), "connection reset by peer") && (testenv.Builder() == "" || runtime.GOOS == "freebsd") { + if isECONNRESET(err) && (testenv.Builder() == "" || runtime.GOOS == "freebsd") { // After we set up the connection on Unix, we make a call to // getsockopt to retrieve its status. Empirically, on some platforms // (notably FreeBSD 13), we may see ECONNRESET from that call instead @@ -115,6 +114,13 @@ func TestDialTimeout(t *testing.T) { t.Skipf("skipping due to ECONNRESET with full accept queue") } + if isWSAECONNREFUSED(err) && (testenv.Builder() == "" || runtime.GOARCH == "arm64") { + // A similar situation seems to occur on windows/arm64, but returning + // WSAECONNREFUSED from ConnectEx instead of ECONNRESET from getsockopt. + t.Logf("Dial: %v", err) + t.Skipf("skipping due to WSAECONNREFUSED with full accept queue") + } + if d.Deadline.IsZero() || afterDial.Before(d.Deadline) { delay := afterDial.Sub(beforeDial) if delay < tt.timeout { |
