syncthing/vendor/golang.org/x/net/ipv6/sockopt_test.go
Jakob Borg 65aaa607ab Use Go 1.5 vendoring instead of Godeps
Change made by:

- running "gvt fetch" on each of the packages mentioned in
  Godeps/Godeps.json
- `rm -rf Godeps`
- tweaking the build scripts to not mention Godeps
- tweaking the build scripts to test `./lib/...`, `./cmd/...` explicitly
  (to avoid testing vendor)
- tweaking the build scripts to not juggle GOPATH for Godeps and instead
  set GO15VENDOREXPERIMENT.

This also results in some updated packages at the same time I bet.

Building with Go 1.3 and 1.4 still *works* but won't use our vendored
dependencies - the user needs to have the actual packages in their
GOPATH then, which they'll get with a normal "go get". Building with Go
1.6+ will get our vendored dependencies by default even when not using
our build script, which is nice.

By doing this we gain some freedom in that we can pick and choose
manually what to include in vendor, as it's not based on just dependency
analysis of our own code. This is also a risk as we might pick up
dependencies we are unaware of, as the build may work locally with those
packages present in GOPATH. On the other hand the build server will
detect this as it has no packages in it's GOPATH beyond what is included
in the repo.

Recommended tool to manage dependencies is github.com/FiloSottile/gvt.
2016-03-05 21:21:24 +01:00

134 lines
2.9 KiB
Go

// Copyright 2013 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_test
import (
"fmt"
"net"
"runtime"
"testing"
"golang.org/x/net/internal/iana"
"golang.org/x/net/internal/nettest"
"golang.org/x/net/ipv6"
)
var supportsIPv6 bool = nettest.SupportsIPv6()
func TestConnInitiatorPathMTU(t *testing.T) {
switch runtime.GOOS {
case "nacl", "plan9", "solaris", "windows":
t.Skipf("not supported on %s", runtime.GOOS)
}
if !supportsIPv6 {
t.Skip("ipv6 is not supported")
}
ln, err := net.Listen("tcp6", "[::1]:0")
if err != nil {
t.Fatal(err)
}
defer ln.Close()
done := make(chan bool)
go acceptor(t, ln, done)
c, err := net.Dial("tcp6", ln.Addr().String())
if err != nil {
t.Fatal(err)
}
defer c.Close()
if pmtu, err := ipv6.NewConn(c).PathMTU(); err != nil {
switch runtime.GOOS {
case "darwin": // older darwin kernels don't support IPV6_PATHMTU option
t.Logf("not supported on %s", runtime.GOOS)
default:
t.Fatal(err)
}
} else {
t.Logf("path mtu for %v: %v", c.RemoteAddr(), pmtu)
}
<-done
}
func TestConnResponderPathMTU(t *testing.T) {
switch runtime.GOOS {
case "nacl", "plan9", "solaris", "windows":
t.Skipf("not supported on %s", runtime.GOOS)
}
if !supportsIPv6 {
t.Skip("ipv6 is not supported")
}
ln, err := net.Listen("tcp6", "[::1]:0")
if err != nil {
t.Fatal(err)
}
defer ln.Close()
done := make(chan bool)
go connector(t, "tcp6", ln.Addr().String(), done)
c, err := ln.Accept()
if err != nil {
t.Fatal(err)
}
defer c.Close()
if pmtu, err := ipv6.NewConn(c).PathMTU(); err != nil {
switch runtime.GOOS {
case "darwin": // older darwin kernels don't support IPV6_PATHMTU option
t.Logf("not supported on %s", runtime.GOOS)
default:
t.Fatal(err)
}
} else {
t.Logf("path mtu for %v: %v", c.RemoteAddr(), pmtu)
}
<-done
}
func TestPacketConnChecksum(t *testing.T) {
switch runtime.GOOS {
case "nacl", "plan9", "solaris", "windows":
t.Skipf("not supported on %s", runtime.GOOS)
}
if !supportsIPv6 {
t.Skip("ipv6 is not supported")
}
if m, ok := nettest.SupportsRawIPSocket(); !ok {
t.Skip(m)
}
c, err := net.ListenPacket(fmt.Sprintf("ip6:%d", iana.ProtocolOSPFIGP), "::") // OSPF for IPv6
if err != nil {
t.Fatal(err)
}
defer c.Close()
p := ipv6.NewPacketConn(c)
offset := 12 // see RFC 5340
for _, toggle := range []bool{false, true} {
if err := p.SetChecksum(toggle, offset); err != nil {
if toggle {
t.Fatalf("ipv6.PacketConn.SetChecksum(%v, %v) failed: %v", toggle, offset, err)
} else {
// Some platforms never allow to disable the kernel
// checksum processing.
t.Logf("ipv6.PacketConn.SetChecksum(%v, %v) failed: %v", toggle, offset, err)
}
}
if on, offset, err := p.Checksum(); err != nil {
t.Fatal(err)
} else {
t.Logf("kernel checksum processing enabled=%v, offset=%v", on, offset)
}
}
}