Browse Source

[3970] Improved the test for TimerMgr::stopThread.

This test now also checks that it is possible to skip running
ready handlers.
Marcin Siodelski 9 years ago
parent
commit
971b7440bb
1 changed files with 17 additions and 0 deletions
  1. 17 0
      src/lib/dhcpsrv/tests/timer_mgr_unittest.cc

+ 17 - 0
src/lib/dhcpsrv/tests/timer_mgr_unittest.cc

@@ -446,6 +446,23 @@ TEST_F(TimerMgrTest, stopThreadWithRunningHandlers) {
     // There should be no calls registered for the timer1.
     EXPECT_EQ(0, calls_count_["timer1"]);
 
+    // Stop the worker thread without completing pending callbacks.
+    ASSERT_NO_THROW(timer_mgr.stopThread(false));
+
+    // There should be still not be any calls registered.
+    EXPECT_EQ(0, calls_count_["timer1"]);
+
+    // We can restart the worker thread before we even kick in the timers.
+    ASSERT_NO_THROW(timer_mgr.startThread());
+
+    // Run the thread for 100ms. This should run some timers. The 'false'
+    // value indicates that the IfaceMgr::receive6 is not called, so the
+    // watch socket is never cleared.
+    doWait(100, false);
+
+    // There should be no calls registered for the timer1.
+    EXPECT_EQ(0, calls_count_["timer1"]);
+
     // Stop the worker thread with completing pending callbacks.
     ASSERT_NO_THROW(timer_mgr.stopThread(true));