129 SECTION(
"complete run-through" )
131 std::vector<const char *> argv;
132 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
134 argv.resize( argvstr.size() + 1, NULL );
135 for(
size_t index = 0; index < argvstr.size(); ++index )
137 argv[index] = argvstr[index].c_str();
141 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
145 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
147 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
148 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/logs" );
149 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
150 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
153 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
156 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
157 {
"",
"power",
"power",
"power",
"power",
"power" },
158 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
159 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
161 XWCTEST_MAGAOXAPP_EXEC_NORM_ns::MagAOXApp_test app(
false );
162 app.setPowerMgtEnabled(
true );
163 app.invokedName() = argv[0];
165 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
167 int rv = app.execute();
171 SECTION(
"No log directory" )
173 std::vector<const char *> argv;
174 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
176 argv.resize( argvstr.size() + 1, NULL );
177 for(
size_t index = 0; index < argvstr.size(); ++index )
179 argv[index] = argvstr[index].c_str();
183 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
187 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
189 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
191 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
192 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
195 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
198 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
199 {
"",
"power",
"power",
"power",
"power",
"power" },
200 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
201 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
204 app.setPowerMgtEnabled(
true );
205 app.invokedName() = argv[0];
207 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
209 int rv = app.execute();
213 SECTION(
"wrong user" )
215 std::vector<const char *> argv;
216 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
218 argv.resize( argvstr.size() + 1, NULL );
219 for(
size_t index = 0; index < argvstr.size(); ++index )
221 argv[index] = argvstr[index].c_str();
225 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
229 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
231 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
232 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/logs" );
233 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
234 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
237 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
240 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
241 {
"",
"power",
"power",
"power",
"power",
"power" },
242 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
243 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
245 XWCTEST_MAGAOXAPP_EXEC_WRONG_USER_ns::MagAOXApp_test app(
false );
246 app.setPowerMgtEnabled(
true );
247 app.invokedName() = argv[0];
249 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
251 int rv = app.execute();
255 SECTION(
"PID Lock Error" )
257 std::vector<const char *> argv;
258 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
260 argv.resize( argvstr.size() + 1, NULL );
261 for(
size_t index = 0; index < argvstr.size(); ++index )
263 argv[index] = argvstr[index].c_str();
267 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
271 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
273 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
274 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/logs" );
275 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
276 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
279 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
282 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
283 {
"",
"power",
"power",
"power",
"power",
"power" },
284 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
285 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
287 XWCTEST_MAGAOXAPP_PID_WRITE_FAIL_ns::MagAOXApp_test app(
false );
288 app.setPowerMgtEnabled(
true );
289 app.invokedName() = argv[0];
291 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
293 int rv = app.execute();
297 SECTION(
"Log fails to start" )
299 std::vector<const char *> argv;
300 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
302 argv.resize( argvstr.size() + 1, NULL );
303 for(
size_t index = 0; index < argvstr.size(); ++index )
305 argv[index] = argvstr[index].c_str();
309 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
313 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
315 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
316 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/logs" );
317 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
318 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
321 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
324 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
325 {
"",
"power",
"power",
"power",
"power",
"power" },
326 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
327 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
329 XWCTEST_MAGAOXAPP_EXEC_LOG_START_ns::MagAOXApp_test app(
false );
330 app.setPowerMgtEnabled(
true );
331 app.invokedName() = argv[0];
333 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
335 int rv = app.execute();
339 SECTION(
"Setting sigterm handler fails" )
341 std::vector<const char *> argv;
342 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
344 argv.resize( argvstr.size() + 1, NULL );
345 for(
size_t index = 0; index < argvstr.size(); ++index )
347 argv[index] = argvstr[index].c_str();
351 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
355 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
357 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
358 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/logs" );
359 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
360 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
363 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
366 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
367 {
"",
"power",
"power",
"power",
"power",
"power" },
368 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
369 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
371 XWCTEST_MAGAOXAPP_EXEC_SIGTERM_ns::MagAOXApp_test app(
false );
372 app.setPowerMgtEnabled(
true );
373 app.invokedName() = argv[0];
375 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
377 int rv = app.execute();
381 SECTION(
"appStartup failure" )
383 std::vector<const char *> argv;
384 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
386 argv.resize( argvstr.size() + 1, NULL );
387 for(
size_t index = 0; index < argvstr.size(); ++index )
389 argv[index] = argvstr[index].c_str();
393 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
397 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
399 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
400 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/logs" );
401 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
402 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
405 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
408 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
409 {
"",
"power",
"power",
"power",
"power",
"power" },
410 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
411 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
413 XWCTEST_MAGAOXAPP_EXEC_NORM_APPSTARTUP_ns::MagAOXApp_test app(
false );
414 app.setPowerMgtEnabled(
true );
415 app.invokedName() = argv[0];
417 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
419 app.appStartupFail =
true;
421 int rv = app.execute();
425 SECTION(
"appLogic failure" )
427 std::vector<const char *> argv;
428 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
430 argv.resize( argvstr.size() + 1, NULL );
431 for(
size_t index = 0; index < argvstr.size(); ++index )
433 argv[index] = argvstr[index].c_str();
437 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
441 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
443 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
444 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/logs" );
445 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
446 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
449 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
452 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
453 {
"",
"power",
"power",
"power",
"power",
"power" },
454 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
455 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
457 XWCTEST_MAGAOXAPP_EXEC_NORM_APPLOGIC_ns::MagAOXApp_test app(
false );
458 app.setPowerMgtEnabled(
true );
459 app.invokedName() = argv[0];
461 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
462 app.appLogicFail =
true;
463 int rv = app.execute();
467 SECTION(
"appShutdown failure" )
469 std::vector<const char *> argv;
470 std::vector<std::string> argvstr( {
"./execname",
"-n",
"testapp" } );
472 argv.resize( argvstr.size() + 1, NULL );
473 for(
size_t index = 0; index < argvstr.size(); ++index )
475 argv[index] = argvstr[index].c_str();
479 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/MagAOXApp_test",
MAGAOX_env_path );
483 std::filesystem::remove_all(
"/tmp/MagAOXApp_test" );
485 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/config" );
486 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/logs" );
487 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/sys/testapp" );
488 mx::ioutils::createDirectories(
"/tmp/MagAOXApp_test/drivers/fifos" );
491 fout.open(
"/tmp/MagAOXApp_test/config/magaox.conf" );
494 mx::app::writeConfigFile(
"/tmp/MagAOXApp_test/config/testapp.conf",
495 {
"",
"power",
"power",
"power",
"power",
"power" },
496 {
"loopPause",
"device",
"channel",
"element",
"targetElement",
"powerOnWait" },
497 {
"2500",
"pdu9",
"thisch",
"thisel",
"thistgtel",
"5" } );
499 XWCTEST_MAGAOXAPP_EXEC_NORM_APPSHUTDOWN_ns::MagAOXApp_test app(
false );
500 app.setPowerMgtEnabled(
true );
501 app.invokedName() = argv[0];
503 app.setup( argv.size() - 1,
const_cast<char **
>( argv.data() ) );
504 app.appShutdownFail =
true;
505 int rv = app.execute();