Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions opendbc/car/tests/test_car_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import math
import hypothesis.strategies as st
import pytest
from functools import cache
from hypothesis import Phase, given, settings
from collections.abc import Callable
from typing import Any
Expand All @@ -27,7 +28,8 @@
MAX_EXAMPLES = int(os.environ.get('MAX_EXAMPLES', '15'))


def get_fuzzy_car_interface(car_name: str, draw: DrawType) -> CarInterfaceBase:
@cache
def get_fuzzy_strategy():
# Fuzzy CAN fingerprints and FW versions to test more states of the CarInterface
fingerprint_strategy = st.fixed_dictionaries({0: st.dictionaries(st.integers(min_value=0, max_value=0x800),
st.sampled_from(DLC_TO_LEN))})
Expand All @@ -44,8 +46,11 @@ def get_fuzzy_car_interface(car_name: str, draw: DrawType) -> CarInterfaceBase:
'car_fw': car_fw_strategy,
'alpha_long': st.booleans(),
})
return params_strategy


params: dict = draw(params_strategy)
def get_fuzzy_car_interface(car_name: str, draw: DrawType) -> CarInterfaceBase:
params: dict = draw(get_fuzzy_strategy())
# reduce search space by duplicating CAN fingerprints across all buses
params['fingerprints'] |= {key + 1: params['fingerprints'][0] for key in range(6)}

Expand Down
Loading