125 SECTION(
"complete run-through" )
127 std::vector<const char *> argv;
128 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
130 argv.resize( argvstr.size() + 1, NULL );
131 for(
size_t index = 0; index < argvstr.size(); ++index )
133 argv[index] = argvstr[index].c_str();
137 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
141 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
143 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
144 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/logs" );
145 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
146 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
149 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
152 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
153 {
"",
"power",
"power",
"power",
"power",
"power" },
154 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
155 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
157 XWCTEST_MAGAOXAPP_EXEC_NORM_ns::MagAOXApp_test app(
false );
158 app.setPowerMgtEnabled(
true );
159 app.invokedName() = argv[0];
161 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
163 int rv = app.execute();
167 SECTION(
"No log directory" )
169 std::vector<const char *> argv;
170 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
172 argv.resize( argvstr.size() + 1, NULL );
173 for(
size_t index = 0; index < argvstr.size(); ++index )
175 argv[index] = argvstr[index].c_str();
179 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
183 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
185 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
187 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
188 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
191 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
194 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
195 {
"",
"power",
"power",
"power",
"power",
"power" },
196 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
197 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
200 app.setPowerMgtEnabled(
true );
201 app.invokedName() = argv[0];
203 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
205 int rv = app.execute();
209 SECTION(
"wrong user" )
211 std::vector<const char *> argv;
212 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
214 argv.resize( argvstr.size() + 1, NULL );
215 for(
size_t index = 0; index < argvstr.size(); ++index )
217 argv[index] = argvstr[index].c_str();
221 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
225 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
227 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
228 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/logs" );
229 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
230 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
233 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
236 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
237 {
"",
"power",
"power",
"power",
"power",
"power" },
238 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
239 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
241 XWCTEST_MAGAOXAPP_EXEC_WRONG_USER_ns::MagAOXApp_test app(
false );
242 app.setPowerMgtEnabled(
true );
243 app.invokedName() = argv[0];
245 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
247 int rv = app.execute();
251 SECTION(
"PID Lock Error" )
253 std::vector<const char *> argv;
254 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
256 argv.resize( argvstr.size() + 1, NULL );
257 for(
size_t index = 0; index < argvstr.size(); ++index )
259 argv[index] = argvstr[index].c_str();
263 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
267 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
269 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
270 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/logs" );
271 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
272 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
275 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
278 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
279 {
"",
"power",
"power",
"power",
"power",
"power" },
280 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
281 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
283 XWCTEST_MAGAOXAPP_PID_WRITE_FAIL_ns::MagAOXApp_test app(
false );
284 app.setPowerMgtEnabled(
true );
285 app.invokedName() = argv[0];
287 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
289 int rv = app.execute();
293 SECTION(
"Log fails to start" )
295 std::vector<const char *> argv;
296 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
298 argv.resize( argvstr.size() + 1, NULL );
299 for(
size_t index = 0; index < argvstr.size(); ++index )
301 argv[index] = argvstr[index].c_str();
305 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
309 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
311 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
312 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/logs" );
313 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
314 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
317 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
320 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
321 {
"",
"power",
"power",
"power",
"power",
"power" },
322 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
323 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
325 XWCTEST_MAGAOXAPP_EXEC_LOG_START_ns::MagAOXApp_test app(
false );
326 app.setPowerMgtEnabled(
true );
327 app.invokedName() = argv[0];
329 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
331 int rv = app.execute();
335 SECTION(
"Setting sigterm handler fails" )
337 std::vector<const char *> argv;
338 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
340 argv.resize( argvstr.size() + 1, NULL );
341 for(
size_t index = 0; index < argvstr.size(); ++index )
343 argv[index] = argvstr[index].c_str();
347 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
351 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
353 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
354 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/logs" );
355 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
356 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
359 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
362 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
363 {
"",
"power",
"power",
"power",
"power",
"power" },
364 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
365 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
367 XWCTEST_MAGAOXAPP_EXEC_SIGTERM_ns::MagAOXApp_test app(
false );
368 app.setPowerMgtEnabled(
true );
369 app.invokedName() = argv[0];
371 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
373 int rv = app.execute();
377 SECTION(
"appStartup failure" )
379 std::vector<const char *> argv;
380 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
382 argv.resize( argvstr.size() + 1, NULL );
383 for(
size_t index = 0; index < argvstr.size(); ++index )
385 argv[index] = argvstr[index].c_str();
389 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
393 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
395 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
396 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/logs" );
397 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
398 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
401 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
404 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
405 {
"",
"power",
"power",
"power",
"power",
"power" },
406 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
407 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
409 XWCTEST_MAGAOXAPP_EXEC_NORM_APPSTARTUP_ns::MagAOXApp_test app(
false );
410 app.setPowerMgtEnabled(
true );
411 app.invokedName() = argv[0];
413 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
415 app.appStartupFail =
true;
417 int rv = app.execute();
421 SECTION(
"appLogic failure" )
423 std::vector<const char *> argv;
424 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
426 argv.resize( argvstr.size() + 1, NULL );
427 for(
size_t index = 0; index < argvstr.size(); ++index )
429 argv[index] = argvstr[index].c_str();
433 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
437 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
439 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
440 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/logs" );
441 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
442 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
445 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
448 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
449 {
"",
"power",
"power",
"power",
"power",
"power" },
450 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
451 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
453 XWCTEST_MAGAOXAPP_EXEC_NORM_APPLOGIC_ns::MagAOXApp_test app(
false );
454 app.setPowerMgtEnabled(
true );
455 app.invokedName() = argv[0];
457 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
458 app.appLogicFail =
true;
459 int rv = app.execute();
463 SECTION(
"appShutdown failure" )
465 std::vector<const char *> argv;
466 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
468 argv.resize( argvstr.size() + 1, NULL );
469 for(
size_t index = 0; index < argvstr.size(); ++index )
471 argv[index] = argvstr[index].c_str();
475 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
479 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
481 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
482 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/logs" );
483 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
484 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
487 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
490 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
491 {
"",
"power",
"power",
"power",
"power",
"power" },
492 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
493 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
495 XWCTEST_MAGAOXAPP_EXEC_NORM_APPSHUTDOWN_ns::MagAOXApp_test app(
false );
496 app.setPowerMgtEnabled(
true );
497 app.invokedName() = argv[0];
499 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
500 app.appShutdownFail =
true;
501 int rv = app.execute();