mirror of
https://github.com/golang/go
synced 2024-11-23 09:20:05 -07:00
crypto/tls: add timeouts to recorded tests
If something causes the recorded tests to deviate from the expected flows, they might wait forever for data that is not coming. Add a short timeout, after which a useful error message is shown. Change-Id: Ib11ccc0e17dcb8b2180493556017275678abbb08 Reviewed-on: https://go-review.googlesource.com/c/144116 Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Adam Langley <agl@golang.org>
This commit is contained in:
parent
f98ac85192
commit
a7fb5e1bd2
@ -384,10 +384,12 @@ func (test *clientTest) run(t *testing.T, write bool) {
|
||||
}
|
||||
for i, b := range flows {
|
||||
if i%2 == 1 {
|
||||
serverConn.SetWriteDeadline(time.Now().Add(1 * time.Second))
|
||||
serverConn.Write(b)
|
||||
continue
|
||||
}
|
||||
bb := make([]byte, len(b))
|
||||
serverConn.SetReadDeadline(time.Now().Add(1 * time.Second))
|
||||
_, err := io.ReadFull(serverConn, bb)
|
||||
if err != nil {
|
||||
t.Fatalf("%s #%d: %s", test.name, i, err)
|
||||
|
@ -615,10 +615,12 @@ func (test *serverTest) run(t *testing.T, write bool) {
|
||||
}
|
||||
for i, b := range flows {
|
||||
if i%2 == 0 {
|
||||
clientConn.SetWriteDeadline(time.Now().Add(1 * time.Second))
|
||||
clientConn.Write(b)
|
||||
continue
|
||||
}
|
||||
bb := make([]byte, len(b))
|
||||
clientConn.SetReadDeadline(time.Now().Add(1 * time.Second))
|
||||
n, err := io.ReadFull(clientConn, bb)
|
||||
if err != nil {
|
||||
t.Fatalf("%s #%d: %s\nRead %d, wanted %d, got %x, wanted %x\n", test.name, i+1, err, n, len(bb), bb[:n], b)
|
||||
|
Loading…
Reference in New Issue
Block a user