44 lines
2.0 KiB
C++
44 lines
2.0 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);
|
|
}
|
|
|
|
TEST_CASE("a slow next frame is not a stale stream") {
|
|
// Fast stream (5 ms exposure, 5 fps): the 2 s floor.
|
|
CHECK(staleFrameLimitMs(5000, 200) == 2000);
|
|
// Tower 111 at dusk: 9 s exposures, a frame every ~9 s.
|
|
CHECK(staleFrameLimitMs(9e6, 9000) == 2 * 9000 + 1000);
|
|
// A frame-rate cap slower than the exposure governs (night: 0.5 s at 0.215 fps).
|
|
CHECK(staleFrameLimitMs(5e5, 1000.0 / 0.215) == 2 * 4651 + 1000);
|
|
|
|
// Asked 8 s after the last frame of a 9 s exposure: wait for it, do not
|
|
// restart the stream and throw that exposure away (tower 111, 2026-10-04).
|
|
CHECK(onStaleFrame(8000, 9e6, 9000) == StallAction::Wait);
|
|
CHECK(onStaleFrame(20000, 9e6, 9000) == StallAction::Restart);
|
|
// A fast stream that has delivered nothing new for seconds is stale.
|
|
CHECK(onStaleFrame(2500, 5000, 200) == StallAction::Restart);
|
|
}
|