~ubuntu-branches/ubuntu/trusty/juju-core/trusty-proposed

« back to all changes in this revision

Viewing changes to src/code.google.com/p/go.crypto/ssh/test/forward_unix_test.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-29 11:40:20 UTC
  • mfrom: (23.1.1 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20140129114020-ejieitm8smtt5vln
Tags: 1.17.1-0ubuntu2
d/tests/local-provider: Don't fail tests if ~/.juju is present as its
created by the juju version command. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
124
124
        }
125
125
}
126
126
 
127
 
// TODO(hanwen): test that closing the connection also
128
 
// exits the listeners.
 
127
// Check that listeners exit if the underlying client transport dies.
 
128
func TestPortForwardConnectionClose(t *testing.T) {
 
129
        server := newServer(t)
 
130
        defer server.Shutdown()
 
131
        conn := server.Dial(clientConfig())
 
132
 
 
133
        sshListener, err := conn.Listen("tcp", "localhost:0")
 
134
        if err != nil {
 
135
                t.Fatal(err)
 
136
        }
 
137
 
 
138
        quit := make(chan error, 1)
 
139
        go func() {
 
140
                for {
 
141
                        c, err := sshListener.Accept()
 
142
                        if err != nil {
 
143
                                quit <- err
 
144
                                break
 
145
                        }
 
146
                        c.Close()
 
147
                }
 
148
        }()
 
149
 
 
150
        // It would be even nicer if we closed the server side, but it
 
151
        // is more involved as the fd for that side is dup()ed.
 
152
        server.clientConn.Close()
 
153
 
 
154
        select {
 
155
        case <-time.After(1 * time.Second):
 
156
                t.Errorf("timeout: listener did not close.")
 
157
        case err := <-quit:
 
158
                t.Logf("quit as expected (error %v)", err)
 
159
        }
 
160
}