Skip to content

tests: add CAN flag and rx/tx hook test helpers#438

Closed
elkoled wants to merge 2 commits intomasterfrom
pr-2952
Closed

tests: add CAN flag and rx/tx hook test helpers#438
elkoled wants to merge 2 commits intomasterfrom
pr-2952

Conversation

@elkoled
Copy link
Owner

@elkoled elkoled commented Jan 23, 2026

Description

This makes incremental progress towards commaai#2944. In this PR, I create 6 test helper functions in C to directly call rx hooks, bypassing the whitelists which would usually prevent these invalid calls from going through. Subsequent PRs will use these helpers to test full branch coverage of rx and tx hooks in all modes. I'm opening this PR to begin the discussion as to whether or not this is how we want to solve the difficult-to-cover empty else branches which are found in many mode header files. example 1 example 2 example 3

From what I can tell, we only include safety.c (where the helpers are defined) during tests, and never during production builds for panda. Thus, it should be safe to create these functions which bypass the safety functionality of the whitelists. However, please let me know if you think tests for these helper functions should be added, or if you would like any checks to be performed inside these functions as sanity checks, such as hiding the definitions behind #ifdef ALLOW_DEBUG or something similar.

Verification:

No major changes, 6 new APIs exposed but never used. Coverage is decreased but will recover as the APIs start getting used in other PRs (see commaai#2953).
opendbc/safety/tests/test.sh --report on master:
image

opendbc/safety/tests/test.sh --report on this branch:
image

@github-actions
Copy link

No car changes detected

@elkoled elkoled closed this Jan 23, 2026
@elkoled elkoled deleted the pr-2952 branch January 23, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants