mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 21:27:31 +00:00
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
@@ -952,7 +952,7 @@ func TestAllocs(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
query []byte
|
||||
want int
|
||||
want uint64
|
||||
}{
|
||||
// Name lowercasing, response slice created by dns.NewBuilder,
|
||||
// and closure allocation from go call.
|
||||
@@ -964,11 +964,11 @@ func TestAllocs(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
allocs := testing.AllocsPerRun(100, func() {
|
||||
err := tstest.MinAllocsPerRun(t, tt.want, func() {
|
||||
syncRespond(r, tt.query)
|
||||
})
|
||||
if int(allocs) > tt.want {
|
||||
t.Errorf("%s: allocs = %v; want %v", tt.name, allocs, tt.want)
|
||||
if err != nil {
|
||||
t.Errorf("%s: %v", tt.name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user