From: Bryan C. Mills Date: Wed, 2 Feb 2022 22:09:28 +0000 (-0500) Subject: net: remove an arbitrary timeout in TestUDPReadSizeError X-Git-Tag: go1.18rc1~117 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=475ce826b75f113aff2810f3d27cb861adee0caa;p=gostls13.git net: remove an arbitrary timeout in TestUDPReadSizeError Looking at the condition actually exercised by the test it seems unnecessary: assuming that the Write succeeds (checked earlier in the test), the Read must have a nonzero number of bytes available to read immediately. (That is not the case in TestUDPZeroByteBuffer, from which this test appears to have been derived.) Fixes #50870 Change-Id: Ia6040a2d5dc320f0b86ec9d6f6b91dc72e8f3b84 Reviewed-on: https://go-review.googlesource.com/c/go/+/382537 Trust: Bryan Mills Run-TryBot: Bryan Mills TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor --- diff --git a/src/net/udpsock_test.go b/src/net/udpsock_test.go index 6f82554e56..f8acf6a028 100644 --- a/src/net/udpsock_test.go +++ b/src/net/udpsock_test.go @@ -415,19 +415,14 @@ func TestUDPReadSizeError(t *testing.T) { if n != len(b1) { t.Errorf("got %d; want %d", n, len(b1)) } - c1.SetReadDeadline(time.Now().Add(100 * time.Millisecond)) b2 := make([]byte, len(b1)-1) if genericRead { n, err = c1.(Conn).Read(b2) } else { n, _, err = c1.ReadFrom(b2) } - switch err { - case nil: // ReadFrom succeeds - default: // Read may timeout, it depends on the platform - if nerr, ok := err.(Error); (!ok || !nerr.Timeout()) && runtime.GOOS != "windows" { // Windows returns WSAEMSGSIZE - t.Fatal(err) - } + if err != nil && runtime.GOOS != "windows" { // Windows returns WSAEMSGSIZE + t.Fatal(err) } if n != len(b1)-1 { t.Fatalf("got %d; want %d", n, len(b1)-1)