test(core): guard zero allocations in animate
- commit
- ad7909a4729781f46aada651e9e1411ae87ab87c
- author
- brice · · 2026-10-04 16:45 UTC
- committer
- brice · · 2026-10-04 19:08 UTC
- parent
- dc38814
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +44 -1
M Makefile +1 -1
| @@ -60,7 +60,7 @@ arch: | |||
| 60 | 60 | $(HOME)/go/bin/hexcheck -hexcheck.config .hexcheck.yaml -hexcheck.root . ./... | |
| 61 | 61 | # Fast, mandatory guards for tiled content publications and SHM copies. | |
| 62 | 62 | perf-check: | |
| 63 | - | CGO_ENABLED=0 go test ./internal/app ./internal/adapters/drm ./internal/adapters/vulkan ./internal/adapters/wayland -run '^(TestOutputRoutingAllocations|TestReportSeenAllocations|TestFrameLifecycleTransitionsAllocations|TestFullscreenShownAllocations|TestFrameDecisionAllocations|TestCommitFrameAllocations|TestColorPipelineAllocations|TestShownBySnapshotAllocations|TestDueFramesAllocations|TestRenderSteadyStateAllocations|TestAccountFlipAllocations|TestFlipDoneAllocations|TestSceneWalkUnchangedTiledSHM|TestTiledCommitPublishAllocations|TestCapturedCommitApplyAllocations|TestCapturedViewportApplyAllocations|TestEffectiveInputEmptyTreeAllocations|TestHeadlessTiledSHMCallbackAndCopyBudget)$$' -count=1 | |
| 63 | + | CGO_ENABLED=0 go test ./internal/core ./internal/app ./internal/adapters/drm ./internal/adapters/vulkan ./internal/adapters/wayland -run '^(TestAnimateAllocations|TestOutputRoutingAllocations|TestReportSeenAllocations|TestFrameLifecycleTransitionsAllocations|TestFullscreenShownAllocations|TestFrameDecisionAllocations|TestCommitFrameAllocations|TestColorPipelineAllocations|TestShownBySnapshotAllocations|TestDueFramesAllocations|TestRenderSteadyStateAllocations|TestAccountFlipAllocations|TestFlipDoneAllocations|TestSceneWalkUnchangedTiledSHM|TestTiledCommitPublishAllocations|TestCapturedCommitApplyAllocations|TestCapturedViewportApplyAllocations|TestEffectiveInputEmptyTreeAllocations|TestHeadlessTiledSHMCallbackAndCopyBudget)$$' -count=1 | |
| 64 | 64 | check: vet test arch fakes-check log-check perf-check | |
| 65 | 65 | ||
| 66 | 66 | # On-demand SDR/HDR colour check with examples/testpattern on a headless | |
| @@ -60,7 +60,7 @@ arch: | |||||
| 60 | $(HOME)/go/bin/hexcheck -hexcheck.config .hexcheck.yaml -hexcheck.root . ./... | 60 | $(HOME)/go/bin/hexcheck -hexcheck.config .hexcheck.yaml -hexcheck.root . ./... | ||
| 61 | # Fast, mandatory guards for tiled content publications and SHM copies. | 61 | # Fast, mandatory guards for tiled content publications and SHM copies. | ||
| 62 | perf-check: | 62 | perf-check: | ||
| 63 | - | CGO_ENABLED=0 go test ./internal/app ./internal/adapters/drm ./internal/adapters/vulkan ./internal/adapters/wayland -run '^(TestOutputRoutingAllocations|TestReportSeenAllocations|TestFrameLifecycleTransitionsAllocations|TestFullscreenShownAllocations|TestFrameDecisionAllocations|TestCommitFrameAllocations|TestColorPipelineAllocations|TestShownBySnapshotAllocations|TestDueFramesAllocations|TestRenderSteadyStateAllocations|TestAccountFlipAllocations|TestFlipDoneAllocations|TestSceneWalkUnchangedTiledSHM|TestTiledCommitPublishAllocations|TestCapturedCommitApplyAllocations|TestCapturedViewportApplyAllocations|TestEffectiveInputEmptyTreeAllocations|TestHeadlessTiledSHMCallbackAndCopyBudget)$$' -count=1 | 63 | + | CGO_ENABLED=0 go test ./internal/core ./internal/app ./internal/adapters/drm ./internal/adapters/vulkan ./internal/adapters/wayland -run '^(TestAnimateAllocations|TestOutputRoutingAllocations|TestReportSeenAllocations|TestFrameLifecycleTransitionsAllocations|TestFullscreenShownAllocations|TestFrameDecisionAllocations|TestCommitFrameAllocations|TestColorPipelineAllocations|TestShownBySnapshotAllocations|TestDueFramesAllocations|TestRenderSteadyStateAllocations|TestAccountFlipAllocations|TestFlipDoneAllocations|TestSceneWalkUnchangedTiledSHM|TestTiledCommitPublishAllocations|TestCapturedCommitApplyAllocations|TestCapturedViewportApplyAllocations|TestEffectiveInputEmptyTreeAllocations|TestHeadlessTiledSHMCallbackAndCopyBudget)$$' -count=1 |
| 64 | check: vet test arch fakes-check log-check perf-check | 64 | check: vet test arch fakes-check log-check perf-check | ||
| 65 | 65 | ||||
| 66 | # On-demand SDR/HDR colour check with examples/testpattern on a headless | 66 | # On-demand SDR/HDR colour check with examples/testpattern on a headless | ||
A internal/core/animate_alloc_test.go +43 -0
| @@ -0,0 +1,43 @@ | |||
| 1 | + | package core | |
| 2 | + | ||
| 3 | + | import ( | |
| 4 | + | "testing" | |
| 5 | + | "time" | |
| 6 | + | ) | |
| 7 | + | ||
| 8 | + | // TestAnimateAllocations guards animate: with a camera, a switch and 20 rect | |
| 9 | + | // motions running it allocates nothing. | |
| 10 | + | func TestAnimateAllocations(t *testing.T) { | |
| 11 | + | c, ic := indicatorCore(t) | |
| 12 | + | c.cfg.Animations.On = true | |
| 13 | + | sc := c.cur() | |
| 14 | + | t0 := ic.now | |
| 15 | + | m := sc.mon | |
| 16 | + | m.AddWindow(1) | |
| 17 | + | m.AddWindow(2) | |
| 18 | + | ||
| 19 | + | ws := m.Workspaces[0] | |
| 20 | + | ws.motion = c.spring(viewSpring(100, 0), t0) | |
| 21 | + | ws.shift = 100 | |
| 22 | + | m.switchMotion = c.spring(workspaceSpring(100, 0), t0) | |
| 23 | + | m.switchOff = 100 | |
| 24 | + | sc.rects = make(map[WindowID]rectMotion, 20) | |
| 25 | + | for i := range 20 { | |
| 26 | + | sp := viewSpring(50, 0) | |
| 27 | + | sc.rects[WindowID(100+i)] = rectMotion{ | |
| 28 | + | x: c.spring(sp, t0), y: c.spring(sp, t0), | |
| 29 | + | w: c.spring(sp, t0), h: c.spring(sp, t0), | |
| 30 | + | dx: 50, dy: 50, dw: 50, dh: 50, | |
| 31 | + | } | |
| 32 | + | } | |
| 33 | + | ||
| 34 | + | now := t0.Add(10 * time.Millisecond) | |
| 35 | + | for name, only := range map[string]*screen{"all": nil, "only": sc} { | |
| 36 | + | if n := testing.AllocsPerRun(100, func() { c.animate(now, only) }); n != 0 { | |
| 37 | + | t.Errorf("animate(%s) allocs = %v, want 0", name, n) | |
| 38 | + | } | |
| 39 | + | } | |
| 40 | + | if !ws.motion.on || !m.switchMotion.on || len(sc.rects) != 20 { | |
| 41 | + | t.Fatalf("motions settled: camera %v switch %v rects %d", ws.motion.on, m.switchMotion.on, len(sc.rects)) | |
| 42 | + | } | |
| 43 | + | } | |
| @@ -0,0 +1,43 @@ | |||||
| 1 | + | package core | |||
| 2 | + | ||||
| 3 | + | import ( | |||
| 4 | + | "testing" | |||
| 5 | + | "time" | |||
| 6 | + | ) | |||
| 7 | + | ||||
| 8 | + | // TestAnimateAllocations guards animate: with a camera, a switch and 20 rect | |||
| 9 | + | // motions running it allocates nothing. | |||
| 10 | + | func TestAnimateAllocations(t *testing.T) { | |||
| 11 | + | c, ic := indicatorCore(t) | |||
| 12 | + | c.cfg.Animations.On = true | |||
| 13 | + | sc := c.cur() | |||
| 14 | + | t0 := ic.now | |||
| 15 | + | m := sc.mon | |||
| 16 | + | m.AddWindow(1) | |||
| 17 | + | m.AddWindow(2) | |||
| 18 | + | ||||
| 19 | + | ws := m.Workspaces[0] | |||
| 20 | + | ws.motion = c.spring(viewSpring(100, 0), t0) | |||
| 21 | + | ws.shift = 100 | |||
| 22 | + | m.switchMotion = c.spring(workspaceSpring(100, 0), t0) | |||
| 23 | + | m.switchOff = 100 | |||
| 24 | + | sc.rects = make(map[WindowID]rectMotion, 20) | |||
| 25 | + | for i := range 20 { | |||
| 26 | + | sp := viewSpring(50, 0) | |||
| 27 | + | sc.rects[WindowID(100+i)] = rectMotion{ | |||
| 28 | + | x: c.spring(sp, t0), y: c.spring(sp, t0), | |||
| 29 | + | w: c.spring(sp, t0), h: c.spring(sp, t0), | |||
| 30 | + | dx: 50, dy: 50, dw: 50, dh: 50, | |||
| 31 | + | } | |||
| 32 | + | } | |||
| 33 | + | ||||
| 34 | + | now := t0.Add(10 * time.Millisecond) | |||
| 35 | + | for name, only := range map[string]*screen{"all": nil, "only": sc} { | |||
| 36 | + | if n := testing.AllocsPerRun(100, func() { c.animate(now, only) }); n != 0 { | |||
| 37 | + | t.Errorf("animate(%s) allocs = %v, want 0", name, n) | |||
| 38 | + | } | |||
| 39 | + | } | |||
| 40 | + | if !ws.motion.on || !m.switchMotion.on || len(sc.rects) != 20 { | |||
| 41 | + | t.Fatalf("motions settled: camera %v switch %v rects %d", ws.motion.on, m.switchMotion.on, len(sc.rects)) | |||
| 42 | + | } | |||
| 43 | + | } | |||