|
5 | 5 | from parameterized import parameterized
|
6 | 6 |
|
7 | 7 | from cereal import car
|
| 8 | +from openpilot.selfdrive.car import make_can_msg |
8 | 9 | from openpilot.selfdrive.car.car_helpers import interfaces
|
9 | 10 | from openpilot.selfdrive.car.fingerprints import FW_VERSIONS
|
10 | 11 | from openpilot.selfdrive.car.fw_versions import ESSENTIAL_ECUS, FW_QUERY_CONFIGS, FUZZY_EXCLUDE_ECUS, VERSIONS, build_fw_dict, \
|
11 | 12 | match_fw_to_car, get_brand_ecu_matches, get_fw_versions, get_present_ecus
|
12 | 13 | from openpilot.selfdrive.car.vin import get_vin
|
| 14 | +from openpilot.selfdrive.pandad import can_list_to_can_capnp |
13 | 15 |
|
14 | 16 | CarFw = car.CarParams.CarFw
|
15 | 17 | Ecu = car.CarParams.Ecu
|
|
19 | 21 |
|
20 | 22 | class FakeSocket:
|
21 | 23 | 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) |
23 | 26 |
|
24 | 27 | def send(self, msg):
|
25 | 28 | pass
|
@@ -313,3 +316,18 @@ def test_fw_query_timing(self, subtests, mocker):
|
313 | 316 | total_time = round(total_times[num_pandas], 2)
|
314 | 317 | self._assert_timing(total_time, total_ref_time[num_pandas])
|
315 | 318 | 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