|
1 | 1 | import os |
2 | 2 | import math |
| 3 | +import pytest |
3 | 4 | from collections.abc import Callable |
4 | 5 | from typing import Any |
5 | 6 | from functools import lru_cache |
|
12 | 13 |
|
13 | 14 | MAX_EXAMPLES = int(os.environ.get('MAX_EXAMPLES', '15')) |
14 | 15 |
|
| 16 | +CAR_CHUNK_SIZE = int(os.environ.get('CAR_CHUNK_SIZE', '4')) |
| 17 | +CAR_BATCHES = int(os.environ.get('CAR_BATCHES', '128')) # overprovisioned |
| 18 | + |
15 | 19 |
|
16 | 20 | @lru_cache(maxsize=1) |
17 | 21 | def _get_all_ecus(): |
18 | | - """Lazy loader for ALL_ECUS""" |
19 | | - from opendbc.car.fingerprints import FW_VERSIONS |
20 | | - from opendbc.car.fw_versions import FW_QUERY_CONFIGS |
| 22 | + """Lazy loader for ALL_ECUS""" |
| 23 | + from opendbc.car.fingerprints import FW_VERSIONS |
| 24 | + from opendbc.car.fw_versions import FW_QUERY_CONFIGS |
21 | 25 |
|
22 | | - all_ecus = {ecu for ecus in FW_VERSIONS.values() for ecu in ecus.keys()} |
23 | | - all_ecus |= {ecu for config in FW_QUERY_CONFIGS.values() for ecu in config.extra_ecus} |
24 | | - return all_ecus |
| 26 | + all_ecus = {ecu for ecus in FW_VERSIONS.values() for ecu in ecus.keys()} |
| 27 | + all_ecus |= {ecu for config in FW_QUERY_CONFIGS.values() for ecu in config.extra_ecus} |
| 28 | + return all_ecus |
25 | 29 |
|
26 | 30 |
|
27 | 31 | @lru_cache(maxsize=1) |
28 | 32 | def _get_all_requests(): |
29 | | - """Lazy loader for ALL_REQUESTS""" |
30 | | - from opendbc.car.fw_versions import FW_QUERY_CONFIGS |
31 | | - return {tuple(r.request) for config in FW_QUERY_CONFIGS.values() for r in config.requests} |
| 33 | + """Lazy loader for ALL_REQUESTS""" |
| 34 | + from opendbc.car.fw_versions import FW_QUERY_CONFIGS |
| 35 | + return {tuple(r.request) for config in FW_QUERY_CONFIGS.values() for r in config.requests} |
| 36 | + |
| 37 | + |
| 38 | +@pytest.fixture(scope="session") |
| 39 | +def _platform_list(): |
| 40 | + from opendbc.car.values import PLATFORMS |
| 41 | + return sorted(PLATFORMS) |
32 | 42 |
|
33 | 43 |
|
34 | 44 | class TestCarInterfaces: |
35 | | - def test_car_interfaces(self, subtests): |
| 45 | + _PARAM_RANGE = range(CAR_BATCHES) |
| 46 | + |
| 47 | + @pytest.mark.parametrize("car_batch_idx", _PARAM_RANGE) |
| 48 | + def test_car_interfaces(self, car_batch_idx, _platform_list, subtests): |
36 | 49 | import hypothesis.strategies as st |
37 | 50 | from hypothesis import Phase, given, settings |
38 | 51 | from opendbc.car.interfaces import CarInterfaceBase |
@@ -137,8 +150,13 @@ def run_car_interface_test(data, car_name: str): |
137 | 150 | rr = radar_interface.update(cans) |
138 | 151 | assert rr is None or len(rr.errors) > 0 |
139 | 152 |
|
140 | | - from opendbc.car.values import PLATFORMS |
141 | | - for car_name in sorted(PLATFORMS): |
| 153 | + start = car_batch_idx * CAR_CHUNK_SIZE |
| 154 | + end = start + CAR_CHUNK_SIZE |
| 155 | + car_batch = _platform_list[start:end] |
| 156 | + if not car_batch: |
| 157 | + pytest.skip(f"No cars in batch {car_batch_idx}") |
| 158 | + |
| 159 | + for car_name in car_batch: |
142 | 160 | with subtests.test(car_name=car_name): |
143 | 161 | run_car_interface_test(car_name=car_name) |
144 | 162 |
|
|
0 commit comments