mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-23 21:53:51 +08:00
* add pytest-asyncio * switch common * switch selfdrive * switch system * switch tools * small fixes * fix setUp and valgrind pytest * switch to setup * fix random * switch mock * switch test_lateral_limits * revert test_ui * fix poetry.lock * add unittest to banned-api * add inline ignores to remaining unittest imports * revert test_models * revert check_can_parser_performance * one more skip --------- Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
30 lines
1.4 KiB
Python
Executable File
30 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import copy
|
|
from hypothesis import given, HealthCheck, Phase, settings
|
|
import hypothesis.strategies as st
|
|
from parameterized import parameterized
|
|
|
|
from cereal import log
|
|
from openpilot.selfdrive.car.toyota.values import CAR as TOYOTA
|
|
from openpilot.selfdrive.test.fuzzy_generation import FuzzyGenerator
|
|
import openpilot.selfdrive.test.process_replay.process_replay as pr
|
|
|
|
# These processes currently fail because of unrealistic data breaking assumptions
|
|
# that openpilot makes causing error with NaN, inf, int size, array indexing ...
|
|
# TODO: Make each one testable
|
|
NOT_TESTED = ['controlsd', 'plannerd', 'calibrationd', 'dmonitoringd', 'paramsd', 'dmonitoringmodeld', 'modeld']
|
|
|
|
TEST_CASES = [(cfg.proc_name, copy.deepcopy(cfg)) for cfg in pr.CONFIGS if cfg.proc_name not in NOT_TESTED]
|
|
|
|
class TestFuzzProcesses:
|
|
|
|
# TODO: make this faster and increase examples
|
|
@parameterized.expand(TEST_CASES)
|
|
@given(st.data())
|
|
@settings(phases=[Phase.generate, Phase.target], max_examples=10, deadline=1000, suppress_health_check=[HealthCheck.too_slow, HealthCheck.data_too_large])
|
|
def test_fuzz_process(self, proc_name, cfg, data):
|
|
msgs = FuzzyGenerator.get_random_event_msg(data.draw, events=cfg.pubs, real_floats=True)
|
|
lr = [log.Event.new_message(**m).as_reader() for m in msgs]
|
|
cfg.timeout = 5
|
|
pr.replay_process(cfg, lr, fingerprint=TOYOTA.TOYOTA_COROLLA_TSS2, disable_progress=True)
|