fwt_software/tests/test_camerastall.cpp

28 lines
1.2 KiB
C++

#include <doctest/doctest.h>
#include "fgc/CameraStall.h"
using namespace fgc;
TEST_CASE("the first-frame limit never drops below 30 s and grows with exposure") {
CHECK(firstFrameLimitMs(0) == 30000);
CHECK(firstFrameLimitMs(5000) == 30000); // 5 ms: a daylight frame
CHECK(firstFrameLimitMs(9e6) == 3 * 9000 + 5000); // tower 111's 9 s auto-exposure ceiling
}
TEST_CASE("a stream that has never delivered waits, then restarts, then resets") {
// Within the limit: a slow first frame is not a stall.
CHECK(onNoFirstFrame(10000, 2.26e6, 0) == StallAction::Wait);
// Past it: restart - which production used never to do, so a stream stuck
// from its start stayed stuck (tower 111, 2026-09-24).
CHECK(onNoFirstFrame(31000, 5000, 0) == StallAction::Restart);
CHECK(onNoFirstFrame(31000, 5000, 1) == StallAction::Restart);
// Restarts are not helping: reboot the camera.
CHECK(onNoFirstFrame(31000, 5000, kRestartsBeforeReset) == StallAction::Reset);
}
TEST_CASE("a stale stream escalates to a reset once restarts stop working") {
CHECK(onRestartFailed(1) == StallAction::Restart);
CHECK(onRestartFailed(kRestartsBeforeReset) == StallAction::Reset);
}