From: Marcin Siodelski Date: Tue, 8 Sep 2015 17:39:52 +0000 (+0200) Subject: [3970] Improved the test for TimerMgr::stopThread. X-Git-Tag: fd4o6_base~5^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=971b7440bb5dbedaa51dd7893a3d4fb1a690f1a5;p=thirdparty%2Fkea.git [3970] Improved the test for TimerMgr::stopThread. This test now also checks that it is possible to skip running ready handlers. --- diff --git a/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc b/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc index 02f52075bb..77148eff54 100644 --- a/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc +++ b/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));