Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subaru safety: fix mutations failures #2056

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/libpanda/safety_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ int get_angle_meas_max(void){
return angle_meas.max;
}

int get_angle_meas_last(void){
return angle_meas.values[0];
}

// ***** car specific helpers *****

Expand Down
1 change: 1 addition & 0 deletions tests/libpanda/safety_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def setup_safety_helpers(ffi):
void set_angle_meas(int min, int max);
int get_angle_meas_min(void);
int get_angle_meas_max(void);
int get_angle_meas_last(void);

bool get_cruise_engaged_prev(void);
void set_cruise_engaged_prev(bool engaged);
Expand Down
15 changes: 15 additions & 0 deletions tests/safety/test_subaru.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,21 @@ def _pcm_status_msg(self, enable):
values = {"Cruise_Activated": enable}
return self.packer.make_can_msg_panda("CruiseControl", self.ALT_MAIN_BUS, values)

def test_angle_meas(self):
self.assertTrue(self._rx(self._angle_meas_msg(0)))
self.assertEqual(self.safety.get_angle_meas_last(), 0)

self.assertTrue(self._rx(self._angle_meas_msg(1)))
self.assertEqual(self.safety.get_angle_meas_last(), 100)

def test_vehicle_speed(self):
self.assertTrue(self._rx(self._speed_msg(0)))
self.assertFalse(self.safety.get_vehicle_moving())
self.assertEqual(self.safety.get_vehicle_speed_last(), 0)

self.assertTrue(self._rx(self._speed_msg(1)))
self.assertTrue(self.safety.get_vehicle_moving())
self.assertEqual(self.safety.get_vehicle_speed_last(), 103)

class TestSubaruStockLongitudinalSafetyBase(TestSubaruSafetyBase):
def _cancel_msg(self, cancel, cruise_throttle=0):
Expand Down
Loading