Skip to content

Commit

Permalink
fix test with new controls allowed with system_mads off
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnyhaibin committed Dec 12, 2024
1 parent d476d03 commit 47a7a18
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions tests/safety/mads_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,6 @@ def test_controls_requested_lat_from_acc_main_on(self):
finally:
self._mads_states_cleanup()

def test_controls_allowed_must_always_enable_lateral_control(self):
try:
for enable_mads in (True, False):
with self.subTest("enable_mads", enable_mads=enable_mads):
self.safety.set_mads_params(enable_mads, False, False, False, False)
for controls_allowed in (True, False):
with self.subTest("controls allowed", controls_allowed=controls_allowed):
self.safety.set_controls_allowed(controls_allowed)
self.assertEqual(self.safety.get_controls_allowed(), self.safety.get_lat_active())
finally:
self._mads_states_cleanup()

def test_disengage_lateral_on_brake_setup(self):
try:
for enable_mads in (True, False):
Expand Down Expand Up @@ -286,6 +274,28 @@ def test_enable_lateral_control_with_controls_allowed_rising_edge(self):
finally:
self._mads_states_cleanup()

def test_controls_allowed_must_always_enable_lateral_control(self):
try:
for enable_mads in (True, False):
with self.subTest("enable_mads", enable_mads=enable_mads):
for unified_engagement_mode in (True, False):
with self.subTest("unified_engagement_mode", unified_engagement_mode=unified_engagement_mode):
for controls_allowed in (True, False):
with self.subTest("controls allowed", controls_allowed=controls_allowed):
self._mads_states_cleanup()
self.safety.set_mads_params(enable_mads, False, False, unified_engagement_mode, False)
self.safety.set_controls_allowed(False)
self._rx(self._speed_msg(0))

self.safety.set_controls_allowed(controls_allowed)
self._rx(self._speed_msg(0))
expected_lat = enable_mads and unified_engagement_mode and self.safety.get_controls_allowed()
self.assertEqual(expected_lat, self.safety.get_controls_allowed_lat())
finally:
self.safety.set_controls_allowed(False)
self._rx(self._speed_msg(0))
self._mads_states_cleanup()

def test_no_always_allow_mads_button(self):
try:
self._lkas_button_msg(False)
Expand Down

0 comments on commit 47a7a18

Please sign in to comment.