From c964381ef77415a9b44f493242b2cb723a4ccc43 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 28 Jun 2023 22:10:44 -0700 Subject: [PATCH] Toyota: essential ECU test (#28737) * bump cereal * more queries (to see the new time) * fix * not sure what i want this to do yet not sure what i want this to do yet * no body * no body * add test * spacing * revert * check len * static fix * shorter cmt old-commit-hash: 3b8aec4b063faa3b806e27bcdbf7c9820bcb7a92 --- selfdrive/car/toyota/tests/test_toyota.py | 28 ++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/selfdrive/car/toyota/tests/test_toyota.py b/selfdrive/car/toyota/tests/test_toyota.py index 3d5eca1e0a..46e3fc2d27 100755 --- a/selfdrive/car/toyota/tests/test_toyota.py +++ b/selfdrive/car/toyota/tests/test_toyota.py @@ -1,7 +1,10 @@ #!/usr/bin/env python3 +from cereal import car import unittest -from selfdrive.car.toyota.values import DBC, TSS2_CAR, ANGLE_CONTROL_CAR +from selfdrive.car.toyota.values import CAR, DBC, TSS2_CAR, ANGLE_CONTROL_CAR, FW_VERSIONS + +Ecu = car.CarParams.Ecu class TestToyotaInterfaces(unittest.TestCase): @@ -11,10 +14,29 @@ class TestToyotaInterfaces(unittest.TestCase): def test_tss2_dbc(self): # We make some assumptions about TSS2 platforms, # like looking up certain signals only in this DBC - for car, dbc in DBC.items(): - if car in TSS2_CAR: + for car_model, dbc in DBC.items(): + if car_model in TSS2_CAR: self.assertEqual(dbc["pt"], "toyota_nodsu_pt_generated") + def test_essential_ecus(self): + # Asserts standard ECUs exist for each platform + common_ecus = {Ecu.fwdRadar, Ecu.fwdCamera} + for car_model, ecus in FW_VERSIONS.items(): + with self.subTest(car_model=car_model): + present_ecus = {ecu[0] for ecu in ecus} + missing_ecus = common_ecus - present_ecus + self.assertEqual(len(missing_ecus), 0) + + # Some exceptions for other common ECUs + if car_model not in (CAR.ALPHARD_TSS2,): + self.assertIn(Ecu.abs, present_ecus) + + if car_model not in (CAR.MIRAI,): + self.assertIn(Ecu.engine, present_ecus) + + if car_model not in (CAR.PRIUS_V, CAR.LEXUS_CTH): + self.assertIn(Ecu.eps, present_ecus) + if __name__ == "__main__": unittest.main()