فهرست منبع

go.net/ipv6: disable tests on non-ipv6 kernels

R=dave, capnm9
CC=golang-dev
https://golang.org/cl/10051046
Mikio Hara 12 سال پیش
والد
کامیت
a46af89e38
7فایلهای تغییر یافته به همراه54 افزوده شده و 0 حذف شده
  1. 3 0
      ipv6/icmp_test.go
  2. 6 0
      ipv6/multicast_test.go
  3. 12 0
      ipv6/multicastlistener_test.go
  4. 3 0
      ipv6/multicastsockopt_test.go
  5. 18 0
      ipv6/sockopt_test.go
  6. 6 0
      ipv6/unicast_test.go
  7. 6 0
      ipv6/unicastsockopt_test.go

+ 3 - 0
ipv6/icmp_test.go

@@ -52,6 +52,9 @@ func TestSetICMPFilter(t *testing.T) {
 	case "plan9", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
+	if !supportsIPv6 {
+		t.Skip("ipv6 is not supported")
+	}
 	if os.Getuid() != 0 {
 		t.Skip("must be root")
 	}

+ 6 - 0
ipv6/multicast_test.go

@@ -19,6 +19,9 @@ func TestPacketConnReadWriteMulticastUDP(t *testing.T) {
 	case "plan9", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
+	if !supportsIPv6 {
+		t.Skip("ipv6 is not supported")
+	}
 	ifi := loopbackInterface()
 	if ifi == nil {
 		t.Skipf("not available on %q", runtime.GOOS)
@@ -78,6 +81,9 @@ func TestPacketConnReadWriteMulticastICMP(t *testing.T) {
 	case "plan9", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
+	if !supportsIPv6 {
+		t.Skip("ipv6 is not supported")
+	}
 	if os.Getuid() != 0 {
 		t.Skip("must be root")
 	}

+ 12 - 0
ipv6/multicastlistener_test.go

@@ -24,6 +24,9 @@ func TestUDPSinglePacketConnWithMultipleGroupListeners(t *testing.T) {
 	case "plan9", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
+	if !supportsIPv6 {
+		t.Skip("ipv6 is not supported")
+	}
 
 	for _, gaddr := range udpMultipleGroupListenerTests {
 		c, err := net.ListenPacket("udp6", "[::]:0") // wildcard address with non-reusable port
@@ -61,6 +64,9 @@ func TestUDPMultipleConnWithMultipleGroupListeners(t *testing.T) {
 	case "plan9", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
+	if !supportsIPv6 {
+		t.Skip("ipv6 is not supported")
+	}
 
 	for _, gaddr := range udpMultipleGroupListenerTests {
 		c1, err := net.ListenPacket("udp6", "[ff02::]:1024") // wildcard address with reusable port
@@ -110,6 +116,9 @@ func TestUDPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) {
 	case "plan9", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
+	if !supportsIPv6 {
+		t.Skip("ipv6 is not supported")
+	}
 
 	gaddr := &net.IPAddr{IP: net.ParseIP("ff02::114")} // see RFC 4727
 	type ml struct {
@@ -150,6 +159,9 @@ func TestIPSinglePacketConnWithSingleGroupListener(t *testing.T) {
 	case "plan9", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
+	if !supportsIPv6 {
+		t.Skip("ipv6 is not supported")
+	}
 	if os.Getuid() != 0 {
 		t.Skip("must be root")
 	}

+ 3 - 0
ipv6/multicastsockopt_test.go

@@ -25,6 +25,9 @@ func TestPacketConnMulticastSocketOptions(t *testing.T) {
 	case "plan9", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
+	if !supportsIPv6 {
+		t.Skip("ipv6 is not supported")
+	}
 	ifi := loopbackInterface()
 	if ifi == nil {
 		t.Skipf("not available on %q", runtime.GOOS)

+ 18 - 0
ipv6/sockopt_test.go

@@ -12,6 +12,15 @@ import (
 	"testing"
 )
 
+var supportsIPv6 bool
+
+func init() {
+	if ln, err := net.Listen("tcp6", "[::1]:0"); err == nil {
+		ln.Close()
+		supportsIPv6 = true
+	}
+}
+
 var condFatalf = func() func(*testing.T, string, ...interface{}) {
 	// A few APIs are not implemented yet on some platforms.
 	switch runtime.GOOS {
@@ -26,6 +35,9 @@ func TestConnInitiatorPathMTU(t *testing.T) {
 	case "plan9", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
+	if !supportsIPv6 {
+		t.Skip("ipv6 is not supported")
+	}
 
 	ln, err := net.Listen("tcp6", "[::1]:0")
 	if err != nil {
@@ -56,6 +68,9 @@ func TestConnResponderPathMTU(t *testing.T) {
 	case "plan9", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
+	if !supportsIPv6 {
+		t.Skip("ipv6 is not supported")
+	}
 
 	ln, err := net.Listen("tcp6", "[::1]:0")
 	if err != nil {
@@ -86,6 +101,9 @@ func TestPacketConnChecksum(t *testing.T) {
 	case "plan9", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
+	if !supportsIPv6 {
+		t.Skip("ipv6 is not supported")
+	}
 	if os.Getuid() != 0 {
 		t.Skip("must be root")
 	}

+ 6 - 0
ipv6/unicast_test.go

@@ -88,6 +88,9 @@ func TestPacketConnReadWriteUnicastUDP(t *testing.T) {
 	case "plan9", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
+	if !supportsIPv6 {
+		t.Skip("ipv6 is not supported")
+	}
 
 	c, err := net.ListenPacket("udp6", "[::1]:0")
 	if err != nil {
@@ -132,6 +135,9 @@ func TestPacketConnReadWriteUnicastICMP(t *testing.T) {
 	case "plan9", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
+	if !supportsIPv6 {
+		t.Skip("ipv6 is not supported")
+	}
 	if os.Getuid() != 0 {
 		t.Skip("must be root")
 	}

+ 6 - 0
ipv6/unicastsockopt_test.go

@@ -17,6 +17,9 @@ func TestConnUnicastSocketOptions(t *testing.T) {
 	case "plan9", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
+	if !supportsIPv6 {
+		t.Skip("ipv6 is not supported")
+	}
 
 	ln, err := net.Listen("tcp6", "[::1]:0")
 	if err != nil {
@@ -50,6 +53,9 @@ func TestPacketConnUnicastSocketOptions(t *testing.T) {
 	case "plan9", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
+	if !supportsIPv6 {
+		t.Skip("ipv6 is not supported")
+	}
 
 	for _, tt := range packetConnUnicastSocketOptionTests {
 		if tt.net == "ip6" && os.Getuid() != 0 {