Преглед изворни кода

ssh: fix flaky TestInvalidServerMessage

When shutting down the test, we sometimes see EOF on the server's side
of the connection and sometimes ECONNRESET. In the latter case, based
on timing, it was possible that the server loop would hit Errorf during
shutdown and cause the test to fail.

R=dave
CC=golang-dev
https://golang.org/cl/6125047
Adam Langley пре 13 година
родитељ
комит
2e60680932
1 измењених фајлова са 5 додато и 0 уклоњено
  1. 5 0
      ssh/session_test.go

+ 5 - 0
ssh/session_test.go

@@ -9,6 +9,7 @@ package ssh
 import (
 import (
 	"bytes"
 	"bytes"
 	"io"
 	"io"
+	"net"
 	"testing"
 	"testing"
 
 
 	"code.google.com/p/go.crypto/ssh/terminal"
 	"code.google.com/p/go.crypto/ssh/terminal"
@@ -45,6 +46,10 @@ func dial(handler serverType, t *testing.T) *ClientConn {
 			if err == io.EOF {
 			if err == io.EOF {
 				return
 				return
 			}
 			}
+			// We sometimes get ECONNRESET rather than EOF.
+			if _, ok := err.(*net.OpError); ok {
+				return
+			}
 			if err != nil {
 			if err != nil {
 				t.Errorf("Unable to accept incoming channel request: %v", err)
 				t.Errorf("Unable to accept incoming channel request: %v", err)
 				return
 				return