mirror of
https://github.com/golang/net.git
synced 2026-03-31 18:37:08 +09:00
ipv6: make use of nettest.SupportsRawIPSocket
Change-Id: I3cf716c9ae02d7daa0d5a11249c3b58f6c8be2fe Reviewed-on: https://go-review.googlesource.com/3403 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
@@ -6,11 +6,11 @@ package ipv6_test
|
||||
|
||||
import (
|
||||
"net"
|
||||
"os"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/net/internal/nettest"
|
||||
"golang.org/x/net/ipv6"
|
||||
)
|
||||
|
||||
@@ -67,8 +67,8 @@ func TestSetICMPFilter(t *testing.T) {
|
||||
if !supportsIPv6 {
|
||||
t.Skip("ipv6 is not supported")
|
||||
}
|
||||
if os.Getuid() != 0 {
|
||||
t.Skip("must be root")
|
||||
if m, ok := nettest.SupportsRawIPSocket(); !ok {
|
||||
t.Skip(m)
|
||||
}
|
||||
|
||||
c, err := net.ListenPacket("ip6:ipv6-icmp", "::1")
|
||||
|
||||
@@ -140,8 +140,8 @@ func TestPacketConnReadWriteMulticastICMP(t *testing.T) {
|
||||
if !supportsIPv6 {
|
||||
t.Skip("ipv6 is not supported")
|
||||
}
|
||||
if os.Getuid() != 0 {
|
||||
t.Skip("must be root")
|
||||
if m, ok := nettest.SupportsRawIPSocket(); !ok {
|
||||
t.Skip(m)
|
||||
}
|
||||
ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagMulticast|net.FlagLoopback)
|
||||
if ifi == nil {
|
||||
|
||||
@@ -7,7 +7,6 @@ package ipv6_test
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
@@ -164,8 +163,8 @@ func TestIPSinglePacketConnWithSingleGroupListener(t *testing.T) {
|
||||
if !supportsIPv6 {
|
||||
t.Skip("ipv6 is not supported")
|
||||
}
|
||||
if os.Getuid() != 0 {
|
||||
t.Skip("must be root")
|
||||
if m, ok := nettest.SupportsRawIPSocket(); !ok {
|
||||
t.Skip(m)
|
||||
}
|
||||
|
||||
c, err := net.ListenPacket("ip6:ipv6-icmp", "::") // wildcard address
|
||||
@@ -208,8 +207,8 @@ func TestIPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) {
|
||||
if !supportsIPv6 {
|
||||
t.Skip("ipv6 is not supported")
|
||||
}
|
||||
if os.Getuid() != 0 {
|
||||
t.Skip("must be root")
|
||||
if m, ok := nettest.SupportsRawIPSocket(); !ok {
|
||||
t.Skip(m)
|
||||
}
|
||||
|
||||
gaddr := net.IPAddr{IP: net.ParseIP("ff02::114")} // see RFC 4727
|
||||
|
||||
@@ -6,7 +6,6 @@ package ipv6_test
|
||||
|
||||
import (
|
||||
"net"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
@@ -38,9 +37,10 @@ func TestPacketConnMulticastSocketOptions(t *testing.T) {
|
||||
t.Skipf("not available on %q", runtime.GOOS)
|
||||
}
|
||||
|
||||
m, ok := nettest.SupportsRawIPSocket()
|
||||
for _, tt := range packetConnMulticastSocketOptionTests {
|
||||
if tt.net == "ip6" && os.Getuid() != 0 {
|
||||
t.Log("must be root")
|
||||
if tt.net == "ip6" && !ok {
|
||||
t.Log(m)
|
||||
continue
|
||||
}
|
||||
c, err := net.ListenPacket(tt.net+tt.proto, tt.addr)
|
||||
|
||||
@@ -7,7 +7,6 @@ package ipv6_test
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
@@ -102,8 +101,8 @@ func TestPacketConnChecksum(t *testing.T) {
|
||||
if !supportsIPv6 {
|
||||
t.Skip("ipv6 is not supported")
|
||||
}
|
||||
if os.Getuid() != 0 {
|
||||
t.Skip("must be root")
|
||||
if m, ok := nettest.SupportsRawIPSocket(); !ok {
|
||||
t.Skip(m)
|
||||
}
|
||||
|
||||
c, err := net.ListenPacket(fmt.Sprintf("ip6:%d", iana.ProtocolOSPFIGP), "::") // OSPF for IPv6
|
||||
|
||||
@@ -89,8 +89,8 @@ func TestPacketConnReadWriteUnicastICMP(t *testing.T) {
|
||||
if !supportsIPv6 {
|
||||
t.Skip("ipv6 is not supported")
|
||||
}
|
||||
if os.Getuid() != 0 {
|
||||
t.Skip("must be root")
|
||||
if m, ok := nettest.SupportsRawIPSocket(); !ok {
|
||||
t.Skip(m)
|
||||
}
|
||||
|
||||
c, err := net.ListenPacket("ip6:ipv6-icmp", "::1")
|
||||
|
||||
@@ -6,11 +6,11 @@ package ipv6_test
|
||||
|
||||
import (
|
||||
"net"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/net/internal/iana"
|
||||
"golang.org/x/net/internal/nettest"
|
||||
"golang.org/x/net/ipv6"
|
||||
)
|
||||
|
||||
@@ -59,9 +59,11 @@ func TestPacketConnUnicastSocketOptions(t *testing.T) {
|
||||
t.Skip("ipv6 is not supported")
|
||||
}
|
||||
|
||||
m, ok := nettest.SupportsRawIPSocket()
|
||||
for _, tt := range packetConnUnicastSocketOptionTests {
|
||||
if tt.net == "ip6" && os.Getuid() != 0 {
|
||||
t.Skip("must be root")
|
||||
if tt.net == "ip6" && !ok {
|
||||
t.Log(m)
|
||||
continue
|
||||
}
|
||||
c, err := net.ListenPacket(tt.net+tt.proto, tt.addr)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user