diff --git a/tests/safety/common.py b/tests/safety/common.py index f3b347a1d512af..07a1ad066c62c3 100644 --- a/tests/safety/common.py +++ b/tests/safety/common.py @@ -19,3 +19,9 @@ def test_relay_malfunction(test, addr): for b in range(0, 3): test.assertFalse(test.safety.safety_tx_hook(make_msg(b, a, 8))) test.assertEqual(-1, test.safety.safety_fwd_hook(b, make_msg(b, a, 8))) + +def test_manually_enable_controls_allowed(test): + test.safety.set_controls_allowed(1) + test.assertTrue(test.safety.get_controls_allowed()) + test.safety.set_controls_allowed(0) + test.assertFalse(test.safety.get_controls_allowed()) diff --git a/tests/safety/test_cadillac.py b/tests/safety/test_cadillac.py index fd4d7907976c13..81bace66e0ed4d 100644 --- a/tests/safety/test_cadillac.py +++ b/tests/safety/test_cadillac.py @@ -3,7 +3,7 @@ import numpy as np from panda import Panda from panda.tests.safety import libpandasafety_py -from panda.tests.safety.common import make_msg +from panda.tests.safety.common import make_msg, test_manually_enable_controls_allowed MAX_RATE_UP = 2 @@ -61,9 +61,7 @@ def test_default_controls_not_allowed(self): self.assertFalse(self.safety.get_controls_allowed()) def test_manually_enable_controls_allowed(self): - self.safety.set_controls_allowed(1) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.set_controls_allowed(0) + test_manually_enable_controls_allowed(self) def test_enable_control_allowed_from_cruise(self): to_push = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') diff --git a/tests/safety/test_chrysler.py b/tests/safety/test_chrysler.py index 0b88eae21b656e..fbbc07170e5a84 100755 --- a/tests/safety/test_chrysler.py +++ b/tests/safety/test_chrysler.py @@ -3,7 +3,7 @@ import numpy as np from panda import Panda from panda.tests.safety import libpandasafety_py -from panda.tests.safety.common import test_relay_malfunction, make_msg +from panda.tests.safety.common import test_relay_malfunction, make_msg, test_manually_enable_controls_allowed MAX_RATE_UP = 3 MAX_RATE_DOWN = 3 @@ -78,10 +78,7 @@ def test_steer_safety_check(self): self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) def test_manually_enable_controls_allowed(self): - self.safety.set_controls_allowed(1) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.set_controls_allowed(0) - self.assertFalse(self.safety.get_controls_allowed()) + test_manually_enable_controls_allowed(self) def test_enable_control_allowed_from_cruise(self): to_push = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') diff --git a/tests/safety/test_gm.py b/tests/safety/test_gm.py index 657c2fe8ce4a6a..21c5af7242dbb6 100644 --- a/tests/safety/test_gm.py +++ b/tests/safety/test_gm.py @@ -3,7 +3,7 @@ import numpy as np from panda import Panda from panda.tests.safety import libpandasafety_py -from panda.tests.safety.common import test_relay_malfunction, make_msg +from panda.tests.safety.common import test_relay_malfunction, make_msg, test_manually_enable_controls_allowed MAX_RATE_UP = 7 MAX_RATE_DOWN = 17 @@ -195,10 +195,7 @@ def test_steer_safety_check(self): self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) def test_manually_enable_controls_allowed(self): - self.safety.set_controls_allowed(1) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.set_controls_allowed(0) - self.assertFalse(self.safety.get_controls_allowed()) + test_manually_enable_controls_allowed(self) def test_non_realtime_limit_up(self): self.safety.set_gm_torque_driver(0, 0) diff --git a/tests/safety/test_honda.py b/tests/safety/test_honda.py index 65449a7447a589..20a5e54309c772 100755 --- a/tests/safety/test_honda.py +++ b/tests/safety/test_honda.py @@ -3,7 +3,7 @@ import numpy as np from panda import Panda from panda.tests.safety import libpandasafety_py -from panda.tests.safety.common import test_relay_malfunction, make_msg +from panda.tests.safety.common import test_relay_malfunction, make_msg, test_manually_enable_controls_allowed MAX_BRAKE = 255 @@ -85,6 +85,9 @@ def test_relay_malfunction(self): def test_default_controls_not_allowed(self): self.assertFalse(self.safety.get_controls_allowed()) + def test_manually_enable_controls_allowed(self): + test_manually_enable_controls_allowed(self) + def test_resume_button(self): RESUME_BTN = 4 self.safety.set_controls_allowed(0) diff --git a/tests/safety/test_hyundai.py b/tests/safety/test_hyundai.py index d0b57477aea723..3c422df1da7e7f 100644 --- a/tests/safety/test_hyundai.py +++ b/tests/safety/test_hyundai.py @@ -3,7 +3,7 @@ import numpy as np from panda import Panda from panda.tests.safety import libpandasafety_py -from panda.tests.safety.common import test_relay_malfunction, make_msg +from panda.tests.safety.common import test_relay_malfunction, make_msg, test_manually_enable_controls_allowed MAX_RATE_UP = 3 MAX_RATE_DOWN = 7 @@ -73,10 +73,7 @@ def test_steer_safety_check(self): self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) def test_manually_enable_controls_allowed(self): - self.safety.set_controls_allowed(1) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.set_controls_allowed(0) - self.assertFalse(self.safety.get_controls_allowed()) + test_manually_enable_controls_allowed(self) def test_enable_control_allowed_from_cruise(self): to_push = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *') diff --git a/tests/safety/test_subaru.py b/tests/safety/test_subaru.py index c7d5be92c25fc4..9df046d5719435 100644 --- a/tests/safety/test_subaru.py +++ b/tests/safety/test_subaru.py @@ -3,7 +3,7 @@ import numpy as np from panda import Panda from panda.tests.safety import libpandasafety_py -from panda.tests.safety.common import test_relay_malfunction, make_msg +from panda.tests.safety.common import test_relay_malfunction, make_msg, test_manually_enable_controls_allowed MAX_RATE_UP = 50 MAX_RATE_DOWN = 70 @@ -88,10 +88,7 @@ def test_steer_safety_check(self): self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) def test_manually_enable_controls_allowed(self): - self.safety.set_controls_allowed(1) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.set_controls_allowed(0) - self.assertFalse(self.safety.get_controls_allowed()) + test_manually_enable_controls_allowed(self) def test_non_realtime_limit_up(self): self.safety.set_subaru_torque_driver(0, 0) diff --git a/tests/safety/test_toyota.py b/tests/safety/test_toyota.py index 2134d82091891e..5b650e9e858b6d 100644 --- a/tests/safety/test_toyota.py +++ b/tests/safety/test_toyota.py @@ -3,7 +3,7 @@ import numpy as np from panda import Panda from panda.tests.safety import libpandasafety_py -from panda.tests.safety.common import test_relay_malfunction, make_msg +from panda.tests.safety.common import test_relay_malfunction, make_msg, test_manually_enable_controls_allowed MAX_RATE_UP = 10 MAX_RATE_DOWN = 25 @@ -98,8 +98,7 @@ def test_default_controls_not_allowed(self): self.assertFalse(self.safety.get_controls_allowed()) def test_manually_enable_controls_allowed(self): - self.safety.set_controls_allowed(1) - self.assertTrue(self.safety.get_controls_allowed()) + test_manually_enable_controls_allowed(self) def test_enable_control_allowed_from_cruise(self): self.safety.safety_rx_hook(self._pcm_cruise_msg(False)) diff --git a/tests/safety/test_volkswagen.py b/tests/safety/test_volkswagen.py index 6e0c14da07703a..0cd1d68f4a5457 100644 --- a/tests/safety/test_volkswagen.py +++ b/tests/safety/test_volkswagen.py @@ -3,7 +3,7 @@ import numpy as np from panda import Panda from panda.tests.safety import libpandasafety_py -from panda.tests.safety.common import test_relay_malfunction, make_msg +from panda.tests.safety.common import test_relay_malfunction, make_msg, test_manually_enable_controls_allowed MAX_RATE_UP = 4 MAX_RATE_DOWN = 10 @@ -127,10 +127,7 @@ def test_steer_safety_check(self): self.assertTrue(self.safety.safety_tx_hook(self._torque_msg(t))) def test_manually_enable_controls_allowed(self): - self.safety.set_controls_allowed(1) - self.assertTrue(self.safety.get_controls_allowed()) - self.safety.set_controls_allowed(0) - self.assertFalse(self.safety.get_controls_allowed()) + test_manually_enable_controls_allowed(self) def test_spam_cancel_safety_check(self): BIT_CANCEL = 13