2024-06-11 01:36:40 +00:00
|
|
|
import cereal.messaging as messaging
|
|
|
|
|
2025-03-08 09:09:31 +00:00
|
|
|
from opendbc.car.toyota.values import CAR as TOYOTA
|
2024-06-11 01:36:40 +00:00
|
|
|
from openpilot.selfdrive.test.process_replay import replay_process_with_name
|
|
|
|
|
|
|
|
|
|
|
|
class TestLeads:
|
|
|
|
def test_radar_fault(self):
|
|
|
|
# if there's no radar-related can traffic, radard should either not respond or respond with an error
|
|
|
|
# this is tightly coupled with underlying car radar_interface implementation, but it's a good sanity check
|
|
|
|
def single_iter_pkg():
|
|
|
|
# single iter package, with meaningless cans and empty carState/modelV2
|
|
|
|
msgs = []
|
2025-03-08 09:09:31 +00:00
|
|
|
for _ in range(500):
|
2024-06-11 01:36:40 +00:00
|
|
|
can = messaging.new_message("can", 1)
|
|
|
|
cs = messaging.new_message("carState")
|
2025-03-08 09:09:31 +00:00
|
|
|
cp = messaging.new_message("carParams")
|
2024-06-11 01:36:40 +00:00
|
|
|
msgs.append(can.as_reader())
|
|
|
|
msgs.append(cs.as_reader())
|
2025-03-08 09:09:31 +00:00
|
|
|
msgs.append(cp.as_reader())
|
2024-06-11 01:36:40 +00:00
|
|
|
model = messaging.new_message("modelV2")
|
|
|
|
msgs.append(model.as_reader())
|
|
|
|
|
|
|
|
return msgs
|
|
|
|
|
|
|
|
msgs = [m for _ in range(3) for m in single_iter_pkg()]
|
2025-03-08 09:09:31 +00:00
|
|
|
out = replay_process_with_name("card", msgs, fingerprint=TOYOTA.TOYOTA_COROLLA_TSS2)
|
|
|
|
states = [m for m in out if m.which() == "liveTracks"]
|
|
|
|
failures = [not state.valid and len(state.liveTracks.errors) for state in states]
|
2024-06-11 01:36:40 +00:00
|
|
|
|
|
|
|
assert len(states) == 0 or all(failures)
|