From 475ce826b75f113aff2810f3d27cb861adee0caa Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Wed, 2 Feb 2022 17:09:28 -0500 Subject: [PATCH] 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 --- src/net/udpsock_test.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) 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) -- 2.50.0