Skip to content

Conversation

@mpurnell1
Copy link
Contributor

@mpurnell1 mpurnell1 commented Dec 19, 2025

Description

This makes incremental progress towards #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 #2953).
opendbc/safety/tests/test.sh --report on master:
image

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

car safety vehicle-specific safety code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant