Skip to content

Commit bf8315b

Browse files
committed
add the test
fix
1 parent d6d296b commit bf8315b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

selfdrive/car/tests/test_fw_fingerprint.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
from parameterized import parameterized
66

77
from cereal import car
8+
from openpilot.selfdrive.car import make_can_msg
89
from openpilot.selfdrive.car.car_helpers import interfaces
910
from openpilot.selfdrive.car.fingerprints import FW_VERSIONS
1011
from openpilot.selfdrive.car.fw_versions import ESSENTIAL_ECUS, FW_QUERY_CONFIGS, FUZZY_EXCLUDE_ECUS, VERSIONS, build_fw_dict, \
1112
match_fw_to_car, get_brand_ecu_matches, get_fw_versions, get_present_ecus
1213
from openpilot.selfdrive.car.vin import get_vin
14+
from openpilot.selfdrive.pandad import can_list_to_can_capnp
1315

1416
CarFw = car.CarParams.CarFw
1517
Ecu = car.CarParams.Ecu
@@ -19,7 +21,8 @@
1921

2022
class FakeSocket:
2123
def receive(self, non_blocking=False):
22-
pass
24+
return (can_list_to_can_capnp([make_can_msg(random.randint(0x600, 0x800), b'\x00' * 8, 0)])
25+
if random.uniform(0, 1) > 0.5 else None)
2326

2427
def send(self, msg):
2528
pass
@@ -313,3 +316,18 @@ def test_fw_query_timing(self, subtests, mocker):
313316
total_time = round(total_times[num_pandas], 2)
314317
self._assert_timing(total_time, total_ref_time[num_pandas])
315318
print(f'all brands, total FW query time={total_time} seconds')
319+
320+
def test_get_fw_versions(self, subtests, mocker):
321+
# some coverage on IsoTpParallelQuery and panda UDS library
322+
# TODO: replace this with full fingerprint simulation testing
323+
# https://github.com/commaai/panda/pull/1329
324+
325+
def fake_cloudlog_exception(*args, **kwargs):
326+
raise
327+
328+
mocker.patch("openpilot.selfdrive.car.fw_versions.set_obd_multiplexing", lambda *args: None)
329+
mocker.patch("openpilot.common.swaglog.cloudlog.exception", fake_cloudlog_exception)
330+
fake_socket = FakeSocket()
331+
for brand in FW_QUERY_CONFIGS.keys():
332+
with subtests.test(brand=brand):
333+
get_fw_versions(fake_socket, fake_socket, brand, num_pandas=1)

0 commit comments

Comments
 (0)