Browse Source

go.net/ipv4: use testing.Skip{,f}

R=bradfitz, dave
CC=bradfitz, gobot, golang-dev, rsc
https://golang.org/cl/7194047
Mikio Hara 12 years ago
parent
commit
413497eef8

+ 8 - 16
ipv4/multicast_test.go

@@ -15,8 +15,7 @@ import (
 
 func TestReadWriteMulticastIPPayloadUDP(t *testing.T) {
 	if testing.Short() || !*testExternal {
-		t.Logf("skipping test to avoid external network")
-		return
+		t.Skip("to avoid external network")
 	}
 
 	c, err := net.ListenPacket("udp4", "224.0.0.0:1024") // see RFC 4727
@@ -27,8 +26,7 @@ func TestReadWriteMulticastIPPayloadUDP(t *testing.T) {
 
 	ifi := loopbackInterface()
 	if ifi == nil {
-		t.Logf("skipping test; an appropriate interface not found")
-		return
+		t.Skip("an appropriate interface not found")
 	}
 	dst, err := net.ResolveUDPAddr("udp4", "224.0.0.254:1024") // see RFC 4727
 	if err != nil {
@@ -56,12 +54,10 @@ func TestReadWriteMulticastIPPayloadUDP(t *testing.T) {
 
 func TestReadWriteMulticastIPPayloadICMP(t *testing.T) {
 	if testing.Short() || !*testExternal {
-		t.Logf("skipping test to avoid external network")
-		return
+		t.Skip("to avoid external network")
 	}
 	if os.Getuid() != 0 {
-		t.Logf("skipping test; must be root")
-		return
+		t.Skip("must be root")
 	}
 
 	c, err := net.ListenPacket("ip4:icmp", "0.0.0.0")
@@ -72,8 +68,7 @@ func TestReadWriteMulticastIPPayloadICMP(t *testing.T) {
 
 	ifi := loopbackInterface()
 	if ifi == nil {
-		t.Logf("skipping test; an appropriate interface not found")
-		return
+		t.Skip("an appropriate interface not found")
 	}
 	dst, err := net.ResolveIPAddr("ip4", "224.0.0.254") // see RFC 4727
 	if err != nil {
@@ -115,12 +110,10 @@ func TestReadWriteMulticastIPPayloadICMP(t *testing.T) {
 
 func TestReadWriteMulticastIPDatagram(t *testing.T) {
 	if testing.Short() || !*testExternal {
-		t.Logf("skipping test to avoid external network")
-		return
+		t.Skip("to avoid external network")
 	}
 	if os.Getuid() != 0 {
-		t.Logf("skipping test; must be root")
-		return
+		t.Skip("must be root")
 	}
 
 	c, err := net.ListenPacket("ip4:icmp", "0.0.0.0")
@@ -131,8 +124,7 @@ func TestReadWriteMulticastIPDatagram(t *testing.T) {
 
 	ifi := loopbackInterface()
 	if ifi == nil {
-		t.Logf("skipping test; an appropriate interface not found")
-		return
+		t.Skip("an appropriate interface not found")
 	}
 	dst, err := net.ResolveIPAddr("ip4", "224.0.0.254") // see RFC 4727
 	if err != nil {

+ 7 - 14
ipv4/multicastlistener_test.go

@@ -23,8 +23,7 @@ var udpMultipleGroupListenerTests = []struct {
 
 func TestUDPSingleConnWithMultipleGroupListeners(t *testing.T) {
 	if testing.Short() || !*testExternal {
-		t.Logf("skipping test to avoid external network")
-		return
+		t.Skip("to avoid external network")
 	}
 
 	for _, tt := range udpMultipleGroupListenerTests {
@@ -61,8 +60,7 @@ func TestUDPSingleConnWithMultipleGroupListeners(t *testing.T) {
 
 func TestUDPMultipleConnWithMultipleGroupListeners(t *testing.T) {
 	if testing.Short() || !*testExternal {
-		t.Logf("skipping test to avoid external network")
-		return
+		t.Skip("to avoid external network")
 	}
 
 	for _, tt := range udpMultipleGroupListenerTests {
@@ -112,12 +110,10 @@ func TestUDPMultipleConnWithMultipleGroupListeners(t *testing.T) {
 
 func TestIPSingleConnWithSingleGroupListener(t *testing.T) {
 	if testing.Short() || !*testExternal {
-		t.Logf("skipping test to avoid external network")
-		return
+		t.Skip("to avoid external network")
 	}
 	if os.Getuid() != 0 {
-		t.Logf("skipping test; must be root")
-		return
+		t.Skip("must be root")
 	}
 
 	// listen to a wildcard address
@@ -156,8 +152,7 @@ func TestIPSingleConnWithSingleGroupListener(t *testing.T) {
 
 func TestUDPPerInterfaceSingleConnWithSingleGroupListener(t *testing.T) {
 	if testing.Short() || !*testExternal {
-		t.Logf("skipping test to avoid external network")
-		return
+		t.Skip("to avoid external network")
 	}
 
 	gaddr := &net.IPAddr{IP: net.IPv4(224, 0, 0, 254)} // see RFC 4727
@@ -197,12 +192,10 @@ func TestUDPPerInterfaceSingleConnWithSingleGroupListener(t *testing.T) {
 
 func TestIPPerInterfaceSingleConnWithSingleGroupListener(t *testing.T) {
 	if testing.Short() || !*testExternal {
-		t.Logf("skipping test to avoid external network")
-		return
+		t.Skip("to avoid external network")
 	}
 	if os.Getuid() != 0 {
-		t.Logf("skipping test; must be root")
-		return
+		t.Skip("must be root")
 	}
 
 	gaddr := &net.IPAddr{IP: net.IPv4(224, 0, 0, 254)} // see RFC 4727

+ 3 - 6
ipv4/multicastsockopt_test.go

@@ -39,8 +39,7 @@ var multicastSockoptTests = []multicastSockoptTest{
 
 func TestUDPMulticastSockopt(t *testing.T) {
 	if testing.Short() || !*testExternal {
-		t.Logf("skipping test to avoid external network")
-		return
+		t.Skip("to avoid external network")
 	}
 
 	for _, tt := range multicastSockoptTests {
@@ -57,12 +56,10 @@ func TestUDPMulticastSockopt(t *testing.T) {
 
 func TestIPMulticastSockopt(t *testing.T) {
 	if testing.Short() || !*testExternal {
-		t.Logf("skipping test to avoid external network")
-		return
+		t.Skip("to avoid external network")
 	}
 	if os.Getuid() != 0 {
-		t.Logf("skipping test; must be root")
-		return
+		t.Skip("must be root")
 	}
 
 	for _, tt := range multicastSockoptTests {

+ 2 - 4
ipv4/unicast_test.go

@@ -36,8 +36,7 @@ func TestReadWriteUnicastIPPayloadUDP(t *testing.T) {
 
 func TestReadWriteUnicastIPPayloadICMP(t *testing.T) {
 	if os.Getuid() != 0 {
-		t.Logf("skipping test; must be root")
-		return
+		t.Skip("must be root")
 	}
 
 	c, err := net.ListenPacket("ip4:icmp", "0.0.0.0")
@@ -79,8 +78,7 @@ func TestReadWriteUnicastIPPayloadICMP(t *testing.T) {
 
 func TestReadWriteUnicastIPDatagram(t *testing.T) {
 	if os.Getuid() != 0 {
-		t.Logf("skipping test; must be root")
-		return
+		t.Skip("must be root")
 	}
 
 	c, err := net.ListenPacket("ip4:icmp", "0.0.0.0")

+ 1 - 2
ipv4/unicastsockopt_test.go

@@ -88,8 +88,7 @@ func TestUDPUnicastSockopt(t *testing.T) {
 
 func TestIPUnicastSockopt(t *testing.T) {
 	if os.Getuid() != 0 {
-		t.Logf("skipping test; must be root")
-		return
+		t.Skip("must be root")
 	}
 
 	for _, tt := range unicastSockoptTests {