23 #include <boost/test/unit_test.hpp> 35 BOOST_AUTO_TEST_SUITE(ts_PeriodicThread)
49 # define RUN_HARD_REALTIME_TESTS 55 const double cMAX_DEVIATION_FACTOR = 1;
56 const double cMEAN_DEVIATION_FACTOR = 1;
57 const size_t cNUMBER_OF_BURN_THREADS = 10;
115 :
PeriodicThread(
"Burn Thread", cBURN_THREAD_PERIOD, cBURN_THREAD_PRIORITY),
149 memset(burn_threads, 0,
sizeof(burn_threads));
158 BOOST_CHECK(!test_thread.
hasRun());
167 burn_threads[i]->
start();
177 burn_threads[i]->
stop();
178 burn_threads[i]->
join();
179 delete burn_threads[i];
180 burn_threads[i] = NULL;
184 BOOST_REQUIRE(test_thread.
hasRun());
188 BOOST_CHECK(test_thread.
maxDeviation() < max_deviation);
195 runPeriodicThread(period, 10, period * cMAX_DEVIATION_FACTOR, period * cMEAN_DEVIATION_FACTOR);
201 runPeriodicThread(period, 100, period * cMAX_DEVIATION_FACTOR, period * cMEAN_DEVIATION_FACTOR);
204 #ifdef RUN_HARD_REALTIME_TESTS 209 runPeriodicThread(period, 1000, period * cMAX_DEVIATION_FACTOR, period * cMEAN_DEVIATION_FACTOR);
215 runPeriodicThread(period, 10000, period * cMAX_DEVIATION_FACTOR, period * cMEAN_DEVIATION_FACTOR);
221 runPeriodicThread(period, 10, period * cMAX_DEVIATION_FACTOR, period * cMEAN_DEVIATION_FACTOR,
true);
227 runPeriodicThread(period, 100, period * cMAX_DEVIATION_FACTOR, period * cMEAN_DEVIATION_FACTOR,
true);
233 runPeriodicThread(period, 1000, period * cMAX_DEVIATION_FACTOR, period * cMEAN_DEVIATION_FACTOR,
true);
239 runPeriodicThread(period, 10000, period * cMAX_DEVIATION_FACTOR, period * cMEAN_DEVIATION_FACTOR,
true);
244 BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(RunPeriodicThread_1s)
Represents absolute times.
TimeSpan abs(const TimeSpan &span)
TimeSpan m_accumulated_deviation
const double cMAX_DEVIATION_FACTOR
const size_t cNUMBER_OF_BURN_THREADS
Contains a system independet PRINTF macro.
Contains icl_core::thread::PeriodicThread.
TimeSpan meanDeviation() const
const icl_core::TimeSpan cBURN_THREAD_PERIOD(0, 100000000)
void runPeriodicThread(const TimeSpan &period, size_t runs, const TimeSpan &max_deviation, const TimeSpan &mean_deviation, bool burn=false)
Contains global LXRT functions.
virtual ~PeriodicTestThread()
Repesents absolute times.
TimeSpan accumulatedDeviation() const
Contains Interface base classes and base types.
void * memset(void *dest, int c, size_t count)
const icl_core::ThreadPriority cRUN_THREAD_PRIORITY
PeriodicTestThread(const TimeSpan &period, size_t runs)
icl_core::TimeSpan period() const
const double cMEAN_DEVIATION_FACTOR
const icl_core::ThreadPriority cBURN_THREAD_PRIORITY
TimeSpan maxDeviation() const
const icl_core::ThreadPriority cTEST_THREAD_PRIORITY