Toyota: check FW valid (#31898)

* basic check

* basic check

* fix
old-commit-hash: 9d5c70fbc9
pull/32199/head
Shane Smiskol 1 year ago committed by GitHub
parent bf4ff54d76
commit 59421a0835
  1. 12
      selfdrive/car/toyota/tests/test_toyota.py

@ -13,6 +13,10 @@ Ecu = car.CarParams.Ecu
ECU_NAME = {v: k for k, v in Ecu.schema.enumerants.items()} ECU_NAME = {v: k for k, v in Ecu.schema.enumerants.items()}
def check_fw_version(fw_version: bytes) -> bool:
return b'?' not in fw_version
class TestToyotaInterfaces(unittest.TestCase): class TestToyotaInterfaces(unittest.TestCase):
def test_car_sets(self): def test_car_sets(self):
self.assertTrue(len(ANGLE_CONTROL_CAR - TSS2_CAR) == 0) self.assertTrue(len(ANGLE_CONTROL_CAR - TSS2_CAR) == 0)
@ -59,6 +63,14 @@ class TestToyotaFingerprint(unittest.TestCase):
car_model in FW_QUERY_CONFIG.non_essential_ecus[Ecu.engine], car_model in FW_QUERY_CONFIG.non_essential_ecus[Ecu.engine],
f"Car model unexpectedly {'not ' if len(engine_ecus) > 1 else ''}in non-essential list") f"Car model unexpectedly {'not ' if len(engine_ecus) > 1 else ''}in non-essential list")
def test_valid_fw_versions(self):
# Asserts all FW versions are valid
for car_model, ecus in FW_VERSIONS.items():
with self.subTest(car_model=car_model.value):
for fws in ecus.values():
for fw in fws:
self.assertTrue(check_fw_version(fw), fw)
# Tests for part numbers, platform codes, and sub-versions which Toyota will use to fuzzy # Tests for part numbers, platform codes, and sub-versions which Toyota will use to fuzzy
# fingerprint in the absence of full FW matches: # fingerprint in the absence of full FW matches:
@settings(max_examples=100) @settings(max_examples=100)

Loading…
Cancel
Save