mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 17:43:54 +08:00
test each model fingerprints with FW fingerprinting (#1769)
* test each model fingerprints with FW fingerprinting
* lock
* test for all
old-commit-hash: b44569284a
This commit is contained in:
@@ -72,7 +72,8 @@ RUN pyenv install 3.8.2 && \
|
||||
azure-storage-nspkg==3.1.0 \
|
||||
pycurl==7.43.0.3 \
|
||||
coverage==5.1 \
|
||||
pre-commit==2.4.0
|
||||
pre-commit==2.4.0 \
|
||||
parameterized==0.7.4
|
||||
|
||||
RUN mkdir -p /tmp/openpilot
|
||||
|
||||
|
||||
4
Pipfile
4
Pipfile
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:df64128a2c440dcebf11649fd64d8d2dcb0c6545467c108979a575799d632d38
|
||||
size 1960
|
||||
oid sha256:03a69ace0d3ec21dacbfbbcad17688191d4f022a519e5447cda33922fb677e24
|
||||
size 1980
|
||||
|
||||
4
Pipfile.lock
generated
4
Pipfile.lock
generated
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:320ca807bda4f25e11681e22847df19e4fcd2857bc207d01f1d446e68a945064
|
||||
size 170762
|
||||
oid sha256:88300c38c21842e55204a6e351985dfcb0c24b1e882432698472dbdc378cd9f8
|
||||
size 171081
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
import random
|
||||
import unittest
|
||||
from itertools import product
|
||||
from parameterized import parameterized
|
||||
|
||||
from cereal import car
|
||||
from selfdrive.car.fingerprints import FW_VERSIONS
|
||||
from selfdrive.car.fw_versions import match_fw_to_car
|
||||
@@ -14,7 +18,7 @@ class TestFwFingerprint(unittest.TestCase):
|
||||
def assertFingerprints(self, candidates, expected):
|
||||
candidates = list(candidates)
|
||||
self.assertEqual(len(candidates), 1)
|
||||
self.assertEqual(candidates[0], TOYOTA.RAV4_TSS2)
|
||||
self.assertEqual(candidates[0], expected)
|
||||
|
||||
def test_rav4_tss2(self):
|
||||
CP = car.CarParams.new_message()
|
||||
@@ -43,13 +47,42 @@ class TestFwFingerprint(unittest.TestCase):
|
||||
|
||||
self.assertFingerprints(match_fw_to_car(CP.carFw), TOYOTA.RAV4_TSS2)
|
||||
|
||||
@parameterized.expand([(k, v) for k, v in FW_VERSIONS.items()])
|
||||
def test_fw_fingerprint_all(self, car_model, ecus):
|
||||
# TODO: this is too slow, so don't run for now
|
||||
return
|
||||
|
||||
ecu_fw_lists = [] # pylint: disable=W0101
|
||||
for ecu, fw_versions in ecus.items():
|
||||
ecu_name, addr, sub_addr = ecu
|
||||
ecu_fw_lists.append([])
|
||||
for fw in fw_versions:
|
||||
ecu_fw_lists[-1].append({"ecu": ecu_name, "fwVersion": fw, "address": addr,
|
||||
"subAddress": 0 if sub_addr is None else sub_addr})
|
||||
CP = car.CarParams.new_message()
|
||||
for car_fw in product(*ecu_fw_lists):
|
||||
CP.carFw = car_fw
|
||||
self.assertFingerprints(match_fw_to_car(CP.carFw), car_model)
|
||||
|
||||
@parameterized.expand([(k, v) for k, v in FW_VERSIONS.items()])
|
||||
def test_fw_fingerprint(self, car_model, ecus):
|
||||
CP = car.CarParams.new_message()
|
||||
for _ in range(20):
|
||||
fw = []
|
||||
for ecu, fw_versions in ecus.items():
|
||||
ecu_name, addr, sub_addr = ecu
|
||||
fw.append({"ecu": ecu_name, "fwVersion": random.choice(fw_versions),
|
||||
"address": addr, "subAddress": 0 if sub_addr is None else sub_addr})
|
||||
CP.carFw = fw
|
||||
self.assertFingerprints(match_fw_to_car(CP.carFw), car_model)
|
||||
|
||||
def test_no_duplicate_fw_versions(self):
|
||||
passed = True
|
||||
for car_name, ecus in FW_VERSIONS.items():
|
||||
for car_model, ecus in FW_VERSIONS.items():
|
||||
for ecu, ecu_fw in ecus.items():
|
||||
duplicates = set([fw for fw in ecu_fw if ecu_fw.count(fw) > 1])
|
||||
if len(duplicates):
|
||||
print(car_name, ECU_NAME[ecu[0]], duplicates)
|
||||
print(car_model, ECU_NAME[ecu[0]], duplicates)
|
||||
passed = False
|
||||
|
||||
self.assertTrue(passed, "Duplicate FW versions found")
|
||||
|
||||
Reference in New Issue
Block a user