1 // Copyright 2016 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.
15 "golang.org/x/net/internal/nettest"
18 func TestTestConn(t *testing.T) {
19 tests := []struct{ name, network string }{
22 {"UnixPacketPipe", "unixpacket"},
25 for _, tt := range tests {
26 t.Run(tt.name, func(t *testing.T) {
27 if !nettest.TestableNetwork(tt.network) {
28 t.Skipf("not supported on %s", runtime.GOOS)
31 mp := func() (c1, c2 net.Conn, stop func(), err error) {
32 ln, err := nettest.NewLocalListener(tt.network)
34 return nil, nil, nil, err
37 // Start a connection between two endpoints.
39 done := make(chan bool)
41 c2, err2 = ln.Accept()
44 c1, err1 = net.Dial(ln.Addr().Network(), ln.Addr().String())
56 case "unix", "unixpacket":
57 os.Remove(ln.Addr().String())
64 return nil, nil, nil, err1
67 return nil, nil, nil, err2
69 return c1, c2, stop, nil