Commit 81806109 authored by Mikio Hara's avatar Mikio Hara

go.net/ipv4: skip ancillary data socket option tests on non-supported kernels

It seems that old darwin kernels don't handle IP_RECVIF, IP_RECVDSTADDR correctly.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/158030043
parent 4ea000c3
......@@ -62,7 +62,10 @@ func TestPacketConnReadWriteMulticastUDP(t *testing.T) {
cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface
for i, toggle := range []bool{true, false, true} {
if err := p.SetControlMessage(cf, toggle); err != nil && !protocolNotSupported(err) {
if err := p.SetControlMessage(cf, toggle); err != nil {
if protocolNotSupported(err) {
t.Skipf("not supported on %q", runtime.GOOS)
}
t.Fatalf("ipv4.PacketConn.SetControlMessage failed: %v", err)
}
if err := p.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil {
......@@ -135,7 +138,10 @@ func TestPacketConnReadWriteMulticastICMP(t *testing.T) {
if err != nil {
t.Fatalf("icmp.Message.Marshal failed: %v", err)
}
if err := p.SetControlMessage(cf, toggle); err != nil && !protocolNotSupported(err) {
if err := p.SetControlMessage(cf, toggle); err != nil {
if protocolNotSupported(err) {
t.Skipf("not supported on %q", runtime.GOOS)
}
t.Fatalf("ipv4.PacketConn.SetControlMessage failed: %v", err)
}
if err := p.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil {
......@@ -228,7 +234,10 @@ func TestRawConnReadWriteMulticastICMP(t *testing.T) {
Protocol: 1,
Dst: dst.IP,
}
if err := r.SetControlMessage(cf, toggle); err != nil && !protocolNotSupported(err) {
if err := r.SetControlMessage(cf, toggle); err != nil {
if protocolNotSupported(err) {
t.Skipf("not supported on %q", runtime.GOOS)
}
t.Fatalf("ipv4.RawConn.SetControlMessage failed: %v", err)
}
if err := r.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil {
......
......@@ -113,7 +113,10 @@ func TestPacketConnReadWriteUnicastUDP(t *testing.T) {
cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface
for i, toggle := range []bool{true, false, true} {
if err := p.SetControlMessage(cf, toggle); err != nil && !protocolNotSupported(err) {
if err := p.SetControlMessage(cf, toggle); err != nil {
if protocolNotSupported(err) {
t.Skipf("not supported on %q", runtime.GOOS)
}
t.Fatalf("ipv4.PacketConn.SetControlMessage failed: %v", err)
}
p.SetTTL(i + 1)
......@@ -173,7 +176,10 @@ func TestPacketConnReadWriteUnicastICMP(t *testing.T) {
if err != nil {
t.Fatalf("icmp.Message.Marshal failed: %v", err)
}
if err := p.SetControlMessage(cf, toggle); err != nil && !protocolNotSupported(err) {
if err := p.SetControlMessage(cf, toggle); err != nil {
if protocolNotSupported(err) {
t.Skipf("not supported on %q", runtime.GOOS)
}
t.Fatalf("ipv4.PacketConn.SetControlMessage failed: %v", err)
}
p.SetTTL(i + 1)
......@@ -257,7 +263,10 @@ func TestRawConnReadWriteUnicastICMP(t *testing.T) {
Protocol: 1,
Dst: dst.IP,
}
if err := r.SetControlMessage(cf, toggle); err != nil && !protocolNotSupported(err) {
if err := r.SetControlMessage(cf, toggle); err != nil {
if protocolNotSupported(err) {
t.Skipf("not supported on %q", runtime.GOOS)
}
t.Fatalf("ipv4.RawConn.SetControlMessage failed: %v", err)
}
if err := r.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)); err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment