Make all timing critical tests depend on SENF_TIMING_CRITICAL_TESTS
g0dil [Fri, 13 Nov 2009 09:20:52 +0000 (09:20 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1521 270642c3-0616-0410-b53a-bc976706d245

senf/PPI/IntervalTimer.test.cc
senf/Scheduler/ClockService.test.cc
senf/Scheduler/FdEvent.test.cc
senf/Scheduler/Scheduler.test.cc
senf/Scheduler/TimerEvent.test.cc

index e8e746c..7dd31d6 100644 (file)
@@ -73,13 +73,17 @@ namespace {
 
 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////////////////////////////////////////
index b3fb4a6..3ad36bf 100644 (file)
@@ -56,15 +56,19 @@ namespace {
 
 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;
 
@@ -72,26 +76,29 @@ BOOST_AUTO_UNIT_TEST(clockService)
     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////////////////////////////////////////
index cfb62db..9cf36c8 100644 (file)
@@ -236,7 +236,7 @@ namespace {
 
     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);
@@ -248,6 +248,9 @@ namespace {
 
 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));
@@ -261,7 +264,8 @@ BOOST_AUTO_UNIT_TEST(fileDispatcher)
         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";
@@ -276,8 +280,9 @@ BOOST_AUTO_UNIT_TEST(fileDispatcher)
     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);
index 7352830..3a1b3ba 100644 (file)
@@ -222,6 +222,9 @@ namespace {
 
 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);
 
@@ -283,14 +286,17 @@ void schedulerTest()
         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() );
@@ -311,8 +317,10 @@ void schedulerTest()
         ::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() ); 
     } 
 
@@ -375,6 +383,9 @@ namespace {
 
 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));
@@ -383,10 +394,12 @@ BOOST_AUTO_UNIT_TEST(blockSignals)
     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() ); 
 }
index b45506c..1d3b815 100644 (file)
@@ -42,7 +42,7 @@ namespace {
 
     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;