test(vader5): pin block_kernel_drivers to xpad only (regression #355)#363
Conversation
Assert the shipped devices/flydigi/vader5.toml blocks only xpad and never hid_generic/usbhid. The inline-TOML install tests cannot catch a value regression in the real device file; this pins the #355 fix.
Review Summary by QodoAdd regression test for vader5 block_kernel_drivers fix
WalkthroughsDescription• Add regression test for vader5 device file • Verify block_kernel_drivers contains only xpad • Ensure hid_generic and usbhid are not blocked • Parse actual shipped device file to catch regressions Diagramflowchart LR
A["vader5.toml device file"] -- "parseFile" --> B["Test validates config"]
B -- "checks block_kernel_drivers" --> C["Only xpad blocked"]
C -- "excludes hid_generic/usbhid" --> D["Regression #355 pinned"]
File Changes1. src/config/device.zig
|
📝 WalkthroughWalkthroughThis PR adds a regression test for the Vader 5 controller device configuration. The test loads the device TOML file and validates that ChangesVader 5 Kernel Driver Block List Regression Test
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/config/device.zig (1)
655-658: ⚡ Quick winSimplify: Remove redundant loop after single-entry assertion.
After asserting
blocked.len == 1(line 653) andblocked[0] == "xpad"(line 654), the loop checking that no entry matches"hid_generic"or"usbhid"is redundant. It will execute exactly once, checking that"xpad"is neither of those values, which is already guaranteed by the earlier assertions.♻️ Simplify by removing the redundant loop
const blocked = result.value.device.block_kernel_drivers orelse return error.MissingBlockList; try std.testing.expectEqual(`@as`(usize, 1), blocked.len); try std.testing.expectEqualStrings("xpad", blocked[0]); -for (blocked) |drv| { - try std.testing.expect(!std.mem.eql(u8, drv, "hid_generic")); - try std.testing.expect(!std.mem.eql(u8, drv, "usbhid")); -}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/config/device.zig` around lines 655 - 658, Remove the redundant loop that iterates over `blocked` and checks `drv` against "hid_generic" and "usbhid"; since you already assert `blocked.len == 1` and `blocked[0] == "xpad"`, delete the `for (blocked) |drv| { try std.testing.expect(!std.mem.eql(u8, drv, "hid_generic")); try std.testing.expect(!std.mem.eql(u8, drv, "usbhid")); }` block and rely on the existing assertions (using `blocked` and `std.mem.eql`) to keep the test concise.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/config/device.zig`:
- Around line 655-658: Remove the redundant loop that iterates over `blocked`
and checks `drv` against "hid_generic" and "usbhid"; since you already assert
`blocked.len == 1` and `blocked[0] == "xpad"`, delete the `for (blocked) |drv| {
try std.testing.expect(!std.mem.eql(u8, drv, "hid_generic")); try
std.testing.expect(!std.mem.eql(u8, drv, "usbhid")); }` block and rely on the
existing assertions (using `blocked` and `std.mem.eql`) to keep the test
concise.
What
Add a regression test asserting the shipped
devices/flydigi/vader5.tomlblocks onlyxpadand neverhid_generic/usbhid.Why
#362 fixed #355 by changing the device file's
block_kernel_driversvalue, but added no test. The existing install tests use inline TOML, so they cannot catch a value regression in the real shipped file. This test parses the actual file viaparseFile("devices/flydigi/vader5.toml")and pins the fix — re-adding the HID-driver block would fail CI.Changes
src/config/device.zig: new testdevice: vader5 blocks only xpad (regression #355).Test plan
zig build testgreen in the canonical Docker image (full suite EXIT=0).Refs #355, #362
Summary by CodeRabbit