opendbc icon indicating copy to clipboard operation
opendbc copied to clipboard

Tests don't run correctly if PCM and gas are in same message

Open sshane opened this issue 3 years ago • 0 comments

On Toyota, the PCM status message (PCM_CRUISE) also has the gas pressed bit, so if you for example change some code that should fail a test:

if (!cruise_engaged) {
  controls_allowed = 0;
}

to

if (!cruise_engaged) {
  controls_allowed = 1;
}

it passes, as generic_rx_checks thinks the gas is pressed and just sets controls_allowed to zero for you.

I also had to be careful in the Bolt camera harness PR which has gas and PCM cruise in the same message: https://github.com/commaai/panda/pull/962

I think the real solution here would be to have tests that only ensure that each safety model sets all required global variables correctly, then we have one test that tests all the behavior (that's independent of all the car safety models).

I'm just not sure if it would be considered a regression to our testing, as now we test fully end to end (CAN message to behavior). This proposal would test CAN message to setting variables/some safety state, then the safety state to safety behavior and enforcement.

sshane avatar Aug 12 '22 07:08 sshane