diff --git a/src/net/dial_test.go b/src/net/dial_test.go index b5f1dc9e98ba07652a2171f2531dbcc54e34e428..811e417cd7c1debdc98206078994058e528758f1 100644 --- a/src/net/dial_test.go +++ b/src/net/dial_test.go @@ -749,9 +749,8 @@ func TestDialCancel(t *testing.T) { switch testenv.Builder() { case "linux-arm64-buildlet": t.Skip("skipping on linux-arm64-buildlet; incompatible network config? issue 15191") - case "": - testenv.MustHaveExternalNetwork(t) } + mustHaveExternalNetwork(t) if runtime.GOOS == "nacl" { // nacl doesn't have external network access. @@ -897,9 +896,7 @@ func TestCancelAfterDial(t *testing.T) { // if the machine has halfway configured IPv6 such that it can bind on // "::" not connect back to that same address. func TestDialListenerAddr(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) ln, err := Listen("tcp", ":0") if err != nil { t.Fatal(err) @@ -912,3 +909,13 @@ func TestDialListenerAddr(t *testing.T) { } c.Close() } + +// mustHaveExternalNetwork is like testenv.MustHaveExternalNetwork +// except that it won't skip testing on non-iOS builders. +func mustHaveExternalNetwork(t *testing.T) { + t.Helper() + ios := runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") + if testenv.Builder() == "" || ios { + testenv.MustHaveExternalNetwork(t) + } +} diff --git a/src/net/lookup_test.go b/src/net/lookup_test.go index 521c5720ba441f249052eda0b33788dd9cf7b458..75fb303d388186069aafc25bd5e56157e0f3d4d6 100644 --- a/src/net/lookup_test.go +++ b/src/net/lookup_test.go @@ -64,9 +64,7 @@ var backoffDuration = [...]time.Duration{time.Second, 5 * time.Second, 30 * time func TestLookupGoogleSRV(t *testing.T) { t.Parallel() - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") { t.Skip("no resolv.conf on iOS") @@ -115,9 +113,7 @@ var lookupGmailMXTests = []struct { func TestLookupGmailMX(t *testing.T) { t.Parallel() - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") { t.Skip("no resolv.conf on iOS") @@ -163,9 +159,7 @@ var lookupGmailNSTests = []struct { func TestLookupGmailNS(t *testing.T) { t.Parallel() - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") { t.Skip("no resolv.conf on iOS") @@ -211,9 +205,7 @@ var lookupGmailTXTTests = []struct { func TestLookupGmailTXT(t *testing.T) { t.Parallel() - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") { t.Skip("no resolv.conf on iOS") @@ -261,9 +253,7 @@ var lookupGooglePublicDNSAddrTests = []struct { } func TestLookupGooglePublicDNSAddr(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if !supportsIPv4() || !supportsIPv6() || !*testIPv4 || !*testIPv6 { t.Skip("both IPv4 and IPv6 are required") @@ -322,9 +312,7 @@ var lookupCNAMETests = []struct { } func TestLookupCNAME(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if !supportsIPv4() || !*testIPv4 { t.Skip("IPv4 is required") @@ -362,9 +350,7 @@ var lookupGoogleHostTests = []struct { } func TestLookupGoogleHost(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if !supportsIPv4() || !*testIPv4 { t.Skip("IPv4 is required") @@ -390,9 +376,7 @@ func TestLookupGoogleHost(t *testing.T) { func TestLookupLongTXT(t *testing.T) { testenv.SkipFlaky(t, 22857) - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) defer dnsWaitGroup.Wait() @@ -418,9 +402,7 @@ var lookupGoogleIPTests = []struct { } func TestLookupGoogleIP(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if !supportsIPv4() || !*testIPv4 { t.Skip("IPv4 is required") @@ -566,9 +548,7 @@ func TestLookupDotsWithLocalSource(t *testing.T) { t.Skip("IPv4 is required") } - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) defer dnsWaitGroup.Wait() @@ -609,9 +589,7 @@ func TestLookupDotsWithLocalSource(t *testing.T) { } func TestLookupDotsWithRemoteSource(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if !supportsIPv4() || !*testIPv4 { t.Skip("IPv4 is required") @@ -864,9 +842,7 @@ func TestLookupNonLDH(t *testing.T) { } func TestLookupContextCancel(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if runtime.GOOS == "nacl" { t.Skip("skip on nacl") } @@ -891,9 +867,7 @@ func TestLookupContextCancel(t *testing.T) { // Issue 24330: treat the nil *Resolver like a zero value. Verify nothing // crashes if nil is used. func TestNilResolverLookup(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if runtime.GOOS == "nacl" { t.Skip("skip on nacl") } @@ -915,9 +889,7 @@ func TestNilResolverLookup(t *testing.T) { // TestLookupHostCancel verifies that lookup works even after many // canceled lookups (see golang.org/issue/24178 for details). func TestLookupHostCancel(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) if runtime.GOOS == "nacl" { t.Skip("skip on nacl") } diff --git a/src/net/tcpsock_unix_test.go b/src/net/tcpsock_unix_test.go index 95c02d272118565d0b78a05c5f82e8854cbfd8bb..8d8e4e8eb8b2bad2b0d4b94c83742076677d59b0 100644 --- a/src/net/tcpsock_unix_test.go +++ b/src/net/tcpsock_unix_test.go @@ -8,7 +8,6 @@ package net import ( "context" - "internal/testenv" "math/rand" "runtime" "sync" @@ -84,9 +83,8 @@ func TestTCPSpuriousConnSetupCompletion(t *testing.T) { // Issue 19289. // Test that a canceled Dial does not cause a subsequent Dial to succeed. func TestTCPSpuriousConnSetupCompletionWithCancel(t *testing.T) { - if testenv.Builder() == "" { - testenv.MustHaveExternalNetwork(t) - } + mustHaveExternalNetwork(t) + defer dnsWaitGroup.Wait() t.Parallel() const tries = 10000