From 2a29778ae2c7af26cfc014d04dadf15b1c0a5c66 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 7 Mar 2024 00:14:56 -0800 Subject: [PATCH] HKG: test platform codes per platform (#31753) * test * clean up --- selfdrive/car/hyundai/tests/test_hyundai.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/selfdrive/car/hyundai/tests/test_hyundai.py b/selfdrive/car/hyundai/tests/test_hyundai.py index c7100d03f0..61b11a1992 100755 --- a/selfdrive/car/hyundai/tests/test_hyundai.py +++ b/selfdrive/car/hyundai/tests/test_hyundai.py @@ -98,6 +98,23 @@ class TestHyundaiFingerprint(unittest.TestCase): fws = data.draw(fw_strategy) get_platform_codes(fws) + def test_expected_platform_codes(self): + # Ensures we don't accidentally add multiple platform codes for a car unless it is intentional + for car_model, ecus in FW_VERSIONS.items(): + with self.subTest(car_model=car_model.value): + for ecu, fws in ecus.items(): + if ecu[0] not in PLATFORM_CODE_ECUS: + continue + + # Third and fourth character are usually EV/hybrid identifiers + codes = {code.split(b"-")[0][:2] for code, _ in get_platform_codes(fws)} + if car_model == CAR.PALISADE: + self.assertEqual(codes, {b"LX", b"ON"}, f"Car has unexpected platform codes: {car_model} {codes}") + elif car_model == CAR.KONA_EV and ecu[0] == Ecu.fwdCamera: + self.assertEqual(codes, {b"OE", b"OS"}, f"Car has unexpected platform codes: {car_model} {codes}") + else: + self.assertEqual(len(codes), 1, f"Car has multiple platform codes: {car_model} {codes}") + # Tests for platform codes, part numbers, and FW dates which Hyundai will use to fuzzy # fingerprint in the absence of full FW matches: def test_platform_code_ecus_available(self):