github.com/deis/deis@v1.13.5-0.20170519182049-1d9e59fbdbfc/Godeps/_workspace/src/golang.org/x/crypto/ssh/test/tcpip_test.go (about) 1 // Copyright 2012 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. 4 5 // +build !windows 6 7 package test 8 9 // direct-tcpip functional tests 10 11 import ( 12 "io" 13 "net" 14 "testing" 15 ) 16 17 func TestDial(t *testing.T) { 18 server := newServer(t) 19 defer server.Shutdown() 20 sshConn := server.Dial(clientConfig()) 21 defer sshConn.Close() 22 23 l, err := net.Listen("tcp", "127.0.0.1:0") 24 if err != nil { 25 t.Fatalf("Listen: %v", err) 26 } 27 defer l.Close() 28 29 go func() { 30 for { 31 c, err := l.Accept() 32 if err != nil { 33 break 34 } 35 36 io.WriteString(c, c.RemoteAddr().String()) 37 c.Close() 38 } 39 }() 40 41 conn, err := sshConn.Dial("tcp", l.Addr().String()) 42 if err != nil { 43 t.Fatalf("Dial: %v", err) 44 } 45 defer conn.Close() 46 }