test: skip mock-relative allocation budgets under the race detector
CI failed TestCommitFrameAllocations under make race: the commit counted 3.05 allocations over the mocked call, past its margin of 3, while the race runtime moves testify's own count by 2 to 3 per call. The TestCommitDamageAllocations budget of 0 also failed once in a full race run from a background allocation. Both skip under -race; perf-check still runs them without it, and the exact zero-allocation subtest of the commit keeps running under -race.
- commit
- 55e2634bf2c902f85bde787fcdbfa2277455e869
- author
- brice · · 2026-10-14 04:23 UTC
- committer
- brice · · 2026-10-14 04:34 UTC
- parent
- ffe1c25
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
4 files · +23 -0
M internal/adapters/drm/commit_alloc_test.go +6 -0
| @@ -53,6 +53,12 @@ func TestCommitFrameAllocations(t *testing.T) { | |||
| 53 | 53 | } | |
| 54 | 54 | }) | |
| 55 | 55 | t.Run("success path", func(t *testing.T) { | |
| 56 | + | if raceEnabled { | |
| 57 | + | // The race runtime moves testify's count by a few | |
| 58 | + | // allocations per call, as much as the margin below. | |
| 59 | + | // perf-check runs it without; the subtest above stays exact. | |
| 60 | + | t.Skip("testify allocates unevenly under the race detector") | |
| 61 | + | } | |
| 56 | 62 | o, c := scanoutAllocsOutput(t) | |
| 57 | 63 | k := newMockkms(t) | |
| 58 | 64 | k.EXPECT().commit(mock.Anything, mock.Anything, mock.Anything).Return(nil) | |
| @@ -53,6 +53,12 @@ func TestCommitFrameAllocations(t *testing.T) { | |||||
| 53 | } | 53 | } | ||
| 54 | }) | 54 | }) | ||
| 55 | t.Run("success path", func(t *testing.T) { | 55 | t.Run("success path", func(t *testing.T) { | ||
| 56 | + | if raceEnabled { | |||
| 57 | + | // The race runtime moves testify's count by a few | |||
| 58 | + | // allocations per call, as much as the margin below. | |||
| 59 | + | // perf-check runs it without; the subtest above stays exact. | |||
| 60 | + | t.Skip("testify allocates unevenly under the race detector") | |||
| 61 | + | } | |||
| 56 | o, c := scanoutAllocsOutput(t) | 62 | o, c := scanoutAllocsOutput(t) | ||
| 57 | k := newMockkms(t) | 63 | k := newMockkms(t) | ||
| 58 | k.EXPECT().commit(mock.Anything, mock.Anything, mock.Anything).Return(nil) | 64 | k.EXPECT().commit(mock.Anything, mock.Anything, mock.Anything).Return(nil) | ||
A internal/adapters/drm/norace_test.go +5 -0
| @@ -0,0 +1,5 @@ | |||
| 1 | + | //go:build !race | |
| 2 | + | ||
| 3 | + | package drm | |
| 4 | + | ||
| 5 | + | const raceEnabled = false | |
| @@ -0,0 +1,5 @@ | |||||
| 1 | + | //go:build !race | |||
| 2 | + | ||||
| 3 | + | package drm | |||
| 4 | + | ||||
| 5 | + | const raceEnabled = false | |||
A internal/adapters/drm/race_test.go +7 -0
| @@ -0,0 +1,7 @@ | |||
| 1 | + | //go:build race | |
| 2 | + | ||
| 3 | + | package drm | |
| 4 | + | ||
| 5 | + | // raceEnabled: the race runtime changes allocation counts, which budgets | |
| 6 | + | // measured against a mocked call cannot tell apart from a regression. | |
| 7 | + | const raceEnabled = true | |
| @@ -0,0 +1,7 @@ | |||||
| 1 | + | //go:build race | |||
| 2 | + | ||||
| 3 | + | package drm | |||
| 4 | + | ||||
| 5 | + | // raceEnabled: the race runtime changes allocation counts, which budgets | |||
| 6 | + | // measured against a mocked call cannot tell apart from a regression. | |||
| 7 | + | const raceEnabled = true | |||
M internal/adapters/wayland/alloc_hotpath_test.go +5 -0
| @@ -23,6 +23,11 @@ func TestReleaseHeldAllocations(t *testing.T) { | |||
| 23 | 23 | } | |
| 24 | 24 | ||
| 25 | 25 | func TestCommitDamageAllocations(t *testing.T) { | |
| 26 | + | if raceEnabled { | |
| 27 | + | // AllocsPerRun counts every goroutine, and the race runtime | |
| 28 | + | // allocates on its own now and then. perf-check runs it without. | |
| 29 | + | t.Skip("the race detector allocates in the background") | |
| 30 | + | } | |
| 26 | 31 | srv := &Server{fifoSurfaces: map[*surface]struct{}{}} | |
| 27 | 32 | surf := &surface{server: srv} | |
| 28 | 33 | commit := func() { | |
| @@ -23,6 +23,11 @@ func TestReleaseHeldAllocations(t *testing.T) { | |||||
| 23 | } | 23 | } | ||
| 24 | 24 | ||||
| 25 | func TestCommitDamageAllocations(t *testing.T) { | 25 | func TestCommitDamageAllocations(t *testing.T) { | ||
| 26 | + | if raceEnabled { | |||
| 27 | + | // AllocsPerRun counts every goroutine, and the race runtime | |||
| 28 | + | // allocates on its own now and then. perf-check runs it without. | |||
| 29 | + | t.Skip("the race detector allocates in the background") | |||
| 30 | + | } | |||
| 26 | srv := &Server{fifoSurfaces: map[*surface]struct{}{}} | 31 | srv := &Server{fifoSurfaces: map[*surface]struct{}{}} | ||
| 27 | surf := &surface{server: srv} | 32 | surf := &surface{server: srv} | ||
| 28 | commit := func() { | 33 | commit := func() { | ||