safety tests: use rx/tx helpers (#1399)

use rx/tx helpers
This commit is contained in:
Shane Smiskol
2023-05-04 04:09:09 +00:00
committed by GitHub
parent 3a64b6ccb5
commit b44df8151a
3 changed files with 9 additions and 9 deletions

View File

@@ -865,15 +865,15 @@ class PandaSafetyTest(PandaSafetyTestBase):
self.assertFalse(self.safety.get_vehicle_moving())
# not moving
self.safety.safety_rx_hook(self._vehicle_moving_msg(0))
self._rx(self._vehicle_moving_msg(0))
self.assertFalse(self.safety.get_vehicle_moving())
# speed is at threshold
self.safety.safety_rx_hook(self._vehicle_moving_msg(self.STANDSTILL_THRESHOLD))
self._rx(self._vehicle_moving_msg(self.STANDSTILL_THRESHOLD))
self.assertFalse(self.safety.get_vehicle_moving())
# past threshold
self.safety.safety_rx_hook(self._vehicle_moving_msg(self.STANDSTILL_THRESHOLD + 1))
self._rx(self._vehicle_moving_msg(self.STANDSTILL_THRESHOLD + 1))
self.assertTrue(self.safety.get_vehicle_moving())
def test_tx_hook_on_wrong_safety_mode(self):

View File

@@ -141,10 +141,10 @@ class HyundaiLongitudinalBase(common.LongitudinalAccelSafetyTest):
addr, bus = self.DISABLED_ECU_UDS_MSG
tester_present = libpanda_py.make_CANPacket(addr, bus, b"\x02\x3E\x80\x00\x00\x00\x00\x00")
self.assertTrue(self.safety.safety_tx_hook(tester_present))
self.assertTrue(self._tx(tester_present))
not_tester_present = libpanda_py.make_CANPacket(addr, bus, b"\x03\xAA\xAA\x00\x00\x00\x00\x00")
self.assertFalse(self.safety.safety_tx_hook(not_tester_present))
self.assertFalse(self._tx(not_tester_present))
def test_disabled_ecu_alive(self):
"""

View File

@@ -297,7 +297,7 @@ class TestHondaNidecSafetyBase(HondaBase):
for pcm_gas in range(0, 255):
for pcm_speed in range(0, 100):
send = pcm_gas <= self.MAX_GAS if controls_allowed else pcm_gas == 0 and pcm_speed == 0
self.assertEqual(send, self.safety.safety_tx_hook(self._send_acc_hud_msg(pcm_gas, pcm_speed)))
self.assertEqual(send, self._tx(self._send_acc_hud_msg(pcm_gas, pcm_speed)))
def test_fwd_hook(self):
# normal operation, not forwarding AEB
@@ -483,10 +483,10 @@ class TestHondaBoschLongSafety(HondaButtonEnableBase, TestHondaBoschSafetyBase):
def test_diagnostics(self):
tester_present = libpanda_py.make_CANPacket(0x18DAB0F1, self.PT_BUS, b"\x02\x3E\x80\x00\x00\x00\x00\x00")
self.assertTrue(self.safety.safety_tx_hook(tester_present))
self.assertTrue(self._tx(tester_present))
not_tester_present = libpanda_py.make_CANPacket(0x18DAB0F1, self.PT_BUS, b"\x03\xAA\xAA\x00\x00\x00\x00\x00")
self.assertFalse(self.safety.safety_tx_hook(not_tester_present))
self.assertFalse(self._tx(not_tester_present))
def test_radar_alive(self):
# If the radar knockout failed, make sure the relay malfunction is shown
@@ -500,7 +500,7 @@ class TestHondaBoschLongSafety(HondaButtonEnableBase, TestHondaBoschSafetyBase):
accel = 0 if gas < 0 else gas / 1000
self.safety.set_controls_allowed(controls_allowed)
send = gas <= self.MAX_GAS if controls_allowed else gas == self.NO_GAS
self.assertEqual(send, self.safety.safety_tx_hook(self._send_gas_brake_msg(gas, accel)), (controls_allowed, gas, accel))
self.assertEqual(send, self._tx(self._send_gas_brake_msg(gas, accel)), (controls_allowed, gas, accel))
def test_brake_safety_check(self):
for controls_allowed in [True, False]: