tests: add CAN flag and rx/tx hook test helpers #2952
+34
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
elsebranches which are found in many mode header files. example 1 example 2 example 3From 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_DEBUGor 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 --reporton master:opendbc/safety/tests/test.sh --reporton this branch: