From f998cad2afb3d9425fc79d205dce122b8fc9f387 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 2 Jun 2023 19:19:47 -0700 Subject: [PATCH] clean up test --- selfdrive/car/hyundai/tests/test_hyundai.py | 34 +++------------------ 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/selfdrive/car/hyundai/tests/test_hyundai.py b/selfdrive/car/hyundai/tests/test_hyundai.py index 0d2e48dbed..e32b96768d 100755 --- a/selfdrive/car/hyundai/tests/test_hyundai.py +++ b/selfdrive/car/hyundai/tests/test_hyundai.py @@ -75,8 +75,6 @@ class TestHyundaiFingerprint(unittest.TestCase): CAR.KIA_SPORTAGE_5TH_GEN, ] - # platform_codes = defaultdict(lambda: defaultdict(set)) - platform_codes = defaultdict(dict) all_platform_codes = defaultdict(set) for candidate, fw_by_addr in FW_VERSIONS.items(): for addr, fws in fw_by_addr.items(): @@ -85,47 +83,25 @@ class TestHyundaiFingerprint(unittest.TestCase): for platform_code in FW_QUERY_CONFIG.fuzzy_get_platform_codes(fws): all_platform_codes[(addr[1], addr[2], platform_code)].add(candidate) - # for f in fws: - # # Add platform codes to lookup dict if config specifies a function - # platform_codes = FW_QUERY_CONFIG.fuzzy_get_platform_codes([f]) - # # if len(platform_codes) == 1: - # all_platform_codes[(addr[1], addr[2], list(platform_codes)[0])].add(candidate) - - # print(all_platform_codes) - # raise Exception + platforms_with_shared_codes = [] - for platform, ecus in FW_VERSIONS.items(): + for platform, fw_by_addr in FW_VERSIONS.items(): shared_codes = [] - for addr, fws in ecus.items(): + for addr, fws in fw_by_addr.items(): if addr[0] not in FW_QUERY_CONFIG.fuzzy_ecus: continue for f in fws: - # if len(platform_codes) == 1: platform_code = list(FW_QUERY_CONFIG.fuzzy_get_platform_codes([f]))[0] shared_codes.append(len(all_platform_codes[(addr[1], addr[2], platform_code)]) > 1) - print(platform, shared_codes, not all(shared_codes)) + if all(shared_codes): platforms_with_shared_codes.append(platform) + print(platforms_with_shared_codes) # make sure list is unique self.assertEqual(len(platforms_with_shared_codes), len(set(platforms_with_shared_codes))) self.assertEqual(set(platforms_with_shared_codes), set(excluded_platforms)) - # if platform != CAR.HYUNDAI_GENESIS: - # platform_codes[Ecu.fwdRadar][platform] = FW_QUERY_CONFIG.fuzzy_get_platform_codes(ecus[(Ecu.fwdRadar, 0x7d0, None)]) - # platform_codes[Ecu.fwdCamera][platform] = FW_QUERY_CONFIG.fuzzy_get_platform_codes(ecus[(Ecu.fwdCamera, 0x7c4, None)]) - # - # for ecu in [Ecu.fwdRadar, Ecu.fwdCamera]: # TODO: use fuzzy_ecus - # for platform in platform_codes.keys(): - # pass - # # print(platform_codes.values()) - # print(platform_codes[ecu].values()) - # print(set.union(*platform_codes[ecu].values())) - # print() - # # for platform in platform_codes.keys(): - # # print(platform_codes.keys()) - # - # # print(platform_codes.values()) if __name__ == "__main__":