From 1b2930d70c8bad5ecae08275e56e228e0f424b02 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Wed, 1 Dec 2021 11:04:39 -0500 Subject: [PATCH] net: remove arbitrary deadlines in PacketConn tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- src/net/packetconn_test.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/net/packetconn_test.go b/src/net/packetconn_test.go index b3b1715655..487912efab 100644 --- a/src/net/packetconn_test.go +++ b/src/net/packetconn_test.go @@ -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) -- 2.48.1