mirror of
https://github.com/commaai/opendbc.git
synced 2026-06-08 06:04:45 +08:00
@@ -1,8 +1,10 @@
|
||||
import unittest
|
||||
|
||||
from opendbc.can import CANDefine
|
||||
from opendbc.can.tests import ALL_DBCS
|
||||
|
||||
|
||||
class TestCANDefine:
|
||||
class TestCANDefine(unittest.TestCase):
|
||||
def test_civic(self):
|
||||
|
||||
dbc_file = "honda_civic_touring_2016_can_generated"
|
||||
@@ -20,8 +22,8 @@ class TestCANDefine:
|
||||
0: 'NORMAL'}
|
||||
}
|
||||
|
||||
def test_all_dbcs(self, subtests):
|
||||
def test_all_dbcs(self):
|
||||
# Asserts no exceptions on all DBCs
|
||||
for dbc in ALL_DBCS:
|
||||
with subtests.test(dbc=dbc):
|
||||
with self.subTest(dbc=dbc):
|
||||
CANDefine(dbc)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import re
|
||||
import unittest
|
||||
|
||||
from opendbc.car.honda.fingerprints import FW_VERSIONS
|
||||
from opendbc.car.honda.values import HONDA_BOSCH, HONDA_BOSCH_TJA_CONTROL
|
||||
@@ -6,7 +7,7 @@ from opendbc.car.honda.values import HONDA_BOSCH, HONDA_BOSCH_TJA_CONTROL
|
||||
HONDA_FW_VERSION_RE = br"[A-Z0-9]{5}-[A-Z0-9]{3}(-|,)[A-Z0-9]{4}(\x00){2}$"
|
||||
|
||||
|
||||
class TestHondaFingerprint:
|
||||
class TestHondaFingerprint(unittest.TestCase):
|
||||
def test_fw_version_format(self):
|
||||
# Asserts all FW versions follow an expected format
|
||||
for fw_by_ecu in FW_VERSIONS.values():
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import unittest
|
||||
|
||||
from opendbc.car.rivian.fingerprints import FW_VERSIONS
|
||||
from opendbc.car.rivian.values import CAR, FW_QUERY_CONFIG, WMI, ModelLine, ModelYear
|
||||
|
||||
|
||||
class TestRivian:
|
||||
def test_custom_fuzzy_fingerprinting(self, subtests):
|
||||
class TestRivian(unittest.TestCase):
|
||||
def test_custom_fuzzy_fingerprinting(self):
|
||||
for platform in CAR:
|
||||
with subtests.test(platform=platform.name):
|
||||
with self.subTest(platform=platform.name):
|
||||
for wmi in WMI:
|
||||
for line in ModelLine:
|
||||
for year in ModelYear:
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import unittest
|
||||
|
||||
from opendbc.car.subaru.fingerprints import FW_VERSIONS
|
||||
|
||||
|
||||
class TestSubaruFingerprint:
|
||||
class TestSubaruFingerprint(unittest.TestCase):
|
||||
def test_fw_version_format(self):
|
||||
for platform, fws_per_ecu in FW_VERSIONS.items():
|
||||
for (ecu, _, _), fws in fws_per_ecu.items():
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import re
|
||||
import unittest
|
||||
|
||||
from opendbc.car import gen_empty_fingerprint
|
||||
from opendbc.car.structs import CarParams
|
||||
from opendbc.car.tesla.interface import CarInterface
|
||||
@@ -52,7 +54,7 @@ FSD_14_FW_RULE = {
|
||||
}
|
||||
|
||||
|
||||
class TestTeslaFingerprint:
|
||||
class TestTeslaFingerprint(unittest.TestCase):
|
||||
def test_fw_platform_code(self):
|
||||
# Every EPS FW must parse and its platform letter must match the car it's filed under.
|
||||
for car_model, ecus in FW_VERSIONS.items():
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import unittest
|
||||
|
||||
from hypothesis import given, settings, strategies as st
|
||||
|
||||
from opendbc.car import Bus
|
||||
@@ -16,7 +18,7 @@ def check_fw_version(fw_version: bytes) -> bool:
|
||||
return b'?' not in fw_version and b'!' not in fw_version
|
||||
|
||||
|
||||
class TestToyotaInterfaces:
|
||||
class TestToyotaInterfaces(unittest.TestCase):
|
||||
def test_car_sets(self):
|
||||
# Angle and radar-ACC cars are always TSS2 cars
|
||||
assert len(ANGLE_CONTROL_CAR - TSS2_CAR) == 0
|
||||
@@ -33,11 +35,11 @@ class TestToyotaInterfaces:
|
||||
if car_model in TSS2_CAR and car_model not in SECOC_CAR:
|
||||
assert dbc[Bus.pt] == "toyota_nodsu_pt_generated"
|
||||
|
||||
def test_essential_ecus(self, subtests):
|
||||
def test_essential_ecus(self):
|
||||
# Asserts standard ECUs exist for each platform
|
||||
common_ecus = {Ecu.fwdRadar, Ecu.fwdCamera}
|
||||
for car_model, ecus in FW_VERSIONS.items():
|
||||
with subtests.test(car_model=car_model.value):
|
||||
with self.subTest(car_model=car_model.value):
|
||||
present_ecus = {ecu[0] for ecu in ecus}
|
||||
missing_ecus = common_ecus - present_ecus
|
||||
assert len(missing_ecus) == 0
|
||||
@@ -53,19 +55,19 @@ class TestToyotaInterfaces:
|
||||
assert Ecu.eps in present_ecus
|
||||
|
||||
|
||||
class TestToyotaFingerprint:
|
||||
def test_non_essential_ecus(self, subtests):
|
||||
class TestToyotaFingerprint(unittest.TestCase):
|
||||
def test_non_essential_ecus(self):
|
||||
# Ensures only the cars that have multiple engine ECUs are in the engine non-essential ECU list
|
||||
for car_model, ecus in FW_VERSIONS.items():
|
||||
with subtests.test(car_model=car_model.value):
|
||||
with self.subTest(car_model=car_model.value):
|
||||
engine_ecus = {ecu for ecu in ecus if ecu[0] == Ecu.engine}
|
||||
assert (len(engine_ecus) > 1) == (car_model in FW_QUERY_CONFIG.non_essential_ecus[Ecu.engine]), \
|
||||
f"Car model unexpectedly {'not ' if len(engine_ecus) > 1 else ''}in non-essential list"
|
||||
|
||||
def test_valid_fw_versions(self, subtests):
|
||||
def test_valid_fw_versions(self):
|
||||
# Asserts all FW versions are valid
|
||||
for car_model, ecus in FW_VERSIONS.items():
|
||||
with subtests.test(car_model=car_model.value):
|
||||
with self.subTest(car_model=car_model.value):
|
||||
for fws in ecus.values():
|
||||
for fw in fws:
|
||||
assert check_fw_version(fw), fw
|
||||
@@ -79,10 +81,10 @@ class TestToyotaFingerprint:
|
||||
fws = data.draw(fw_strategy)
|
||||
get_platform_codes(fws)
|
||||
|
||||
def test_platform_code_ecus_available(self, subtests):
|
||||
def test_platform_code_ecus_available(self):
|
||||
# Asserts ECU keys essential for fuzzy fingerprinting are available on all platforms
|
||||
for car_model, ecus in FW_VERSIONS.items():
|
||||
with subtests.test(car_model=car_model.value):
|
||||
with self.subTest(car_model=car_model.value):
|
||||
for platform_code_ecu in PLATFORM_CODE_ECUS:
|
||||
if platform_code_ecu == Ecu.eps and car_model in (CAR.TOYOTA_PRIUS_V, CAR.LEXUS_CTH,):
|
||||
continue
|
||||
@@ -90,14 +92,14 @@ class TestToyotaFingerprint:
|
||||
continue
|
||||
assert platform_code_ecu in [e[0] for e in ecus]
|
||||
|
||||
def test_fw_format(self, subtests):
|
||||
def test_fw_format(self):
|
||||
# Asserts:
|
||||
# - every supported ECU FW version returns one platform code
|
||||
# - every supported ECU FW version has a part number
|
||||
# - expected parsing of ECU sub-versions
|
||||
|
||||
for car_model, ecus in FW_VERSIONS.items():
|
||||
with subtests.test(car_model=car_model.value):
|
||||
with self.subTest(car_model=car_model.value):
|
||||
for ecu, fws in ecus.items():
|
||||
if ecu[0] not in PLATFORM_CODE_ECUS:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user