From aa5683bbce5b5e8e8414f5b90df9add3998e98ab Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 13 Jun 2023 12:50:02 -0700 Subject: [PATCH] common parts --- selfdrive/car/hyundai/tests/test_hyundai.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/selfdrive/car/hyundai/tests/test_hyundai.py b/selfdrive/car/hyundai/tests/test_hyundai.py index 98727264ce..482a9ca6f6 100755 --- a/selfdrive/car/hyundai/tests/test_hyundai.py +++ b/selfdrive/car/hyundai/tests/test_hyundai.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import unittest +from collections import defaultdict from cereal import car from selfdrive.car.hyundai.values import CAMERA_SCC_CAR, CANFD_CAR, CAN_GEARS, CAR, CHECKSUM, FW_QUERY_CONFIG, \ @@ -25,6 +26,26 @@ class TestHyundaiFingerprint(unittest.TestCase): ecu_strings = ", ".join([f'Ecu.{ECU_NAME[ecu]}' for ecu in ecus_not_in_whitelist]) self.assertEqual(len(ecus_not_in_whitelist), 0, f'{car_model}: Car model has ECUs not in auxiliary request whitelists: {ecu_strings}') + def test_shared_part_numbers(self): + all_part_numbers = defaultdict(set) + for car_model, ecus in FW_VERSIONS.items(): + with self.subTest(car_model=car_model): + if car_model == CAR.HYUNDAI_GENESIS: + raise unittest.SkipTest("No part numbers for car model") + + for ecu, fws in ecus.items(): + if ecu[0] not in FW_QUERY_CONFIG.platform_code_ecus: + continue + + for fw in fws: + match = PART_NUMBER_FW_PATTERN.search(fw) + all_part_numbers[(*ecu, match.group())].add(car_model) + self.assertIsNotNone(match, fw) + + for ecu, platforms in all_part_numbers.items(): + if len(platforms) > 1: + print('shared parts', (ECU_NAME[ecu[0]], ecu[1], ecu[2], ecu[3]), platforms) + def test_blacklisted_fws(self): blacklisted_fw = {(Ecu.fwdCamera, 0x7c4, None): [b'\xf1\x00NX4 FR_CMR AT USA LHD 1.00 1.00 99211-CW010 14X']} for car_model in FW_VERSIONS.keys():