1 // Copyright 2017 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
15 "golang.org/x/net/internal/nettest"
16 "golang.org/x/net/internal/socket"
19 func TestSocket(t *testing.T) {
20 t.Run("Option", func(t *testing.T) {
21 testSocketOption(t, &socket.Option{Level: syscall.SOL_SOCKET, Name: syscall.SO_RCVBUF, Len: 4})
25 func testSocketOption(t *testing.T, so *socket.Option) {
26 c, err := nettest.NewLocalPacketListener("udp")
28 t.Skipf("not supported on %s/%s: %v", runtime.GOOS, runtime.GOARCH, err)
31 cc, err := socket.NewConn(c.(net.Conn))
36 if err := so.SetInt(cc, N); err != nil {
39 n, err := so.GetInt(cc)
44 t.Fatalf("got %d; want greater than or equal to %d", n, N)