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) { ...@@ -112,22 +112,22 @@ func TestClientAuthPublickey(t *testing.T) {
} }
serverConfig.PasswordCallback = nil 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 { if err != nil {
t.Fatalf("unable to listen: %s", err) t.Fatalf("unable to listen: %s", err)
} }
defer l.Close() defer l.Close()
done := make(chan bool) done := make(chan bool, 1)
go func() { go func() {
c, err := l.Accept() c, err := l.Accept()
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
defer c.Close()
if err := c.Handshake(); err != nil { if err := c.Handshake(); err != nil {
t.Error(err) t.Error(err)
} }
defer c.Close()
done <- true done <- true
}() }()
...@@ -140,7 +140,7 @@ func TestClientAuthPublickey(t *testing.T) { ...@@ -140,7 +140,7 @@ func TestClientAuthPublickey(t *testing.T) {
c, err := Dial("tcp", l.Addr().String(), config) c, err := Dial("tcp", l.Addr().String(), config)
if err != nil { if err != nil {
t.Errorf("unable to dial remote side: %s", err) t.Fatalf("unable to dial remote side: %s", err)
} }
defer c.Close() defer c.Close()
<-done <-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