Skip to content

mazda: fix the CX-9 model tests and run the fork's tests in CI - #9

Merged
zephleggett merged 2 commits into
developfrom
mazda-test-fixes
Aug 31, 2026
Merged

mazda: fix the CX-9 model tests and run the fork's tests in CI#9
zephleggett merged 2 commits into
developfrom
mazda-test-fixes

Conversation

@zephleggett

Copy link
Copy Markdown

Three failures that predate #8 and fail on every branch.

test models: MAZDA_CX9 radar and canValid

MazdaPlatformConfig's default dbc_dict gained Bus.radar for the CX-5 2022 track work, so every Mazda claimed a radar and radarUnavailable was False everywhere. The 2016-20 CX-9 is the one platform that never puts the 0x361-0x366 tracks on bus 0, so RadarInterface built a parser that never went valid.

Checked all six Mazda platforms against segments 0-2: only the CX-9 lacks the tracks, so it gets its own dbc_dict without the radar bus.

The can_invalid_cnt failure was separate and only reproduced on segment 0, which is the segment CI happens to pick. CAM_PEDESTRIAN is read through vl, so it registered lazily with liveness checks on while its three siblings were already declared at nan for exactly that reason. The 2016-20 CX-9 camera never sends it, so canValid was false for the whole route (5745 frames).

./test.sh: the fork's tests never ran

opendbc has no pytest anywhere - the suite runs under unittest-parallel, safety under unittest discover, and pytest is in neither pyproject.toml nor uv.lock. These five files were the only ones importing it, so discovery raised ModuleNotFoundError on each. The 146 tests have never executed in this repo; they only ran in the parent openpilot repo, whose venv has pytest.

Converted in place rather than adding pytest, which would put a dependency upstream does not have into files upstream owns. Fixtures become module-level factories, parametrize becomes a class-level case table walked with subTest, and approx becomes assertAlmostEqual or a small _Approx helper where the tolerance is compared inside an expression. Case coverage is unchanged at 166.

TestStandstillHold and TestAdvertisedLead had a run() helper that shadows TestCase.run; it is drive() now.

Discovery goes from 9529 tests with 5 errors to 9656 with none.

Not addressed

The Safety mutation tests failure is flaky, not a real regression: it passed on 8ec52e0 and failed on f8c21af, and the only diff between them is a comment rewrite. The four survivors are in lateral.h and longitudinal.h, which #8 never touched.

Verified locally

  • all six Mazda platforms, test_car_interface + test_radar_interface, segments 0-2
  • unittest-parallel -j4: 9656 tests, OK
  • ruff and codespell clean

MazdaPlatformConfig's default dbc_dict gained Bus.radar for the CX-5 2022
radar track work, which handed every Mazda a radar bus and left
radarUnavailable False on all of them. The 2016-20 CX-9 is the one platform
that never puts the 0x361-0x366 tracks on bus 0, so its RadarInterface built
a parser that never went valid and test_radar_interface failed on every
segment of route 10b5a4b380434151.

Give that platform its own dbc_dict without the radar bus. Verified against
all six Mazda platforms on segments 0-2: only the CX-9 lacks the tracks.

Also declare CAM_PEDESTRIAN in the cam parser at nan frequency, next to the
three siblings already there. It is read through vl, so it was registering
lazily with liveness checks on, and the 2016-20 CX-9 camera never sends it:
canValid stayed false for a whole route (5745 frames on segment 0).
opendbc has no pytest: the suite runs under unittest-parallel, the safety
tests under unittest discover, and pytest appears in neither pyproject.toml
nor uv.lock. These five files were the only ones importing it, so discovery
raised ModuleNotFoundError on each and ./test.sh failed on both runners. The
146 tests had never executed here; they only ever ran in the parent openpilot
repo, whose venv has pytest.

Convert them in place: fixtures become module-level factories, parametrize
becomes a class-level case table walked with subTest, and approx becomes
assertAlmostEqual or a small _Approx helper where the tolerance is compared
inside an expression. Case coverage is unchanged at 166.

TestStandstillHold and TestAdvertisedLead had a run() helper, which shadows
TestCase.run and would have swallowed every test in those classes; it is
drive() now.

Discovery goes from 9529 tests with 5 errors to 9656 with none.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing to opendbc! In order for us to review your PR as quickly as possible, check the following:

  • Convert your PR to a draft unless it's ready to review
  • Read the contributing docs
  • Before marking as "ready for review", ensure:
    • the goal is clearly stated in the description
    • all the tests are passing
    • include a route or your device' dongle ID if relevant

@zephleggett
zephleggett merged commit b79f49b into develop Aug 31, 2026
12 checks passed
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.

1 participant