mirror of
https://github.com/golang/net.git
synced 2026-03-31 02:17:08 +09:00
ipv4, ipv6: drop redundant skip checks based on GOOS
All the dropped platforms either don't support raw sockets or the tests pass sucessfully (e.g. ipv4.TestPacketConnReadWriteMulticastICMP on solaris), so the tests can rely on being skipped due to !nettest.SupportsRawSocket(). Also check for errNotImplemented to cover cases where functionality is not available on windows. Change-Id: Ic9107a7ca16e9d9faed4991e1148b493c646ea7d Reviewed-on: https://go-review.googlesource.com/c/net/+/489155 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
committed by
Gopher Robot
parent
938ff153cf
commit
0bfab66a03
7
ipv4/export_test.go
Normal file
7
ipv4/export_test.go
Normal file
@@ -0,0 +1,7 @@
|
||||
// Copyright 2023 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.
|
||||
|
||||
package ipv4
|
||||
|
||||
var ErrNotImplemented = errNotImplemented
|
||||
@@ -8,8 +8,11 @@
|
||||
package ipv4_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/net/ipv4"
|
||||
)
|
||||
|
||||
func protocolNotSupported(err error) bool {
|
||||
@@ -28,5 +31,5 @@ func protocolNotSupported(err error) bool {
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
return errors.Is(err, ipv4.ErrNotImplemented)
|
||||
}
|
||||
|
||||
@@ -131,10 +131,6 @@ var packetConnReadWriteMulticastICMPTests = []struct {
|
||||
}
|
||||
|
||||
func TestPacketConnReadWriteMulticastICMP(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "fuchsia", "hurd", "illumos", "js", "nacl", "plan9", "solaris", "wasip1", "windows":
|
||||
t.Skipf("not supported on %s", runtime.GOOS)
|
||||
}
|
||||
if !nettest.SupportsRawSocket() {
|
||||
t.Skipf("not supported on %s/%s", runtime.GOOS, runtime.GOARCH)
|
||||
}
|
||||
@@ -261,10 +257,6 @@ var rawConnReadWriteMulticastICMPTests = []struct {
|
||||
}
|
||||
|
||||
func TestRawConnReadWriteMulticastICMP(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "fuchsia", "hurd", "illumos", "js", "nacl", "plan9", "solaris", "wasip1", "windows":
|
||||
t.Skipf("not supported on %s", runtime.GOOS)
|
||||
}
|
||||
if testing.Short() {
|
||||
t.Skip("to avoid external network")
|
||||
}
|
||||
|
||||
@@ -171,10 +171,6 @@ func TestUDPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIPSingleRawConnWithSingleGroupListener(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "fuchsia", "hurd", "js", "nacl", "plan9", "wasip1", "windows", "zos":
|
||||
t.Skipf("not supported on %s", runtime.GOOS)
|
||||
}
|
||||
if testing.Short() {
|
||||
t.Skip("to avoid external network")
|
||||
}
|
||||
@@ -216,10 +212,6 @@ func TestIPSingleRawConnWithSingleGroupListener(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIPPerInterfaceSingleRawConnWithSingleGroupListener(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "fuchsia", "hurd", "js", "nacl", "plan9", "wasip1", "windows", "zos":
|
||||
t.Skipf("not supported on %s", runtime.GOOS)
|
||||
}
|
||||
if testing.Short() {
|
||||
t.Skip("to avoid external network")
|
||||
}
|
||||
|
||||
@@ -65,10 +65,6 @@ var rawConnMulticastSocketOptionTests = []struct {
|
||||
}
|
||||
|
||||
func TestRawConnMulticastSocketOptions(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "fuchsia", "hurd", "js", "nacl", "plan9", "wasip1", "zos":
|
||||
t.Skipf("not supported on %s", runtime.GOOS)
|
||||
}
|
||||
if !nettest.SupportsRawSocket() {
|
||||
t.Skipf("not supported on %s/%s", runtime.GOOS, runtime.GOARCH)
|
||||
}
|
||||
|
||||
@@ -84,10 +84,6 @@ func TestPacketConnReadWriteUnicastUDP(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPacketConnReadWriteUnicastICMP(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "fuchsia", "hurd", "js", "nacl", "plan9", "wasip1", "windows":
|
||||
t.Skipf("not supported on %s", runtime.GOOS)
|
||||
}
|
||||
if !nettest.SupportsRawSocket() {
|
||||
t.Skipf("not supported on %s/%s", runtime.GOOS, runtime.GOARCH)
|
||||
}
|
||||
@@ -179,10 +175,6 @@ func TestPacketConnReadWriteUnicastICMP(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRawConnReadWriteUnicastICMP(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "fuchsia", "hurd", "js", "nacl", "plan9", "wasip1", "windows":
|
||||
t.Skipf("not supported on %s", runtime.GOOS)
|
||||
}
|
||||
if !nettest.SupportsRawSocket() {
|
||||
t.Skipf("not supported on %s/%s", runtime.GOOS, runtime.GOARCH)
|
||||
}
|
||||
|
||||
@@ -85,10 +85,6 @@ func TestPacketConnUnicastSocketOptions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRawConnUnicastSocketOptions(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "fuchsia", "hurd", "js", "nacl", "plan9", "wasip1", "windows", "zos":
|
||||
t.Skipf("not supported on %s", runtime.GOOS)
|
||||
}
|
||||
if !nettest.SupportsRawSocket() {
|
||||
t.Skipf("not supported on %s/%s", runtime.GOOS, runtime.GOARCH)
|
||||
}
|
||||
|
||||
7
ipv6/export_test.go
Normal file
7
ipv6/export_test.go
Normal file
@@ -0,0 +1,7 @@
|
||||
// Copyright 2023 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.
|
||||
|
||||
package ipv6
|
||||
|
||||
var ErrNotImplemented = errNotImplemented
|
||||
@@ -8,8 +8,11 @@
|
||||
package ipv6_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/net/ipv6"
|
||||
)
|
||||
|
||||
func protocolNotSupported(err error) bool {
|
||||
@@ -28,5 +31,5 @@ func protocolNotSupported(err error) bool {
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
return errors.Is(err, ipv6.ErrNotImplemented)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
package ipv6_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"reflect"
|
||||
"runtime"
|
||||
@@ -60,10 +61,6 @@ func TestICMPFilter(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetICMPFilter(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "fuchsia", "hurd", "js", "nacl", "plan9", "wasip1", "windows":
|
||||
t.Skipf("not supported on %s", runtime.GOOS)
|
||||
}
|
||||
if !nettest.SupportsIPv6() {
|
||||
t.Skip("ipv6 is not supported")
|
||||
}
|
||||
@@ -83,9 +80,12 @@ func TestSetICMPFilter(t *testing.T) {
|
||||
f.SetAll(true)
|
||||
f.Accept(ipv6.ICMPTypeEchoRequest)
|
||||
f.Accept(ipv6.ICMPTypeEchoReply)
|
||||
if err := p.SetICMPFilter(&f); err != nil {
|
||||
if err := p.SetICMPFilter(&f); errors.Is(err, ipv6.ErrNotImplemented) {
|
||||
t.Skipf("setting ICMP filter not supported: %v", err)
|
||||
} else if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
kf, err := p.ICMPFilter()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -171,10 +171,6 @@ func TestUDPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIPSinglePacketConnWithSingleGroupListener(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "fuchsia", "hurd", "js", "nacl", "plan9", "wasip1", "windows":
|
||||
t.Skipf("not supported on %s", runtime.GOOS)
|
||||
}
|
||||
if !nettest.SupportsIPv6() {
|
||||
t.Skip("ipv6 is not supported")
|
||||
}
|
||||
@@ -216,8 +212,6 @@ func TestIPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "darwin", "ios", "dragonfly", "openbsd": // platforms that return fe80::1%lo0: bind: can't assign requested address
|
||||
t.Skipf("not supported on %s", runtime.GOOS)
|
||||
case "fuchsia", "hurd", "js", "nacl", "plan9", "wasip1", "windows":
|
||||
t.Skipf("not supported on %s", runtime.GOOS)
|
||||
}
|
||||
if !nettest.SupportsIPv6() {
|
||||
t.Skip("ipv6 is not supported")
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
package ipv6_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"runtime"
|
||||
@@ -83,10 +84,6 @@ func TestConnResponderPathMTU(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPacketConnChecksum(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "fuchsia", "hurd", "js", "nacl", "plan9", "wasip1", "windows":
|
||||
t.Skipf("not supported on %s", runtime.GOOS)
|
||||
}
|
||||
if !nettest.SupportsIPv6() {
|
||||
t.Skip("ipv6 is not supported")
|
||||
}
|
||||
@@ -104,7 +101,9 @@ func TestPacketConnChecksum(t *testing.T) {
|
||||
offset := 12 // see RFC 5340
|
||||
|
||||
for _, toggle := range []bool{false, true} {
|
||||
if err := p.SetChecksum(toggle, offset); err != nil {
|
||||
if err := p.SetChecksum(toggle, offset); errors.Is(err, ipv6.ErrNotImplemented) {
|
||||
t.Skipf("setting checksum not supported: %v", err)
|
||||
} else if err != nil {
|
||||
if toggle {
|
||||
t.Fatalf("ipv6.PacketConn.SetChecksum(%v, %v) failed: %v", toggle, offset, err)
|
||||
} else {
|
||||
|
||||
@@ -6,6 +6,7 @@ package ipv6_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"net"
|
||||
"os"
|
||||
"runtime"
|
||||
@@ -90,10 +91,6 @@ func TestPacketConnReadWriteUnicastUDP(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPacketConnReadWriteUnicastICMP(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "fuchsia", "hurd", "js", "nacl", "plan9", "wasip1", "windows", "zos":
|
||||
t.Skipf("not supported on %s", runtime.GOOS)
|
||||
}
|
||||
if !nettest.SupportsIPv6() {
|
||||
t.Skip("ipv6 is not supported")
|
||||
}
|
||||
@@ -128,7 +125,9 @@ func TestPacketConnReadWriteUnicastICMP(t *testing.T) {
|
||||
var f ipv6.ICMPFilter
|
||||
f.SetAll(true)
|
||||
f.Accept(ipv6.ICMPTypeEchoReply)
|
||||
if err := p.SetICMPFilter(&f); err != nil {
|
||||
if err := p.SetICMPFilter(&f); errors.Is(err, ipv6.ErrNotImplemented) {
|
||||
t.Skipf("setting ICMP filter not supported: %v", err)
|
||||
} else if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user