~juju-qa/ubuntu/yakkety/juju/juju-1.25.8

« back to all changes in this revision

Viewing changes to src/golang.org/x/crypto/ssh/test/tcpip_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-12-02 17:28:37 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161202172837-jkrbdlyjcxtrii2n
Initial commit of 1.25.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}