car interfaces: long running fuzzy test (#29592)

* draft

* draft 2

* increase deadline and run

* imports

* run -> use
pull/29591/head
Shane Smiskol 2 years ago committed by GitHub
parent 7bfd3dac81
commit 821cfff56d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      Jenkinsfile
  2. 9
      selfdrive/car/tests/test_car_interfaces.py

1
Jenkinsfile vendored

@ -160,6 +160,7 @@ pipeline {
sh "scons --clean && scons --no-cache --random -j42" sh "scons --clean && scons --no-cache --random -j42"
sh "INTERNAL_SEG_CNT=500 INTERNAL_SEG_LIST=selfdrive/car/tests/test_models_segs.txt FILEREADER_CACHE=1 \ sh "INTERNAL_SEG_CNT=500 INTERNAL_SEG_LIST=selfdrive/car/tests/test_models_segs.txt FILEREADER_CACHE=1 \
pytest -n42 --dist=loadscope selfdrive/car/tests/test_models.py" pytest -n42 --dist=loadscope selfdrive/car/tests/test_models.py"
sh "MAX_EXAMPLES=100 pytest -n42 selfdrive/car/tests/test_car_interfaces.py"
} }
post { post {

@ -3,7 +3,7 @@ import os
import math import math
import unittest import unittest
import hypothesis.strategies as st import hypothesis.strategies as st
from hypothesis import given, settings from hypothesis import Phase, given, settings
import importlib import importlib
from parameterized import parameterized from parameterized import parameterized
@ -18,6 +18,8 @@ from openpilot.selfdrive.test.fuzzy_generation import DrawType, FuzzyGenerator
ALL_ECUS = list({ecu for ecus in FW_VERSIONS.values() for ecu in ecus.keys()}) ALL_ECUS = list({ecu for ecus in FW_VERSIONS.values() for ecu in ecus.keys()})
MAX_EXAMPLES = int(os.environ.get('MAX_EXAMPLES', '5'))
def get_fuzzy_car_interface_args(draw: DrawType) -> dict: def get_fuzzy_car_interface_args(draw: DrawType) -> dict:
# Fuzzy CAN fingerprints and FW versions to test more states of the CarInterface # Fuzzy CAN fingerprints and FW versions to test more states of the CarInterface
@ -45,8 +47,11 @@ class TestCarInterfaces(unittest.TestCase):
def setUpClass(cls): def setUpClass(cls):
os.environ['NO_RADAR_SLEEP'] = '1' os.environ['NO_RADAR_SLEEP'] = '1'
# FIXME: Due to the lists used in carParams, Phase.target is very slow and will cause
# many generated examples to overrun when max_examples > ~20, don't use it
@parameterized.expand([(car,) for car in sorted(all_known_cars())]) @parameterized.expand([(car,) for car in sorted(all_known_cars())])
@settings(max_examples=5) @settings(max_examples=MAX_EXAMPLES, deadline=500,
phases=(Phase.reuse, Phase.generate, Phase.shrink))
@given(data=st.data()) @given(data=st.data())
def test_car_interfaces(self, car_name, data): def test_car_interfaces(self, car_name, data):
CarInterface, CarController, CarState = interfaces[car_name] CarInterface, CarController, CarState = interfaces[car_name]

Loading…
Cancel
Save