more robust fingerprint test

old-commit-hash: dc371f951a
commatwo_master
Adeeb Shihadeh 5 years ago
parent d84ede9f00
commit 412fb8c2f2
  1. 32
      selfdrive/car/tests/test_fw_fingerprint.py

@ -6,7 +6,6 @@ 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
from selfdrive.car.toyota.values import CAR as TOYOTA
CarFw = car.CarParams.CarFw
Ecu = car.CarParams.Ecu
@ -19,42 +18,15 @@ class TestFwFingerprint(unittest.TestCase):
self.assertEqual(len(candidates), 1, f"got more than one candidate: {candidates}")
self.assertEqual(candidates[0], expected)
def test_rav4_tss2(self):
CP = car.CarParams.new_message()
CP.carFw = [
{"ecu": Ecu.esp,
"fwVersion": b"\x01F15260R210\x00\x00\x00\x00\x00\x00",
"address": 1968,
"subAddress": 0},
{"ecu": Ecu.engine,
"fwVersion": b"\x028966342Y8000\x00\x00\x00\x00897CF1201001\x00\x00\x00\x00",
"address": 1792,
"subAddress": 0},
{"ecu": Ecu.eps,
"fwVersion": b"\x028965B0R01200\x00\x00\x00\x008965B0R02200\x00\x00\x00\x00",
"address": 1953,
"subAddress": 0},
{"ecu": Ecu.fwdRadar,
"fwVersion": b"\x018821F3301200\x00\x00\x00\x00",
"address": 1872,
"subAddress": 15},
{"ecu": Ecu.fwdCamera,
"fwVersion": b"\x028646F4203300\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00",
"address": 1872,
"subAddress": 109}
]
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(self, car_model, ecus):
CP = car.CarParams.new_message()
for _ in range(20):
for _ in range(200):
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})
"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)

Loading…
Cancel
Save