BOOST_AUTO_UNIT_TEST(intervalTimer)
{
+ char const * enabled (getenv("SENF_TIMING_CRITICAL_TESTS"));
+ BOOST_WARN_MESSAGE(enabled, "Set SENF_TIMING_CRITICAL_TESTS to not skip timing critical tests");
+
TimerTest timer (100,3);
senf::ClockService::clock_type start (senf::ClockService::now());
senf::ppi::run();
- BOOST_CHECK_PREDICATE( is_close_clock,
- (senf::ClockService::now())
- (start+senf::ClockService::milliseconds(300))
- (senf::ClockService::milliseconds(80)) );
+ if (enabled)
+ BOOST_CHECK_PREDICATE( is_close_clock,
+ (senf::ClockService::now())
+ (start+senf::ClockService::milliseconds(300))
+ (senf::ClockService::milliseconds(50)) );
}
///////////////////////////////cc.e////////////////////////////////////////
BOOST_AUTO_UNIT_TEST(clockService)
{
+ char const * enabled (getenv("SENF_TIMING_CRITICAL_TESTS"));
+ BOOST_WARN_MESSAGE(enabled, "Set SENF_TIMING_CRITICAL_TESTS to not skip timing critical tests");
+
senf::ClockService::restart(); // So we know, when the signal will be delivered
senf::ClockService::clock_type t1 (senf::ClockService::now());
delay(200);
senf::ClockService::clock_type t2 (senf::ClockService::now());
- BOOST_CHECK_PREDICATE( is_close_clock,
- (t1 + senf::ClockService::milliseconds(200))
- (t2)
- (senf::ClockService::milliseconds(100)) );
+ if (enabled)
+ BOOST_CHECK_PREDICATE( is_close_clock,
+ (t1 + senf::ClockService::milliseconds(200))
+ (t2)
+ (senf::ClockService::milliseconds(100)) );
t1 = t2;
delay(1*1000);
t2 = senf::ClockService::now();
- BOOST_CHECK_PREDICATE( is_close_clock,
- (t1 + senf::ClockService::seconds(1))
- (t2)
- (senf::ClockService::milliseconds(500)) );
+ if (enabled)
+ BOOST_CHECK_PREDICATE( is_close_clock,
+ (t1 + senf::ClockService::seconds(1))
+ (t2)
+ (senf::ClockService::milliseconds(500)) );
t1 = t2;
delay(200);
- BOOST_CHECK_PREDICATE( is_close_clock,
- (t1 + senf::ClockService::milliseconds(200))
- (senf::ClockService::now())
- (senf::ClockService::milliseconds(100)) );
+ if (enabled)
+ BOOST_CHECK_PREDICATE( is_close_clock,
+ (t1 + senf::ClockService::milliseconds(200))
+ (senf::ClockService::now())
+ (senf::ClockService::milliseconds(100)) );
// The next check validates that the clock service itimer/heartbeat_ is correctly reset after a
// clock-skew is detected
- BOOST_CHECK_PREDICATE( is_close_clock,
- (t1 + senf::ClockService::milliseconds(200))
- (senf::ClockService::now())
- (senf::ClockService::milliseconds(100)) );
+ if (enabled)
+ BOOST_CHECK_PREDICATE( is_close_clock,
+ (t1 + senf::ClockService::milliseconds(200))
+ (senf::ClockService::now())
+ (senf::ClockService::milliseconds(100)) );
}
///////////////////////////////cc.e////////////////////////////////////////
bool is_close(senf::ClockService::clock_type a, senf::ClockService::clock_type b)
{
- return (a<b ? b-a : a-b) < senf::ClockService::milliseconds(100);
+ return (a<b ? b-a : a-b) < senf::ClockService::milliseconds(50);
}
bool called (false);
BOOST_AUTO_UNIT_TEST(fileDispatcher)
{
+ char const * enabled (getenv("SENF_TIMING_CRITICAL_TESTS"));
+ BOOST_WARN_MESSAGE(enabled, "Set SENF_TIMING_CRITICAL_TESTS to not skip timing critical tests");
+
senf::scheduler::detail::FileDispatcher::instance().timeout(500);
int fd (open("test.empty.file", O_RDWR|O_CREAT|O_TRUNC, 0600));
SENF_CHECK_NO_THROW( senf::scheduler::detail::FIFORunner::instance().run() );
BOOST_CHECK( called );
- BOOST_CHECK_PREDICATE( is_close, (t)(senf::ClockService::now()) );
+ if (enabled)
+ BOOST_CHECK_PREDICATE( is_close, (t)(senf::ClockService::now()) );
}
catch (std::exception const & ex) {
std::cerr << "Exception:\n" << ex.what() << "\n";
SENF_CHECK_NO_THROW( senf::scheduler::detail::FIFORunner::instance().run() );
BOOST_CHECK( ! called );
- BOOST_CHECK_PREDICATE(
- is_close, (t+senf::ClockService::milliseconds(500))(senf::ClockService::now()) );
+ if (enabled)
+ BOOST_CHECK_PREDICATE(
+ is_close, (t+senf::ClockService::milliseconds(500))(senf::ClockService::now()) );
unlink("test.empty.file");
senf::scheduler::detail::FileDispatcher::instance().timeout(-1);
void schedulerTest()
{
+ char const * enabled (getenv("SENF_TIMING_CRITICAL_TESTS"));
+ BOOST_WARN_MESSAGE(enabled, "Set SENF_TIMING_CRITICAL_TESTS to not skip timing critical tests");
+
int pid = start_server();
BOOST_REQUIRE (pid);
event = senf::scheduler::FdEvent::EV_NONE;
senf::ClockService::clock_type t (senf::ClockService::now());
SENF_CHECK_NO_THROW( senf::scheduler::process() );
- BOOST_CHECK_PREDICATE( is_close, (senf::ClockService::now()-t) (senf::ClockService::milliseconds(200)) );
+ if (enabled)
+ BOOST_CHECK_PREDICATE( is_close, (senf::ClockService::now()-t) (senf::ClockService::milliseconds(200)) );
BOOST_CHECK( timeoutCalled );
BOOST_CHECK( ! timer1.enabled() );
BOOST_CHECK_EQUAL( event, senf::scheduler::FdEvent::EV_NONE );
- BOOST_CHECK_PREDICATE( is_close, (senf::ClockService::now()) (senf::scheduler::eventTime()) );
+ if (enabled)
+ BOOST_CHECK_PREDICATE( is_close, (senf::ClockService::now()) (senf::scheduler::eventTime()) );
timeoutCalled = false;
SENF_CHECK_NO_THROW( senf::scheduler::process() );
- BOOST_CHECK_PREDICATE( is_close, (senf::ClockService::now()-t) (senf::ClockService::milliseconds(400)) );
+ if (enabled)
+ BOOST_CHECK_PREDICATE( is_close, (senf::ClockService::now()-t) (senf::ClockService::milliseconds(400)) );
BOOST_CHECK( timeoutCalled );
BOOST_CHECK_EQUAL( event, senf::scheduler::FdEvent::EV_NONE );
BOOST_CHECK( ! timer2.enabled() );
::kill(::getpid(), SIGUSR1);
delay(200);
SENF_CHECK_NO_THROW( senf::scheduler::process() );
- BOOST_CHECK_PREDICATE( is_close, (senf::ClockService::now()) (t+senf::ClockService::milliseconds(200)) );
- BOOST_CHECK_PREDICATE( is_close, (sigtime) (t+senf::ClockService::milliseconds(200)) );
+ if (enabled) {
+ BOOST_CHECK_PREDICATE( is_close, (senf::ClockService::now()) (t+senf::ClockService::milliseconds(200)) );
+ BOOST_CHECK_PREDICATE( is_close, (sigtime) (t+senf::ClockService::milliseconds(200)) );
+ }
SENF_CHECK_NO_THROW( senf::scheduler::process() );
}
BOOST_AUTO_UNIT_TEST(blockSignals)
{
+ char const * enabled (getenv("SENF_TIMING_CRITICAL_TESTS"));
+ BOOST_WARN_MESSAGE(enabled, "Set SENF_TIMING_CRITICAL_TESTS to not skip timing critical tests");
+
senf::scheduler::TimerEvent signaler ("sigme", &sigme, senf::ClockService::now());
senf::scheduler::TimerEvent timer (
"testWatchdog", &timeout, senf::ClockService::now()+senf::ClockService::milliseconds(400));
senf::ClockService::clock_type t = senf::ClockService::now();
SENF_CHECK_NO_THROW( senf::scheduler::process() );
- BOOST_CHECK_PREDICATE( is_close,
- (senf::ClockService::now())
- (t+senf::ClockService::milliseconds(200)) );
- BOOST_CHECK_PREDICATE( is_close, (sigtime) (t+senf::ClockService::milliseconds(200)) );
+ if (enabled) {
+ BOOST_CHECK_PREDICATE( is_close,
+ (senf::ClockService::now())
+ (t+senf::ClockService::milliseconds(200)) );
+ BOOST_CHECK_PREDICATE( is_close, (sigtime) (t+senf::ClockService::milliseconds(200)) );
+ }
SENF_CHECK_NO_THROW( senf::scheduler::process() );
}
bool is_close(senf::ClockService::clock_type a, senf::ClockService::clock_type b)
{
- return (a<b ? b-a : a-b) < senf::ClockService::milliseconds(100);
+ return (a<b ? b-a : a-b) < senf::ClockService::milliseconds(50);
}
bool called = false;