]> Cypherpunks repositories - gostls13.git/commitdiff
net: don't run IP stack required tests on IP stack disabled kernels
authorMikio Hara <mikioh.mikioh@gmail.com>
Wed, 6 May 2015 23:20:42 +0000 (08:20 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Thu, 7 May 2015 01:50:23 +0000 (01:50 +0000)
This change doesn't work perfectly on IPv6-only kernels including CLAT
enabled kernels, but works enough on IPv4-only kernels.

Fixes #10721.
Updates #10729.

Change-Id: I7db0e572e252aa0a9f9f54c8e557955077b72e44
Reviewed-on: https://go-review.googlesource.com/9777
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/dial_test.go
src/net/ipsock_test.go
src/net/listen_test.go
src/net/platform_test.go

index fab52627699437bda7696b17babf91bab87a0249..f5141bcd5eec22dfed3e89c936b1a6d994da6d77 100644 (file)
@@ -155,7 +155,7 @@ func TestDialerDualStackFDLeak(t *testing.T) {
                t.Skipf("not implemented a way to cancel dial racers in TCP SYN-SENT state on %s", runtime.GOOS)
        }
        if !supportsIPv4 || !supportsIPv6 {
-               t.Skip("ipv4 or ipv6 is not supported")
+               t.Skip("both IPv4 and IPv6 are required")
        }
 
        origTestHookLookupIP := testHookLookupIP
@@ -247,7 +247,7 @@ func TestDialerLocalAddr(t *testing.T) {
 
 func TestDialerDualStack(t *testing.T) {
        if !supportsIPv4 || !supportsIPv6 {
-               t.Skip("ipv4 or ipv6 is not supported")
+               t.Skip("both IPv4 and IPv6 are required")
        }
 
        origTestHookLookupIP := testHookLookupIP
index c06f15e846fb5dbbf6d0458de109b994c96bc7f6..b36557a1575b03a4e9d79f8ce89f4623e1f49b95 100644 (file)
@@ -216,7 +216,7 @@ var addrListTests = []struct {
 
 func TestAddrList(t *testing.T) {
        if !supportsIPv4 || !supportsIPv6 {
-               t.Skip("ipv4 or ipv6 is not supported")
+               t.Skip("both IPv4 and IPv6 are required")
        }
 
        for i, tt := range addrListTests {
index 995792bed30165d21f239e2883cfed529dfd4e60..8f43c846d9069d8870a2782045283fba5cd9c74e 100644 (file)
@@ -218,9 +218,14 @@ var dualStackTCPListenerTests = []struct {
 // listening address and same port.
 func TestDualStackTCPListener(t *testing.T) {
        switch runtime.GOOS {
+       case "dragonfly":
+               t.Skip("not supported on DragonFly, see golang.org/issue/10729")
        case "nacl", "plan9":
                t.Skipf("not supported on %s", runtime.GOOS)
        }
+       if !supportsIPv4 || !supportsIPv6 {
+               t.Skip("both IPv4 and IPv6 are required")
+       }
 
        for _, tt := range dualStackTCPListenerTests {
                if !testableListenArgs(tt.network1, JoinHostPort(tt.address1, "0"), "") {
@@ -305,6 +310,9 @@ func TestDualStackUDPListener(t *testing.T) {
        case "nacl", "plan9":
                t.Skipf("not supported on %s", runtime.GOOS)
        }
+       if !supportsIPv4 || !supportsIPv6 {
+               t.Skip("both IPv4 and IPv6 are required")
+       }
 
        for _, tt := range dualStackUDPListenerTests {
                if !testableListenArgs(tt.network1, JoinHostPort(tt.address1, "0"), "") {
index eb680b8e340296c6a7d100f613d7bf6c6922fc31..b700091dc5de8e6ef17bd6b1646d2ac8f1ba0a3a 100644 (file)
@@ -103,15 +103,26 @@ func testableListenArgs(network, address, client string) bool {
                return false
        }
 
-       // Test functionality of IPv6 communication using AF_INET6
-       // sockets.
+       // Test functionality of IPv4 communication using AF_INET and
+       // IPv6 communication using AF_INET6 sockets.
+       if !supportsIPv4 && ip.To4() != nil {
+               return false
+       }
        if !supportsIPv6 && ip.To16() != nil && ip.To4() == nil {
                return false
        }
+       cip := ParseIP(client)
+       if cip != nil {
+               if !supportsIPv4 && cip.To4() != nil {
+                       return false
+               }
+               if !supportsIPv6 && cip.To16() != nil && cip.To4() == nil {
+                       return false
+               }
+       }
 
        // Test functionality of IPv4 communication using AF_INET6
        // sockets.
-       cip := ParseIP(client)
        if !supportsIPv4map && (network == "tcp" || network == "udp" || network == "ip") && wildcard {
                // At this point, we prefer IPv4 when ip is nil.
                // See favoriteAddrFamily for further information.