all: use testingutil.MinAllocsPerRun
There are a few remaining uses of testing.AllocsPerRun: Two in which we only log the number of allocations, and one in which dynamically calculate the allocations target based on a different AllocsPerRun run. This also allows us to tighten the "no allocs" test in wgengine/filter. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:

committed by
Josh Bleecher Snyder

parent
1df865a580
commit
94fb42d4b2
@ -8,6 +8,8 @@ import (
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"tailscale.com/tstest"
|
||||
)
|
||||
|
||||
func TestCurrentFileDescriptors(t *testing.T) {
|
||||
@ -19,11 +21,11 @@ func TestCurrentFileDescriptors(t *testing.T) {
|
||||
t.Fatalf("got %v; want >= 3", n)
|
||||
}
|
||||
|
||||
allocs := int(testing.AllocsPerRun(100, func() {
|
||||
err := tstest.MinAllocsPerRun(t, 0, func() {
|
||||
n = CurrentFDs()
|
||||
}))
|
||||
if allocs != 0 {
|
||||
t.Errorf("allocs = %v; want 0", allocs)
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Open some FDs.
|
||||
|
Reference in New Issue
Block a user