camerad: sanity check tests (#34785)

lil more
pull/34786/head
Adeeb Shihadeh 2 months ago committed by GitHub
parent 65bf2ec0ea
commit f4d17cbfdd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      system/camerad/sensors/os04c10.cc
  2. 33
      system/camerad/test/test_camerad.py

@ -43,6 +43,9 @@ OS04C10::OS04C10() {
frame_data_type = 0x2c;
mclk_frequency = 24000000; // Hz
// TODO: this was set from logs. actually calculate it out
readout_time_ns = 11000000;
ev_scale = 150.0;
dc_gain_factor = 1;
dc_gain_min_weight = 1; // always on is fine

@ -64,7 +64,36 @@ class TestCamerad:
laggy_frames = {k: v for k, v in diffs.items() if v > 1.1}
assert len(laggy_frames) == 0, f"Frames not synced properly: {laggy_frames=}"
def test_sanity_checks(self, logs):
self._sanity_checks(logs)
def _sanity_checks(self, ts):
for c in CAMERAS:
assert c in ts
assert len(ts[c]['t']) > 20
# not a valid request id
assert 0 not in ts[c]['requestId']
# should monotonically increase
assert np.all(np.diff(ts[c]['frameId']) >= 1)
assert np.all(np.diff(ts[c]['requestId']) >= 1)
# EOF > SOF
assert np.all((ts[c]['timestampEof'] - ts[c]['timestampSof']) > 0)
# logMonoTime > SOF
assert np.all((ts[c]['t'] - ts[c]['timestampSof']/1e9) > 0.001)
assert np.all((ts[c]['t'] - ts[c]['timestampEof']/1e9) > 0.001)
@pytest.mark.skip("TODO: enable this")
def test_stress_test(self, logs):
def test_stress_test(self):
os.environ['SPECTRA_STRESS_TEST'] = '1'
run_and_log(["camerad", ], CAMERAS, 5)
logs = run_and_log(["camerad", ], CAMERAS, 15)
ts = msgs_to_time_series(logs)
# we should see some jumps from introduced errors
assert np.max([ np.max(np.diff(ts[c]['frameId'])) for c in CAMERAS ]) > 1
assert np.max([ np.max(np.diff(ts[c]['requestId'])) for c in CAMERAS ]) > 1
self._sanity_checks(ts)

Loading…
Cancel
Save