mirror of
https://github.com/golang/go
synced 2024-11-23 19:40:08 -07:00
net: don't run IP stack required tests on IP stack disabled kernels
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>
This commit is contained in:
parent
76d67eaccc
commit
f963cb707e
@ -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)
|
t.Skipf("not implemented a way to cancel dial racers in TCP SYN-SENT state on %s", runtime.GOOS)
|
||||||
}
|
}
|
||||||
if !supportsIPv4 || !supportsIPv6 {
|
if !supportsIPv4 || !supportsIPv6 {
|
||||||
t.Skip("ipv4 or ipv6 is not supported")
|
t.Skip("both IPv4 and IPv6 are required")
|
||||||
}
|
}
|
||||||
|
|
||||||
origTestHookLookupIP := testHookLookupIP
|
origTestHookLookupIP := testHookLookupIP
|
||||||
@ -247,7 +247,7 @@ func TestDialerLocalAddr(t *testing.T) {
|
|||||||
|
|
||||||
func TestDialerDualStack(t *testing.T) {
|
func TestDialerDualStack(t *testing.T) {
|
||||||
if !supportsIPv4 || !supportsIPv6 {
|
if !supportsIPv4 || !supportsIPv6 {
|
||||||
t.Skip("ipv4 or ipv6 is not supported")
|
t.Skip("both IPv4 and IPv6 are required")
|
||||||
}
|
}
|
||||||
|
|
||||||
origTestHookLookupIP := testHookLookupIP
|
origTestHookLookupIP := testHookLookupIP
|
||||||
|
@ -216,7 +216,7 @@ var addrListTests = []struct {
|
|||||||
|
|
||||||
func TestAddrList(t *testing.T) {
|
func TestAddrList(t *testing.T) {
|
||||||
if !supportsIPv4 || !supportsIPv6 {
|
if !supportsIPv4 || !supportsIPv6 {
|
||||||
t.Skip("ipv4 or ipv6 is not supported")
|
t.Skip("both IPv4 and IPv6 are required")
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, tt := range addrListTests {
|
for i, tt := range addrListTests {
|
||||||
|
@ -218,9 +218,14 @@ var dualStackTCPListenerTests = []struct {
|
|||||||
// listening address and same port.
|
// listening address and same port.
|
||||||
func TestDualStackTCPListener(t *testing.T) {
|
func TestDualStackTCPListener(t *testing.T) {
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
|
case "dragonfly":
|
||||||
|
t.Skip("not supported on DragonFly, see golang.org/issue/10729")
|
||||||
case "nacl", "plan9":
|
case "nacl", "plan9":
|
||||||
t.Skipf("not supported on %s", runtime.GOOS)
|
t.Skipf("not supported on %s", runtime.GOOS)
|
||||||
}
|
}
|
||||||
|
if !supportsIPv4 || !supportsIPv6 {
|
||||||
|
t.Skip("both IPv4 and IPv6 are required")
|
||||||
|
}
|
||||||
|
|
||||||
for _, tt := range dualStackTCPListenerTests {
|
for _, tt := range dualStackTCPListenerTests {
|
||||||
if !testableListenArgs(tt.network1, JoinHostPort(tt.address1, "0"), "") {
|
if !testableListenArgs(tt.network1, JoinHostPort(tt.address1, "0"), "") {
|
||||||
@ -305,6 +310,9 @@ func TestDualStackUDPListener(t *testing.T) {
|
|||||||
case "nacl", "plan9":
|
case "nacl", "plan9":
|
||||||
t.Skipf("not supported on %s", runtime.GOOS)
|
t.Skipf("not supported on %s", runtime.GOOS)
|
||||||
}
|
}
|
||||||
|
if !supportsIPv4 || !supportsIPv6 {
|
||||||
|
t.Skip("both IPv4 and IPv6 are required")
|
||||||
|
}
|
||||||
|
|
||||||
for _, tt := range dualStackUDPListenerTests {
|
for _, tt := range dualStackUDPListenerTests {
|
||||||
if !testableListenArgs(tt.network1, JoinHostPort(tt.address1, "0"), "") {
|
if !testableListenArgs(tt.network1, JoinHostPort(tt.address1, "0"), "") {
|
||||||
|
@ -103,15 +103,26 @@ func testableListenArgs(network, address, client string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test functionality of IPv6 communication using AF_INET6
|
// Test functionality of IPv4 communication using AF_INET and
|
||||||
// sockets.
|
// IPv6 communication using AF_INET6 sockets.
|
||||||
|
if !supportsIPv4 && ip.To4() != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if !supportsIPv6 && ip.To16() != nil && ip.To4() == nil {
|
if !supportsIPv6 && ip.To16() != nil && ip.To4() == nil {
|
||||||
return false
|
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
|
// Test functionality of IPv4 communication using AF_INET6
|
||||||
// sockets.
|
// sockets.
|
||||||
cip := ParseIP(client)
|
|
||||||
if !supportsIPv4map && (network == "tcp" || network == "udp" || network == "ip") && wildcard {
|
if !supportsIPv4map && (network == "tcp" || network == "udp" || network == "ip") && wildcard {
|
||||||
// At this point, we prefer IPv4 when ip is nil.
|
// At this point, we prefer IPv4 when ip is nil.
|
||||||
// See favoriteAddrFamily for further information.
|
// See favoriteAddrFamily for further information.
|
||||||
|
Loading…
Reference in New Issue
Block a user