30 #include <boost/function_types/function_type.hpp> 48 BOOST_CHECK( this->getTaskState() == TaskContext::PreOperational );
49 BOOST_CHECK( this->getTargetState() == TaskContext::PreOperational );
82 BOOST_CHECK( mTaskState <= Stopped );
83 BOOST_CHECK( getTargetState() == Stopped );
91 BOOST_CHECK( mTaskState == Stopped);
92 BOOST_CHECK( getTargetState() == Running );
100 BOOST_CHECK( mTaskState >= Running || mTaskState == Exception);
101 BOOST_CHECK( getTargetState() == Stopped || getTargetState() == Exception );
108 BOOST_CHECK( mTaskState == Stopped || mTaskState == Exception);
109 BOOST_CHECK( getTargetState() == PreOperational || getTargetState() == Exception );
116 BOOST_CHECK( mTaskState == Exception);
117 BOOST_CHECK( getTargetState() == Exception );
126 BOOST_CHECK( mTaskState == Running );
127 BOOST_CHECK( getTargetState() == Running );
154 BOOST_CHECK( mTaskState == RunTimeError );
155 BOOST_CHECK( getTargetState() == RunTimeError );
169 bool do_fatal, do_error, do_throw,do_throw2,do_throw3,
do_trigger, do_breakUH, do_block, do_checks, do_stop;
187 tc =
new TaskContext(
"root", TaskContext::Stopped );
193 SimulationThread::Instance()->
stop();
241 BOOST_CHECK( trigtc.
getPeriod() == 0.0 );
243 BOOST_CHECK( trigtc.
trigger() == true );
249 BOOST_CHECK( trigtc.
trigger() == true );
253 BOOST_CHECK( trigtc.
start() );
254 BOOST_CHECK( trigtc.
didstart ==
true );
263 BOOST_CHECK( trigtc.
trigger() );
265 BOOST_CHECK( trigtc.
didstart ==
false );
269 BOOST_CHECK( trigtc.
trigger() );
276 BOOST_CHECK( trigtc.
trigger() );
284 BOOST_CHECK_EQUAL( pertc.
getPeriod(), 0.1 );
285 BOOST_CHECK( pertc.
trigger() == false );
286 BOOST_CHECK( pertc.
configure() == true );
287 BOOST_CHECK( pertc.
trigger() == false );
288 BOOST_CHECK( pertc.
start() == true );
289 BOOST_CHECK( pertc.
trigger() == false );
300 BOOST_CHECK( breaktc.
getPeriod() == 0.0 );
304 BOOST_CHECK( breaktc.
start() );
307 BOOST_CHECK_EQUAL( breaktc.
didupdate,
true );
308 BOOST_CHECK_EQUAL( breaktc.
stop(), false );
310 BOOST_CHECK_EQUAL( breaktc.
didstop,
false);
315 BOOST_CHECK_EQUAL( breaktc.
stop(), true );
317 BOOST_CHECK_EQUAL( breaktc.
didstop,
true);
329 BOOST_CHECK( breaktc.
getPeriod() == 0.0 );
332 BOOST_CHECK( breaktc.
start() );
336 BOOST_CHECK_EQUAL( breaktc.
didupdate,
true );
338 BOOST_CHECK_EQUAL( breaktc.
didstop,
false);
339 BOOST_CHECK_EQUAL( breaktc.
isRunning(),
true);
346 BOOST_CHECK( breaktc.
trigger() );
348 BOOST_CHECK_EQUAL( breaktc.
didupdate,
true );
350 BOOST_CHECK_EQUAL( breaktc.
didstop,
true);
351 BOOST_CHECK_EQUAL( breaktc.
isRunning(),
false);
361 BOOST_CHECK_EQUAL( pertc.
getPeriod(), 0.1 );
364 BOOST_CHECK_EQUAL( pertc.
getPeriod(), 0.2 );
365 BOOST_CHECK( pertc.
start() == true );
368 BOOST_CHECK_EQUAL( pertc.
getPeriod(), 0.5 );
377 BOOST_CHECK( tc->getTaskState() == TaskContext::Stopped );
380 BOOST_CHECK( tc->isConfigured() == true );
381 BOOST_CHECK( tc->isRunning() == false );
382 BOOST_CHECK( tc->isActive() == true );
383 BOOST_CHECK( tc->configure() == true );
386 BOOST_CHECK( tc->start() == true );
387 BOOST_CHECK( tc->isRunning() == true );
388 BOOST_CHECK( tc->isActive() == true );
389 BOOST_CHECK( tc->configure() == false );
390 BOOST_CHECK( tc->start() == false );
391 BOOST_CHECK( tc->cleanup() == false );
394 BOOST_CHECK( tc->stop() == true );
395 BOOST_CHECK( tc->isRunning() ==
false);
396 BOOST_CHECK( tc->isActive() == true );
397 BOOST_CHECK( tc->stop() == false );
398 BOOST_CHECK( tc->configure() == true );
399 BOOST_CHECK( tc->isConfigured() == true );
402 BOOST_CHECK( tc->engine()->getActivity()->stop() ==
true);
403 BOOST_CHECK( tc->isActive() ==
false);
404 BOOST_CHECK( tc->activate() == true );
405 BOOST_CHECK( tc->isActive() ==
true);
406 BOOST_CHECK( tc->isRunning() == false );
407 BOOST_CHECK( tc->configure() == true );
408 BOOST_CHECK( tc->isConfigured() == true );
411 BOOST_CHECK( tc->cleanup() == true );
412 BOOST_CHECK( tc->isConfigured() ==
false);
413 BOOST_CHECK( tc->isRunning() ==
false);
416 BOOST_CHECK( tc->configure() == true );
417 BOOST_CHECK( tc->isConfigured() ==
true);
418 BOOST_CHECK( tc->isRunning() ==
false);
419 BOOST_CHECK( tc->isActive() == true );
429 BOOST_CHECK( stc->getTaskState() == TaskContext::PreOperational );
432 BOOST_CHECK( stc->configure() == true );
433 BOOST_CHECK( stc->didconfig ==
true );
434 BOOST_CHECK( stc->isConfigured() == true );
436 BOOST_CHECK( stc->didstart ==
false );
437 BOOST_CHECK( stc->didupdate ==
false );
438 BOOST_CHECK( stc->diderror ==
false );
439 BOOST_CHECK( stc->didexcept ==
false );
440 BOOST_CHECK( stc->didstop ==
false );
441 BOOST_CHECK( stc->didcleanup ==
false );
445 BOOST_CHECK( stc->start() == true );
446 BOOST_CHECK( stc->didstart ==
true );
447 BOOST_CHECK( stc->isRunning() == true );
449 BOOST_CHECK( stc->didconfig ==
false );
450 BOOST_CHECK( stc->didupdate ==
false );
451 BOOST_CHECK( stc->diderror ==
false );
452 BOOST_CHECK( stc->didexcept ==
false );
453 BOOST_CHECK( stc->didstop ==
false );
454 BOOST_CHECK( stc->didcleanup ==
false );
459 SimulationThread::Instance()->run(1);
461 BOOST_CHECK( stc->didconfig ==
false );
462 BOOST_CHECK( stc->didstart ==
false );
463 BOOST_CHECK( stc->didupdate ==
true );
464 BOOST_CHECK( stc->diderror ==
false );
465 BOOST_CHECK( stc->didexcept ==
false );
466 BOOST_CHECK( stc->didstop ==
false );
467 BOOST_CHECK( stc->didcleanup ==
false );
471 BOOST_CHECK( stc->stop() == true );
472 BOOST_CHECK( stc->didstop ==
true );
473 BOOST_CHECK( stc->isRunning() == false );
475 BOOST_CHECK( stc->didconfig ==
false );
476 BOOST_CHECK( stc->didstart ==
false );
477 BOOST_CHECK( stc->didupdate ==
false );
478 BOOST_CHECK( stc->diderror ==
false );
479 BOOST_CHECK( stc->didexcept ==
false );
480 BOOST_CHECK( stc->didcleanup ==
false );
484 BOOST_CHECK( stc->configure() == true );
485 BOOST_CHECK( stc->didconfig ==
true );
486 BOOST_CHECK( stc->isConfigured() == true );
488 BOOST_CHECK( stc->didstart ==
false );
489 BOOST_CHECK( stc->didupdate ==
false );
490 BOOST_CHECK( stc->diderror ==
false );
491 BOOST_CHECK( stc->didexcept ==
false );
492 BOOST_CHECK( stc->didstop ==
false );
493 BOOST_CHECK( stc->didcleanup ==
false );
497 BOOST_CHECK( stc->cleanup() == true );
498 BOOST_CHECK( stc->didcleanup ==
true );
499 BOOST_CHECK( stc->isConfigured() ==
false);
501 BOOST_CHECK( stc->didconfig ==
false );
502 BOOST_CHECK( stc->didstart ==
false );
503 BOOST_CHECK( stc->didupdate ==
false );
504 BOOST_CHECK( stc->diderror ==
false );
505 BOOST_CHECK( stc->didexcept ==
false );
506 BOOST_CHECK( stc->didstop ==
false );
516 stc->validconfig =
false;
517 stc->validstart =
false;
520 BOOST_CHECK( stc->isConfigured() == false );
521 BOOST_CHECK( stc->isRunning() == false );
522 BOOST_CHECK( stc->configure() == false );
523 BOOST_CHECK( stc->didconfig ==
true );
524 BOOST_CHECK( stc->isConfigured() == false );
525 BOOST_CHECK( stc->isRunning() == false );
526 BOOST_CHECK( stc->isActive() == true );
530 stc->validconfig =
true;
531 BOOST_CHECK( stc->configure() == true );
532 BOOST_CHECK( stc->didconfig ==
true );
533 BOOST_CHECK( stc->isConfigured() == true );
534 BOOST_CHECK( stc->isRunning() == false );
535 BOOST_CHECK( stc->isActive() == true );
539 BOOST_CHECK( stc->start() == false );
540 BOOST_CHECK( stc->didstart ==
true );
541 BOOST_CHECK( stc->isRunning() == false );
542 BOOST_CHECK( stc->isActive() == true );
543 BOOST_CHECK( stc->isConfigured() == true );
547 stc->validstart =
true;
548 BOOST_CHECK( stc->start() == true );
549 BOOST_CHECK( stc->didstart ==
true );
550 BOOST_CHECK( stc->isConfigured() == true );
551 BOOST_CHECK( stc->isRunning() == true );
552 BOOST_CHECK( stc->isActive() == true );
556 stc->do_error =
true;
558 SimulationThread::Instance()->run(1);
559 BOOST_CHECK( stc->inRunTimeError() == true );
560 BOOST_CHECK( stc->diderror ==
true );
561 BOOST_CHECK( stc->didexcept ==
false );
562 BOOST_CHECK( stc->isActive() == true );
564 stc->do_error =
false;
566 SimulationThread::Instance()->run(1);
567 BOOST_CHECK( stc->isRunning() == true );
568 BOOST_CHECK( stc->diderror ==
false );
569 BOOST_CHECK( stc->didupdate ==
true );
572 stc->do_throw =
true;
574 SimulationThread::Instance()->run(1);
575 BOOST_CHECK( stc->inRunTimeError() == false );
576 BOOST_CHECK( stc->inException() == true );
577 BOOST_CHECK( stc->didexcept ==
true );
578 BOOST_CHECK( stc->isActive() == true );
580 stc->do_throw =
false;
582 SimulationThread::Instance()->run(1);
583 BOOST_CHECK( stc->isConfigured() == false );
584 BOOST_CHECK( stc->diderror ==
false );
585 BOOST_CHECK( stc->didupdate ==
false );
591 stc->do_error =
false;
592 stc->do_throw =
true;
593 stc->do_throw3 =
true;
595 SimulationThread::Instance()->run(1);
596 BOOST_CHECK( stc->inRunTimeError() == false );
597 BOOST_CHECK( stc->inFatalError() == true );
598 BOOST_CHECK( stc->diderror ==
false );
599 BOOST_CHECK( stc->didexcept ==
true );
600 BOOST_CHECK( stc->didstop ==
true );
601 BOOST_CHECK( stc->didcleanup ==
true );
602 BOOST_CHECK( stc->isActive() == false );
603 BOOST_CHECK( stc->isRunning() == false );
604 BOOST_CHECK( stc->isConfigured() == false );
608 BOOST_CHECK( stc->configure() == false );
609 BOOST_CHECK( stc->start() == false );
619 while(getTargetState() != Stopped) {
629 for (
int i = 0; i < 100; ++i)
651 while(getTargetState() != Stopped) {
655 mRecovered = recover();
661 for (
int i = 0; i < 100; ++i)
687 lastErrorHook = TimeService::Instance()->getTicks();
691 lastStopHook = TimeService::Instance()->getTicks();
697 for (
int i = 0; i < 100; ++i)
#define BOOST_FIXTURE_TEST_SUITE(suite_name, F)
TimeService::ticks lastErrorHook
ActivityInterface * getActivity() const
Query for the task this interface is run in.
errorHook_is_not_called_after_an_exit_transition_Task()
#define BOOST_AUTO_TEST_SUITE_END()
virtual TaskState getTargetState() const
static int rtos_nanosleep(const TIME_SPEC *rqtp, TIME_SPEC *rmtp)
int usleep(unsigned int us)
virtual bool isRunning() const
bool setActivity(base::ActivityInterface *new_act)
virtual Seconds getPeriod() const
virtual bool inException() const
calling_error_does_not_override_a_stop_transition_Task()
virtual Seconds getPeriod() const =0
static TIME_SPEC ticks2timespec(TICK_TIME hrt)
virtual TaskState getTaskState() const
virtual bool isActive() const
virtual bool inRunTimeError() const
TICK_TIME nano2ticks(NANO_TIME nano)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
ActivityInterface * stsim
The state indicating the component is ready to run.
TimeService::ticks lastStopHook
BOOST_AUTO_TEST_CASE(testPeriod)
calling_recover_does_not_override_a_stop_transition_Task()
struct timespec TIME_SPEC
virtual bool setPeriod(Seconds s)
TaskCore_bails_out_if_startHook_returns_true_but_exception_was_called()
const ExecutionEngine * engine() const
base::ActivityInterface * getActivity()
static bool trigger(TaskContext *tc)