mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-08-22 08:53:44 +08:00
camerad: stress test (#34735)
* refactor a bunch of stuff * prob * enable * rm print * cleanup --------- Co-authored-by: Comma Device <device@comma.ai>
This commit is contained in:
@@ -211,9 +211,9 @@ private:
|
||||
inline static bool first_frame_synced = false;
|
||||
|
||||
// a mode for stressing edge cases: realignment, sync failures, etc.
|
||||
inline bool stress_test(const char* log, float prob=0.02) {
|
||||
static bool enable = getenv("SPECTRA_STRESS_TEST") != nullptr;
|
||||
bool triggered = enable && ((static_cast<double>(rand()) / RAND_MAX) < prob);
|
||||
inline bool stress_test(const char* log) {
|
||||
static double prob = std::stod(util::getenv("SPECTRA_ERROR_PROB", "-1"));;
|
||||
bool triggered = (prob > 0) && ((static_cast<double>(rand()) / RAND_MAX) < prob);
|
||||
if (triggered) {
|
||||
LOGE("stress test (cam %d): %s", cc.camera_num, log);
|
||||
}
|
||||
|
||||
@@ -83,13 +83,12 @@ class TestCamerad:
|
||||
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)
|
||||
assert np.all((ts[c]['t'] - ts[c]['timestampSof']/1e9) > 1e-7)
|
||||
assert np.all((ts[c]['t'] - ts[c]['timestampEof']/1e9) > 1e-7)
|
||||
|
||||
@pytest.mark.skip("TODO: enable this")
|
||||
def test_stress_test(self):
|
||||
os.environ['SPECTRA_STRESS_TEST'] = '1'
|
||||
logs = run_and_log(["camerad", ], CAMERAS, 15)
|
||||
os.environ['SPECTRA_ERROR_PROB'] = '0.008'
|
||||
logs = run_and_log(["camerad", ], CAMERAS, 10)
|
||||
ts = msgs_to_time_series(logs)
|
||||
|
||||
# we should see some jumps from introduced errors
|
||||
|
||||
Reference in New Issue
Block a user