32 nr_of_p = TimerThread::MAX_ACTIVITIES/2;
33 nr_of_np = TimerThread::MAX_ACTIVITIES/2;
36 errInitNP =
"Not all NonPreemptibleActivity::init() or finalize() functions were called.";
37 errStepNP =
"Not all NonPreemptibleActivity::step() functions were called.";
38 errFinNP =
"Not all NonPreemptibleActivity::finalize() or finalize() functions were called.";
39 errInitP =
"Not all PreemptibleActivity::init() functions were called.";
40 errStepP =
"Not all PreemptibleActivity::step() functions were called.";
41 errFinP =
"Not all PreemptibleActivity::finalize() functions were called.";
43 log(
Info) <<
"Creating "<< nr_of_np <<
" High priority and "<< nr_of_p <<
" Low priority activities."<<
endlog();
45 np_tasks.reserve(nr_of_np);
46 p_tasks.reserve(nr_of_p);
47 for (
unsigned int i=0; i< nr_of_np/2; ++i)
49 for (
unsigned int i=0; i< nr_of_np/2; ++i)
51 for (
unsigned int i=0; i< nr_of_p/3; ++i)
53 for (
unsigned int i=0; i< nr_of_p/3; ++i)
55 for (
unsigned int i=0; i< nr_of_p/3; ++i)
60 nr_of_p = p_tasks.size();
61 nr_of_np = np_tasks.size();
67 for (
NPI i=np_tasks.begin(); i != np_tasks.end(); ++i)
72 for (
PI i=p_tasks.begin(); i != p_tasks.end(); ++i)
85 for (NPI i=np_tasks.begin(); i != np_tasks.end(); ++i)
87 BOOST_CHECK( (*i)->start() );
89 for (PI i=p_tasks.begin(); i != p_tasks.end(); ++i)
91 BOOST_CHECK( (*i)->start() );
100 while ( runs++ != 100/correction ) {
101 if ( np_tasks[runningNp]->isRunning() )
102 BOOST_CHECK( np_tasks[runningNp]->stop() );
103 if ( !np_tasks[runningNp - 1]->isRunning() )
104 BOOST_CHECK( np_tasks[runningNp - 1]->start() );
106 if ( p_tasks[runningP]->isRunning() )
107 BOOST_CHECK( p_tasks[runningP]->stop() );
108 if ( !p_tasks[runningP - 1]->isRunning() )
109 BOOST_CHECK( p_tasks[runningP - 1]->start() );
111 if ( ++runningP == nr_of_p) runningP = 1;
112 if ( ++runningNp == nr_of_np) runningNp = 1;
113 if ( runs % (20/correction) == 0 )
117 for (NPI i=np_tasks.begin(); i != np_tasks.end(); ++i)
119 if ( (*i)->isRunning() )
120 BOOST_CHECK( (*i)->stop() );
122 for (PI i=p_tasks.begin(); i != p_tasks.end(); ++i)
124 if ( (*i)->isRunning() )
125 BOOST_CHECK( (*i)->stop() );
128 for (
unsigned int i=0; i < nr_of_np; ++i)
130 BOOST_CHECK_EQUAL( np_tasks[i]->nrOfOKStarts(), np_tasks[i]->nrOfInits() );
133 BOOST_CHECK_EQUAL( np_tasks[i]->nrOfOKStops(), np_tasks[i]->nrOfFinals() );
136 for (
unsigned int i=0; i < nr_of_p; ++i)
138 BOOST_CHECK_EQUAL( p_tasks[i]->nrOfOKStarts(), p_tasks[i]->nrOfInits() );
140 BOOST_CHECK_EQUAL( p_tasks[i]->nrOfOKStops(), p_tasks[i]->nrOfFinals() );
144 int totInit=0, totSteps=0, totFins=0;
147 for (
unsigned int i=1; i < nr_of_np-1; ++i)
149 totInit += np_tasks[i]->nrOfInits();
150 totSteps += np_tasks[i]->nrOfSteps();
151 totFins += np_tasks[i]->nrOfFinals();
153 BOOST_CHECK_MESSAGE( totInit == totFins, errInitNP);
154 BOOST_CHECK_MESSAGE( totSteps >= totInit, errStepNP );
157 totInit = totSteps = totFins = 0;
159 for (
unsigned int i=1; i < nr_of_p-1; ++i)
161 totInit += p_tasks[i]->nrOfInits();
162 totSteps += p_tasks[i]->nrOfSteps();
163 totFins += p_tasks[i]->nrOfFinals();
165 BOOST_CHECK_MESSAGE(totInit == totFins, errInitP );
166 BOOST_CHECK_MESSAGE(totSteps >= totInit, errStepP );
#define BOOST_FIXTURE_TEST_SUITE(suite_name, F)
std::vector< DummyNPTask * >::iterator NPI
std::vector< DummyPTask * >::iterator PI
#define BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(testMultiple)
const int HighestPriority
unsigned int sleep(unsigned int s)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
const int IncreasePriority
static Logger::LogFunction endlog()