Skip to content

test_models: fuzz openpilot TX against panda on replayed routes#37726

Open
felmonon wants to merge 3 commits intocommaai:masterfrom
felmonon:speedup-test-car-interfaces
Open

test_models: fuzz openpilot TX against panda on replayed routes#37726
felmonon wants to merge 3 commits intocommaai:masterfrom
felmonon:speedup-test-car-interfaces

Conversation

@felmonon
Copy link

@felmonon felmonon commented Mar 24, 2026

Description

Fixes #32425.

This adds TX-side fuzz coverage to selfdrive/car/tests/test_models.py.

The fuzz test replays route CAN through CarInterface and panda safety, then checks the TX messages openpilot emits against safety_tx_hook. It waits for a bounded number of valid replayed frames so the test reliably exercises TX instead of failing on an empty route slice.

It also adds a Toyota angle-control regression on a real route that exercises accepted, blocked, recovered, and inactive LTA TX paths. The blocked/recovered path is driven by repeated STEER_TORQUE_SENSOR RX samples into panda so the regression goes through the real safety RX history logic instead of direct test-only setters.

Verification

  • python3 -m compileall selfdrive/car/tests/test_models.py
  • TX_FUZZ_MAX_EXAMPLES=5 /tmp/comma-openpilot-validate/.venv/bin/python -m pytest -n0 -q selfdrive/car/tests/test_models.py::TestCarModel_264_TOYOTA_RAV4_TSS2_2023::test_panda_safety_tx_fuzzy
  • TX_FUZZ_MAX_EXAMPLES=5 /tmp/comma-openpilot-validate/.venv/bin/python -m pytest -n0 -q selfdrive/car/tests/test_models.py::TestCarModel_55_HONDA_ACCORD::test_panda_safety_tx_fuzzy
  • TX_FUZZ_MAX_EXAMPLES=5 /tmp/comma-openpilot-validate/.venv/bin/python -m pytest -n0 -q selfdrive/car/tests/test_models.py::TestCarModel_264_TOYOTA_RAV4_TSS2_2023::test_toyota_lta_tx_regression

Route

Route: ad5a3fa719bc2f83/2023-10-17--19-48-42

Replay real CAN windows into panda safety and the CarInterface before fuzzing plausible CarControl outputs, so TX checks run against warmed-up safety state instead of random payloads alone.

Also add a Toyota LTA route-backed regression that alternates active and inactive angle commands to cover desired-angle history across state transitions.
@github-actions github-actions bot added CI / testing car vehicle-specific labels Mar 24, 2026
@felmonon felmonon changed the title selfdrive: add route-backed panda TX fuzz coverage test_models: fuzz openpilot TX against panda on replayed routes Mar 24, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 24, 2026

Process replay diff report

Replays driving segments through this PR and compares the behavior to master.
Please review any changes carefully to ensure they are expected.

✅ 0 changed, 66 passed, 0 errors

Bound the replayed TX fuzz test on valid frames so it reliably exercises controller output instead of failing on empty route slices.

Also replace the Toyota LTA all-pass sequence with a deterministic accepted/blocked/inactive/recovered regression that forces the over-threshold panda torque path on openpilot-generated messages.
Replace the Toyota regression's direct panda torque setters with repeated STEER_TORQUE_SENSOR RX samples, and move recovery ahead of the inactive phase so the test exercises blocked-history behavior through the real safety RX path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

car vehicle-specific CI / testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_models: add a test that fuzzes the tx messages

1 participant