Skip to content

Commit e7b772b

Browse files
committed
ssh: print server exit reason in tests
This helps debugging protocol violations by the client Change-Id: I8e5486b49515b719bbe3de44daa489fb7434875a Reviewed-on: https://go-review.googlesource.com/c/crypto/+/171680 Run-TryBot: Han-Wen Nienhuys <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 9732e03 commit e7b772b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Diff for: ssh/session_test.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func dial(handler serverType, t *testing.T) *Client {
3535
}
3636
conf.AddHostKey(testSigners["rsa"])
3737

38-
_, chans, reqs, err := NewServerConn(c1, &conf)
38+
conn, chans, reqs, err := NewServerConn(c1, &conf)
3939
if err != nil {
4040
t.Fatalf("Unable to handshake: %v", err)
4141
}
@@ -56,6 +56,9 @@ func dial(handler serverType, t *testing.T) *Client {
5656
handler(ch, inReqs, t)
5757
}()
5858
}
59+
if err := conn.Wait(); err != io.EOF {
60+
t.Logf("server exit reason: %v", err)
61+
}
5962
}()
6063

6164
config := &ClientConfig{
@@ -358,10 +361,9 @@ func TestServerWindow(t *testing.T) {
358361
}
359362
written, err := copyNRandomly("stdin", serverStdin, origBuf, windowTestBytes)
360363
if err != nil {
361-
t.Fatalf("failed to copy origBuf to serverStdin: %v", err)
362-
}
363-
if written != windowTestBytes {
364-
t.Fatalf("Wrote only %d of %d bytes to server", written, windowTestBytes)
364+
t.Errorf("failed to copy origBuf to serverStdin: %v", err)
365+
} else if written != windowTestBytes {
366+
t.Errorf("Wrote only %d of %d bytes to server", written, windowTestBytes)
365367
}
366368

367369
echoedBytes := <-result

0 commit comments

Comments
 (0)