]> Cypherpunks repositories - gostls13.git/commitdiff
net: remove an arbitrary timeout in TestUDPReadSizeError
authorBryan C. Mills <bcmills@google.com>
Wed, 2 Feb 2022 22:09:28 +0000 (17:09 -0500)
committerBryan Mills <bcmills@google.com>
Thu, 3 Feb 2022 05:57:46 +0000 (05:57 +0000)
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 <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/net/udpsock_test.go

index 6f82554e56d0d4e66a834ff27bb11cc88cd5421e..f8acf6a028a04fe757ebcbb9c2a91653faa9b07b 100644 (file)
@@ -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)