mirror of
https://github.com/golang/go
synced 2024-11-02 13:42:29 +00:00
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
This commit is contained in:
parent
7d1d8fe430
commit
8c6461bcb1
1 changed files with 4 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue