}
func TestProhibitionaryDialArg(t *testing.T) {
+ testenv.MustHaveExternalNetwork(t)
+
switch runtime.GOOS {
case "plan9":
t.Skipf("not supported on %s", runtime.GOOS)
}
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
if !supportsIPv4map {
t.Skip("mapping ipv4 address inside ipv6 address not supported")
}
}
func TestDialParallel(t *testing.T) {
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
+ testenv.MustHaveExternalNetwork(t)
+
if !supportsIPv4 || !supportsIPv6 {
t.Skip("both IPv4 and IPv6 are required")
}
}
func TestDialerFallbackDelay(t *testing.T) {
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
+ testenv.MustHaveExternalNetwork(t)
+
if !supportsIPv4 || !supportsIPv6 {
t.Skip("both IPv4 and IPv6 are required")
}
}
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)
+ }
+
if runtime.GOOS == "plan9" || runtime.GOOS == "nacl" {
// plan9 is not implemented and nacl doesn't have
// external network access.
t.Skipf("skipping on %s", runtime.GOOS)
}
- onGoBuildFarm := testenv.Builder() != ""
- if testing.Short() && !onGoBuildFarm {
- t.Skip("skipping in short mode")
- }
- if testenv.Builder() == "linux-arm64-buildlet" {
- t.Skip("skipping on linux-arm64-buildlet; incompatible network config? issue 15191")
- }
blackholeIPPort := JoinHostPort(slowDst4, "1234")
if !supportsIPv4 {
import (
"fmt"
+ "internal/testenv"
"io/ioutil"
"os"
"path"
}
func TestDNSTransportFallback(t *testing.T) {
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
+ testenv.MustHaveExternalNetwork(t)
for _, tt := range dnsTransportFallbackTests {
timeout := time.Duration(tt.timeout) * time.Second
}
func TestSpecialDomainName(t *testing.T) {
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
+ testenv.MustHaveExternalNetwork(t)
server := "8.8.8.8:53"
for _, tt := range specialDomainNameTests {
}
func TestUpdateResolvConf(t *testing.T) {
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
+ testenv.MustHaveExternalNetwork(t)
conf, err := newResolvConfTest()
if err != nil {
}
func TestGoLookupIPWithResolverConfig(t *testing.T) {
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
+ testenv.MustHaveExternalNetwork(t)
conf, err := newResolvConfTest()
if err != nil {
// Test that goLookupIPOrder falls back to the host file when no DNS servers are available.
func TestGoLookupIPOrderFallbackToFile(t *testing.T) {
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
+ testenv.MustHaveExternalNetwork(t)
// Add a config that simulates no dns servers being available.
conf, err := newResolvConfTest()
import (
"fmt"
+ "internal/testenv"
"io"
"strings"
"testing"
)
func TestResolveGoogle(t *testing.T) {
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
+ testenv.MustHaveExternalNetwork(t)
+
if !supportsIPv4 || !supportsIPv6 || !*testIPv4 || !*testIPv6 {
t.Skip("both IPv4 and IPv6 are required")
}
}
func TestDialGoogle(t *testing.T) {
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
+ testenv.MustHaveExternalNetwork(t)
+
if !supportsIPv4 || !supportsIPv6 || !*testIPv4 || !*testIPv6 {
t.Skip("both IPv4 and IPv6 are required")
}
import (
"fmt"
+ "internal/testenv"
"os"
"runtime"
"syscall"
}
func TestWildWildcardListener(t *testing.T) {
+ testenv.MustHaveExternalNetwork(t)
+
switch runtime.GOOS {
case "plan9":
t.Skipf("not supported on %s", runtime.GOOS)
}
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
defer func() {
if p := recover(); p != nil {
// test listener with same address family, same group address and same
// port.
func TestIPv4MulticastListener(t *testing.T) {
+ testenv.MustHaveExternalNetwork(t)
+
switch runtime.GOOS {
case "android", "nacl", "plan9":
t.Skipf("not supported on %s", runtime.GOOS)
case "solaris":
t.Skipf("not supported on solaris, see golang.org/issue/7399")
}
+ if !supportsIPv4 {
+ t.Skip("IPv4 is not supported")
+ }
closer := func(cs []*UDPConn) {
for _, c := range cs {
// routing stuff for finding out an appropriate
// nexthop containing both network and link layer
// adjacencies.
- if ifi == nil && (testing.Short() || !*testExternal) {
+ if ifi == nil || !*testIPv4 {
continue
}
for _, tt := range ipv4MulticastListenerTests {
// test listener with same address family, same group address and same
// port.
func TestIPv6MulticastListener(t *testing.T) {
+ testenv.MustHaveExternalNetwork(t)
+
switch runtime.GOOS {
case "plan9":
t.Skipf("not supported on %s", runtime.GOOS)
t.Skipf("not supported on solaris, see issue 7399")
}
if !supportsIPv6 {
- t.Skip("ipv6 is not supported")
+ t.Skip("IPv6 is not supported")
}
if os.Getuid() != 0 {
t.Skip("must be root")
// routing stuff for finding out an appropriate
// nexthop containing both network and link layer
// adjacencies.
- if ifi == nil && (testing.Short() || !*testExternal || !*testIPv6) {
+ if ifi == nil && !*testIPv6 {
continue
}
for _, tt := range ipv6MulticastListenerTests {
}
func TestLookupGoogleSRV(t *testing.T) {
- if testing.Short() && testenv.Builder() == "" || !*testExternal {
- t.Skip("avoid external network")
+ if testenv.Builder() == "" {
+ testenv.MustHaveExternalNetwork(t)
}
+
if !supportsIPv4 || !*testIPv4 {
t.Skip("IPv4 is required")
}
}
func TestLookupGmailMX(t *testing.T) {
- if testing.Short() && testenv.Builder() == "" || !*testExternal {
- t.Skip("avoid external network")
+ if testenv.Builder() == "" {
+ testenv.MustHaveExternalNetwork(t)
}
+
if !supportsIPv4 || !*testIPv4 {
t.Skip("IPv4 is required")
}
}
func TestLookupGmailNS(t *testing.T) {
- if testing.Short() && testenv.Builder() == "" || !*testExternal {
- t.Skip("avoid external network")
+ if testenv.Builder() == "" {
+ testenv.MustHaveExternalNetwork(t)
}
+
if !supportsIPv4 || !*testIPv4 {
t.Skip("IPv4 is required")
}
}
func TestLookupGmailTXT(t *testing.T) {
- if testing.Short() && testenv.Builder() == "" || !*testExternal {
- t.Skip("avoid external network")
+ if testenv.Builder() == "" {
+ testenv.MustHaveExternalNetwork(t)
}
+
if !supportsIPv4 || !*testIPv4 {
t.Skip("IPv4 is required")
}
}
func TestLookupGooglePublicDNSAddr(t *testing.T) {
- if testing.Short() && testenv.Builder() == "" || !*testExternal {
- t.Skip("avoid external network")
+ if testenv.Builder() == "" {
+ testenv.MustHaveExternalNetwork(t)
}
+
if !supportsIPv4 || !supportsIPv6 || !*testIPv4 || !*testIPv6 {
t.Skip("both IPv4 and IPv6 are required")
}
}
func TestLookupIANACNAME(t *testing.T) {
- if testing.Short() && testenv.Builder() == "" || !*testExternal {
- t.Skip("avoid external network")
+ if testenv.Builder() == "" {
+ testenv.MustHaveExternalNetwork(t)
}
+
if !supportsIPv4 || !*testIPv4 {
t.Skip("IPv4 is required")
}
}
func TestLookupGoogleHost(t *testing.T) {
- if testing.Short() && testenv.Builder() == "" || !*testExternal {
- t.Skip("avoid external network")
+ if testenv.Builder() == "" {
+ testenv.MustHaveExternalNetwork(t)
}
+
if !supportsIPv4 || !*testIPv4 {
t.Skip("IPv4 is required")
}
}
func TestLookupGoogleIP(t *testing.T) {
- if testing.Short() && testenv.Builder() == "" || !*testExternal {
- t.Skip("avoid external network")
+ if testenv.Builder() == "" {
+ testenv.MustHaveExternalNetwork(t)
}
+
if !supportsIPv4 || !*testIPv4 {
t.Skip("IPv4 is required")
}
}
func TestLookupDotsWithRemoteSource(t *testing.T) {
- if testing.Short() && testenv.Builder() == "" || !*testExternal {
- t.Skip("avoid external network")
+ if testenv.Builder() == "" {
+ testenv.MustHaveExternalNetwork(t)
}
+
if !supportsIPv4 || !*testIPv4 {
t.Skip("IPv4 is required")
}
"bytes"
"encoding/json"
"errors"
+ "internal/testenv"
"os/exec"
"reflect"
"regexp"
}
func TestLookupMX(t *testing.T) {
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
+ testenv.MustHaveExternalNetwork(t)
for _, server := range nslookupTestServers {
mx, err := LookupMX(server)
}
func TestLookupCNAME(t *testing.T) {
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
+ testenv.MustHaveExternalNetwork(t)
for _, server := range nslookupTestServers {
cname, err := LookupCNAME(server)
}
func TestLookupNS(t *testing.T) {
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
+ testenv.MustHaveExternalNetwork(t)
for _, server := range nslookupTestServers {
ns, err := LookupNS(server)
}
func TestLookupTXT(t *testing.T) {
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
+ testenv.MustHaveExternalNetwork(t)
for _, server := range nslookupTestServers {
txt, err := LookupTXT(server)
var (
testDNSFlood = flag.Bool("dnsflood", false, "whether to test DNS query flooding")
- testExternal = flag.Bool("external", true, "allow use of external networks during long test")
-
// If external IPv4 connectivity exists, we can try dialing
// non-node/interface local scope IPv4 addresses.
// On Windows, Lookup APIs may not return IPv4-related
package net
import (
+ "internal/testenv"
"os"
"runtime"
"strings"
}
// Test wildcard IP addresses.
- if wildcard && (testing.Short() || !*testExternal) {
+ if wildcard && !testenv.HasExternalNetwork() {
return false
}
package net
import (
+ "internal/testenv"
"io"
"reflect"
"runtime"
}
func TestTCPListenerName(t *testing.T) {
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
+ testenv.MustHaveExternalNetwork(t)
for _, tt := range tcpListenerNameTests {
ln, err := ListenTCP(tt.net, tt.laddr)
}
func TestIPv6LinkLocalUnicastTCP(t *testing.T) {
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
+ testenv.MustHaveExternalNetwork(t)
+
if !supportsIPv6 {
t.Skip("IPv6 is not supported")
}
package net
import (
+ "internal/testenv"
"reflect"
"runtime"
"testing"
}
func TestUDPConnLocalName(t *testing.T) {
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
+ testenv.MustHaveExternalNetwork(t)
for _, tt := range udpConnLocalNameTests {
c, err := ListenUDP(tt.net, tt.laddr)
}
func TestIPv6LinkLocalUnicastUDP(t *testing.T) {
- if testing.Short() || !*testExternal {
- t.Skip("avoid external network")
- }
+ testenv.MustHaveExternalNetwork(t)
+
if !supportsIPv6 {
t.Skip("IPv6 is not supported")
}