update test fuzzy

pull/20845/head
Willem Melching 4 years ago
parent ab319d4f54
commit a0a1ed0cbc
  1. 29
      selfdrive/test/process_replay/test_fuzzy.py

@ -4,7 +4,7 @@ import unittest
import hypothesis.strategies as st
import numpy as np
from hypothesis import given, settings
from hypothesis import given, settings, note
from cereal import log
from selfdrive.car.toyota.values import CAR as TOYOTA
@ -57,27 +57,27 @@ def get_strategy_for_events(event_types, finite=False):
})
r['SensorEventData.SensorVec'] = st.fixed_dictionaries({
'v': st.lists(floats(width=32), min_size=3, max_size=3),
'status': st.integers(min_value=0, max_value=1),
'status': st.just(1),
})
r['SensorEventData_gyro'] = st.fixed_dictionaries({
'version': st.just(1),
'sensor': st.just(5),
'type': st.just(16), # BMX055
'type': st.just(16),
'timestamp': st.integers(min_value=0, max_value=2**63 - 1),
'source': st.just(8),
'source': st.just(8), # BMX055
'gyroUncalibrated': r['SensorEventData.SensorVec'],
})
r['SensorEventData_accel'] = st.fixed_dictionaries({
'version': st.just(1),
'sensor': st.just(1),
'type': st.just(1), # BMX055
'type': st.just(1),
'timestamp': st.integers(min_value=0, max_value=2**63 - 1),
'source': st.just(8),
'source': st.just(8), # BMX055
'acceleration': r['SensorEventData.SensorVec'],
})
r['SensorEvents'] = st.lists(st.one_of(r['SensorEventData_gyro'], r['SensorEventData_accel']), min_size=1)
r['GpsLocationExternal'] = st.fixed_dictionaries({
'flags': st.integers(min_value=0, max_value=1),
'flags': st.just(1),
'latitude': floats(),
'longitude': floats(),
'altitude': floats(),
@ -115,10 +115,13 @@ def is_finite(d, exclude=[], prefix=""): # pylint: disable=dangerous-default-va
continue
if isinstance(v, dict):
ret = ret and is_finite(v, exclude, name + ".")
if not is_finite(v, exclude, name + "."):
ret = False
else:
try:
ret = ret and np.isfinite(v).all()
if not np.isfinite(v).all():
note((name, v))
ret = False
except TypeError:
pass
@ -137,8 +140,8 @@ class TestFuzzy(unittest.TestCase):
@settings(deadline=1000)
def test_paramsd(self, dat):
for r in test_process(dat, 'paramsd'):
lp = r.liveParameters.to_dict()
assert is_finite(lp)
d = r.liveParameters.to_dict()
assert is_finite(d)
@given(get_strategy_for_process('locationd', finite=True))
@settings(deadline=1000)
@ -150,8 +153,8 @@ class TestFuzzy(unittest.TestCase):
'calibratedOrientationECEF.std',
]
for r in test_process(dat, 'locationd'):
lp = r.liveLocationKalman.to_dict()
assert is_finite(lp, exclude)
d = r.liveLocationKalman.to_dict()
assert is_finite(d, exclude)
if __name__ == "__main__":

Loading…
Cancel
Save