ipv4: make use of nettest.SupportsRawIPSocket Change-Id: I12b41d16b49415081242e06b25a7106a4a0c0442 Reviewed-on: https://go-review.googlesource.com/3402 Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/ipv4/multicastlistener_test.go b/ipv4/multicastlistener_test.go index f9d7791..fd6dd75 100644 --- a/ipv4/multicastlistener_test.go +++ b/ipv4/multicastlistener_test.go
@@ -6,7 +6,6 @@ import ( "net" - "os" "runtime" "testing" @@ -163,8 +162,8 @@ if testing.Short() { t.Skip("to avoid external network") } - if os.Getuid() != 0 { - t.Skip("must be root") + if m, ok := nettest.SupportsRawIPSocket(); !ok { + t.Skip(m) } c, err := net.ListenPacket("ip4:icmp", "0.0.0.0") // wildcard address @@ -208,8 +207,8 @@ if testing.Short() { t.Skip("to avoid external network") } - if os.Getuid() != 0 { - t.Skip("must be root") + if m, ok := nettest.SupportsRawIPSocket(); !ok { + t.Skip(m) } gaddr := net.IPAddr{IP: net.IPv4(224, 0, 0, 254)} // see RFC 4727