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 <hanwen@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/ssh/session_test.go b/ssh/session_test.go index 7dce6dd..39853bf 100644 --- a/ssh/session_test.go +++ b/ssh/session_test.go
@@ -35,7 +35,7 @@ } conf.AddHostKey(testSigners["rsa"]) - _, chans, reqs, err := NewServerConn(c1, &conf) + conn, chans, reqs, err := NewServerConn(c1, &conf) if err != nil { t.Fatalf("Unable to handshake: %v", err) } @@ -56,6 +56,9 @@ handler(ch, inReqs, t) }() } + if err := conn.Wait(); err != io.EOF { + t.Logf("server exit reason: %v", err) + } }() config := &ClientConfig{ @@ -358,10 +361,9 @@ } written, err := copyNRandomly("stdin", serverStdin, origBuf, windowTestBytes) if err != nil { - t.Fatalf("failed to copy origBuf to serverStdin: %v", err) - } - if written != windowTestBytes { - t.Fatalf("Wrote only %d of %d bytes to server", written, windowTestBytes) + t.Errorf("failed to copy origBuf to serverStdin: %v", err) + } else if written != windowTestBytes { + t.Errorf("Wrote only %d of %d bytes to server", written, windowTestBytes) } echoedBytes := <-result