diff --git a/tests/safety/test_gm.py b/tests/safety/test_gm.py index 92507e0d10..e8e5430cab 100755 --- a/tests/safety/test_gm.py +++ b/tests/safety/test_gm.py @@ -15,6 +15,8 @@ class Buttons: class GmLongitudinalBase(common.PandaSafetyTest): + PCM_CRUISE = False # openpilot can control the PCM state if longitudinal + # pylint: disable=no-member,abstract-method def test_set_resume_buttons(self): """ @@ -70,6 +72,8 @@ class TestGmSafetyBase(common.PandaSafetyTest, common.DriverTorqueSteeringSafety INACTIVE_REGEN = 0 MAX_BRAKE = 0 + PCM_CRUISE = True # openpilot is tied to the PCM state if not longitudinal + @classmethod def setUpClass(cls): if cls.__name__ == "TestGmSafetyBase": @@ -85,7 +89,11 @@ def setUp(self): self.safety.init_tests() def _pcm_status_msg(self, enable): - raise NotImplementedError + if self.PCM_CRUISE: + values = {"CruiseState": enable} + return self.packer.make_can_msg_panda("AcceleratorPedal2", 0, values) + else: + raise NotImplementedError def _speed_msg(self, speed): values = {"%sWheelSpd" % s: speed for s in ["RL", "RR"]} @@ -102,6 +110,9 @@ def _user_regen_msg(self, regen): def _user_gas_msg(self, gas): values = {"AcceleratorPedal2": 1 if gas else 0} + if self.PCM_CRUISE: + # Fill CruiseState with expected value if the safety mode reads cruise state from gas msg + values["CruiseState"] = self.safety.get_controls_allowed() return self.packer.make_can_msg_panda("AcceleratorPedal2", 0, values) def _send_brake_msg(self, brake): @@ -179,15 +190,6 @@ def setUp(self): self.safety.set_safety_hooks(Panda.SAFETY_GM, Panda.FLAG_GM_HW_CAM) self.safety.init_tests() - def _user_gas_msg(self, gas): - cruise_active = self.safety.get_controls_allowed() - values = {"AcceleratorPedal2": 1 if gas else 0, "CruiseState": cruise_active} - return self.packer.make_can_msg_panda("AcceleratorPedal2", 0, values) - - def _pcm_status_msg(self, enable): - values = {"CruiseState": enable} - return self.packer.make_can_msg_panda("AcceleratorPedal2", 0, values) - def test_buttons(self): # Only CANCEL button is allowed while cruise is enabled self.safety.set_controls_allowed(0)