Skip to content

Commit

Permalink
tests: some speed optimizations (commaai#1181)
Browse files Browse the repository at this point in the history
* mock sleep via monotonic

* rm

* no need to generate 8 buses

* this doesn't actually make a big diff

* lower loop

* can reduce

* here too

* Revert "here too"

This reverts commit 06b4cad.

* Revert "can reduce"

This reverts commit 55cae02.
  • Loading branch information
sshane authored Aug 21, 2024
1 parent 06c51c1 commit f6f0674
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions opendbc/car/tests/test_fw_fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from opendbc.car.structs import CarParams
from opendbc.car.fingerprints import FW_VERSIONS
from opendbc.car.fw_versions import ESSENTIAL_ECUS, FW_QUERY_CONFIGS, FUZZY_EXCLUDE_ECUS, VERSIONS, build_fw_dict, \
match_fw_to_car, get_brand_ecu_matches, get_fw_versions, get_fw_versions_ordered, get_present_ecus
match_fw_to_car, get_brand_ecu_matches, get_fw_versions, get_present_ecus
from opendbc.car.vin import get_vin

CarFw = CarParams.CarFw
Expand All @@ -26,7 +26,7 @@ def assertFingerprints(self, candidates, expected):
def test_exact_match(self, brand, car_model, ecus, test_non_essential):
config = FW_QUERY_CONFIGS[brand]
CP = CarParams()
for _ in range(100):
for _ in range(20):
fw = []
for ecu, fw_versions in ecus.items():
# Assume non-essential ECUs apply to all cars, so we catch cases where Car A with
Expand Down Expand Up @@ -316,8 +316,15 @@ def test_get_fw_versions(self, subtests, mocker):
def fake_carlog_exception(*args, **kwargs):
raise

t = 0

def fake_monotonic():
nonlocal t
t += 0.0001
return t

mocker.patch("opendbc.car.carlog.exception", fake_carlog_exception)
get_fw_versions_ordered(self.fake_can_recv, self.fake_can_send, lambda obd: None, '0' * 17, set())
mocker.patch("time.monotonic", fake_monotonic)
for brand in FW_QUERY_CONFIGS.keys():
with subtests.test(brand=brand):
get_fw_versions(self.fake_can_recv, self.fake_can_send, lambda obd: None, brand)

0 comments on commit f6f0674

Please sign in to comment.