Explorar el Código

x/net/ipv4: make use of nettest.ProtocolNotSupported

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/164640043
Mikio Hara hace 11 años
padre
commit
405a8afa2d
Se han modificado 4 ficheros con 6 adiciones y 48 borrados
  1. 0 31
      ipv4/error_posix_test.go
  2. 0 11
      ipv4/error_stub_test.go
  3. 3 3
      ipv4/multicast_test.go
  4. 3 3
      ipv4/unicast_test.go

+ 0 - 31
ipv4/error_posix_test.go

@@ -1,31 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
-
-package ipv4_test
-
-import (
-	"os"
-	"syscall"
-)
-
-func protocolNotSupported(err error) bool {
-	switch err := err.(type) {
-	case syscall.Errno:
-		switch err {
-		case syscall.EPROTONOSUPPORT, syscall.ENOPROTOOPT:
-			return true
-		}
-	case *os.SyscallError:
-		switch err := err.Err.(type) {
-		case syscall.Errno:
-			switch err {
-			case syscall.EPROTONOSUPPORT, syscall.ENOPROTOOPT:
-				return true
-			}
-		}
-	}
-	return false
-}

+ 0 - 11
ipv4/error_stub_test.go

@@ -1,11 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build nacl plan9
-
-package ipv4_test
-
-func protocolNotSupported(err error) bool {
-	return false
-}

+ 3 - 3
ipv4/multicast_test.go

@@ -63,7 +63,7 @@ func TestPacketConnReadWriteMulticastUDP(t *testing.T) {
 
 	for i, toggle := range []bool{true, false, true} {
 		if err := p.SetControlMessage(cf, toggle); err != nil {
-			if protocolNotSupported(err) {
+			if nettest.ProtocolNotSupported(err) {
 				t.Skipf("not supported on %q", runtime.GOOS)
 			}
 			t.Fatalf("ipv4.PacketConn.SetControlMessage failed: %v", err)
@@ -139,7 +139,7 @@ func TestPacketConnReadWriteMulticastICMP(t *testing.T) {
 			t.Fatalf("icmp.Message.Marshal failed: %v", err)
 		}
 		if err := p.SetControlMessage(cf, toggle); err != nil {
-			if protocolNotSupported(err) {
+			if nettest.ProtocolNotSupported(err) {
 				t.Skipf("not supported on %q", runtime.GOOS)
 			}
 			t.Fatalf("ipv4.PacketConn.SetControlMessage failed: %v", err)
@@ -235,7 +235,7 @@ func TestRawConnReadWriteMulticastICMP(t *testing.T) {
 			Dst:      dst.IP,
 		}
 		if err := r.SetControlMessage(cf, toggle); err != nil {
-			if protocolNotSupported(err) {
+			if nettest.ProtocolNotSupported(err) {
 				t.Skipf("not supported on %q", runtime.GOOS)
 			}
 			t.Fatalf("ipv4.RawConn.SetControlMessage failed: %v", err)

+ 3 - 3
ipv4/unicast_test.go

@@ -114,7 +114,7 @@ func TestPacketConnReadWriteUnicastUDP(t *testing.T) {
 
 	for i, toggle := range []bool{true, false, true} {
 		if err := p.SetControlMessage(cf, toggle); err != nil {
-			if protocolNotSupported(err) {
+			if nettest.ProtocolNotSupported(err) {
 				t.Skipf("not supported on %q", runtime.GOOS)
 			}
 			t.Fatalf("ipv4.PacketConn.SetControlMessage failed: %v", err)
@@ -177,7 +177,7 @@ func TestPacketConnReadWriteUnicastICMP(t *testing.T) {
 			t.Fatalf("icmp.Message.Marshal failed: %v", err)
 		}
 		if err := p.SetControlMessage(cf, toggle); err != nil {
-			if protocolNotSupported(err) {
+			if nettest.ProtocolNotSupported(err) {
 				t.Skipf("not supported on %q", runtime.GOOS)
 			}
 			t.Fatalf("ipv4.PacketConn.SetControlMessage failed: %v", err)
@@ -264,7 +264,7 @@ func TestRawConnReadWriteUnicastICMP(t *testing.T) {
 			Dst:      dst.IP,
 		}
 		if err := r.SetControlMessage(cf, toggle); err != nil {
-			if protocolNotSupported(err) {
+			if nettest.ProtocolNotSupported(err) {
 				t.Skipf("not supported on %q", runtime.GOOS)
 			}
 			t.Fatalf("ipv4.RawConn.SetControlMessage failed: %v", err)