From c1d377078d925b24f3d3645eead09fa95026fc6f Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Wed, 27 Oct 2021 16:02:12 -0700 Subject: [PATCH] wgengine/magicsock: use testingutil.MinAllocsPerRun This speeds up and deflakes the test. Fixes #2826 (again) Signed-off-by: Josh Bleecher Snyder --- wgengine/magicsock/magicsock_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wgengine/magicsock/magicsock_test.go b/wgengine/magicsock/magicsock_test.go index ea2db2a4a..6c2a8f7b8 100644 --- a/wgengine/magicsock/magicsock_test.go +++ b/wgengine/magicsock/magicsock_test.go @@ -44,6 +44,7 @@ import ( "tailscale.com/types/wgkey" "tailscale.com/util/cibuild" "tailscale.com/util/racebuild" + "tailscale.com/util/testingutil" "tailscale.com/wgengine/filter" "tailscale.com/wgengine/wgcfg" "tailscale.com/wgengine/wgcfg/nmcfg" @@ -1348,9 +1349,9 @@ func TestReceiveFromAllocs(t *testing.T) { } t.Logf("allowing %d allocs for Go version %q", maxAllocs, runtime.Version()) roundTrip := setUpReceiveFrom(t) - avg := int(testing.AllocsPerRun(1000, roundTrip)) - if avg > maxAllocs { - t.Fatalf("expected %d allocs in ReceiveFrom, got %v", maxAllocs, avg) + err := testingutil.MinAllocsPerRun(t, uint64(maxAllocs), roundTrip) + if err != nil { + t.Fatal(err) } }