Commit 8c6461bc authored by Russ Cox's avatar Russ Cox

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
parent 7d1d8fe4
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment