]> Cypherpunks repositories - gostls13.git/commitdiff
net: remove arbitrary deadlines in PacketConn tests
authorBryan C. Mills <bcmills@google.com>
Wed, 1 Dec 2021 16:04:39 +0000 (11:04 -0500)
committerBryan C. Mills <bcmills@google.com>
Thu, 2 Dec 2021 05:26:57 +0000 (05:26 +0000)
When TestPacketConn was added (in CL 6501057) it included arbitrary
100ms deadlines. Those deadlines were arbitrarily increased to 500ms
in CL 4922.

If the test is actually provoking a deadlock, allowing it to deadlock
will give us a more useful goroutine dump. Otherwise, the deadlines
don't seem all that useful — they appear to increase code coverage,
but have no effect on the test in the typical case, and can only
cause flakes on particularly-slow machines.

For #43627

Change-Id: I83de5217c54c743b83adddf51d4f6f2bd5b91732
Reviewed-on: https://go-review.googlesource.com/c/go/+/368215
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/net/packetconn_test.go

index b3b17156555a8a28e9673096b991a74a99d2653b..487912efab961566079dd0f19e3679dc33f5f2ef 100644 (file)
@@ -12,7 +12,6 @@ package net
 import (
        "os"
        "testing"
-       "time"
 )
 
 // The full stack test cases for IPConn have been moved to the
@@ -60,9 +59,6 @@ func TestPacketConn(t *testing.T) {
                }
                defer closer(c1, tt.net, tt.addr1, tt.addr2)
                c1.LocalAddr()
-               c1.SetDeadline(time.Now().Add(500 * time.Millisecond))
-               c1.SetReadDeadline(time.Now().Add(500 * time.Millisecond))
-               c1.SetWriteDeadline(time.Now().Add(500 * time.Millisecond))
 
                c2, err := ListenPacket(tt.net, tt.addr2)
                if err != nil {
@@ -70,9 +66,6 @@ func TestPacketConn(t *testing.T) {
                }
                defer closer(c2, tt.net, tt.addr1, tt.addr2)
                c2.LocalAddr()
-               c2.SetDeadline(time.Now().Add(500 * time.Millisecond))
-               c2.SetReadDeadline(time.Now().Add(500 * time.Millisecond))
-               c2.SetWriteDeadline(time.Now().Add(500 * time.Millisecond))
                rb2 := make([]byte, 128)
 
                if _, err := c1.WriteTo(wb, c2.LocalAddr()); err != nil {
@@ -115,9 +108,6 @@ func TestConnAndPacketConn(t *testing.T) {
                }
                defer closer(c1, tt.net, tt.addr1, tt.addr2)
                c1.LocalAddr()
-               c1.SetDeadline(time.Now().Add(500 * time.Millisecond))
-               c1.SetReadDeadline(time.Now().Add(500 * time.Millisecond))
-               c1.SetWriteDeadline(time.Now().Add(500 * time.Millisecond))
 
                c2, err := Dial(tt.net, c1.LocalAddr().String())
                if err != nil {
@@ -126,9 +116,6 @@ func TestConnAndPacketConn(t *testing.T) {
                defer c2.Close()
                c2.LocalAddr()
                c2.RemoteAddr()
-               c2.SetDeadline(time.Now().Add(500 * time.Millisecond))
-               c2.SetReadDeadline(time.Now().Add(500 * time.Millisecond))
-               c2.SetWriteDeadline(time.Now().Add(500 * time.Millisecond))
 
                if _, err := c2.Write(wb); err != nil {
                        t.Fatal(err)