31TEST_CASE(
"ocam2KCtrl lifecycle entrypoints handle startup failures and POWERON logic",
"[ocam2KCtrl]" )
36 #ifdef OCAM2KCTRL_TEST_DOXYGEN_REF
42 SECTION(
"appStartup reports failure when the startup mode cannot be configured" )
46 app.m_startupMode =
"";
48 REQUIRE( app.appStartup() < 0 );
51 SECTION(
"appStartup reports failure when EDT startup cannot load the configured mode" )
55 configureStartupMode( app );
56 g_edtStubState.readcfgReturn = -1;
58 REQUIRE( app.appStartup() < 0 );
61 SECTION(
"appStartup succeeds once a startup mode and telemetry path are configured" )
64 startupScope startup( app );
66 configureStartupMode( app );
68 const int startupRv = app.appStartup();
69 startup.markStarted( startupRv == 0 );
71 REQUIRE( startupRv == 0 );
72 REQUIRE( app.m_temps.CCD == Approx( -999.0f ) );
75 SECTION(
"appLogic returns immediately while the app is still in POWERON and the wait has not elapsed" )
79 static_cast<MagAOXAppT &
>( app ).m_powerState = 1;
82 app.m_powerOnCounter = 0;
83 static_cast<MagAOXAppT &
>( app ).m_loopPause = 0;
84 fgThreadScope fgThread( app );
86 REQUIRE( app.appLogic() == 0 );
90 SECTION(
"appLogic returns an error if the framegrabber thread has already exited" )
92 auto *app =
new ocam2KCtrl_test;
95 app->m_powerTargetState = 1;
97 startFgThread( *app, 1 );
98 std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) );
100 REQUIRE( app->appLogic() == -1 );