aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-11-16 18:13:50 -0500
committerRuss Cox <rsc@golang.org>2011-11-16 18:13:50 -0500
commit8c6461bcb166cf9234be2e61eeab882f5856521b (patch)
tree2e3eb19712eb5d568b15fe33a02ac078ead694db
parent7d1d8fe430a3e1463bced18cd4e5bf08a0fa6c75 (diff)
downloadgo-8c6461bcb166cf9234be2e61eeab882f5856521b.tar.gz
go-8c6461bcb166cf9234be2e61eeab882f5856521b.zip
exp/ssh: fix test?
Fixes use of c after Dial failure (causes crash). May fix Dial failure by listening to 127.0.0.1:0 instead of 0.0.0.0:0 (tests should only listen on localhost). R=golang-dev, gri CC=golang-dev https://golang.org/cl/5395052
-rw-r--r--src/pkg/exp/ssh/client_auth_test.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/pkg/exp/ssh/client_auth_test.go b/src/pkg/exp/ssh/client_auth_test.go
index ccd6cd24cb..cfd6a39d70 100644
--- a/src/pkg/exp/ssh/client_auth_test.go
+++ b/src/pkg/exp/ssh/client_auth_test.go
@@ -112,22 +112,22 @@ func TestClientAuthPublickey(t *testing.T) {
}
serverConfig.PasswordCallback = nil
- l, err := Listen("tcp", "0.0.0.0:0", serverConfig)
+ l, err := Listen("tcp", "127.0.0.1:0", serverConfig)
if err != nil {
t.Fatalf("unable to listen: %s", err)
}
defer l.Close()
- done := make(chan bool)
+ done := make(chan bool, 1)
go func() {
c, err := l.Accept()
if err != nil {
t.Fatal(err)
}
+ defer c.Close()
if err := c.Handshake(); err != nil {
t.Error(err)
}
- defer c.Close()
done <- true
}()
@@ -140,7 +140,7 @@ func TestClientAuthPublickey(t *testing.T) {
c, err := Dial("tcp", l.Addr().String(), config)
if err != nil {
- t.Errorf("unable to dial remote side: %s", err)
+ t.Fatalf("unable to dial remote side: %s", err)
}
defer c.Close()
<-done