@@ -87,6 +87,19 @@ void release_sem(Semaphore *sem)
8787
8888testcase_data current_case;
8989
90+ Thread wdg_kicking_thread (osPriorityNormal, 768 );
91+ Semaphore kick_wdg_during_test_teardown (0 , 1 );
92+
93+ void wdg_kicking_thread_fun ()
94+ {
95+ kick_wdg_during_test_teardown.acquire ();
96+ Watchdog &watchdog = Watchdog::get_instance ();
97+ while (true ) {
98+ watchdog.kick ();
99+ wait_us (20000 );
100+ }
101+ }
102+
90103bool send_reset_notification (testcase_data *tcdata, uint32_t delay_ms)
91104{
92105 char msg_value[12 ];
@@ -124,7 +137,7 @@ void test_simple_reset()
124137
125138 // Watchdog reset should have occurred during wait_ms() above;
126139
127- watchdog. kick (); // Just to buy some time for testsuite failure handling.
140+ kick_wdg_during_test_teardown. release (); // For testsuite failure handling.
128141 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
129142}
130143
@@ -161,7 +174,7 @@ void test_sleep_reset()
161174
162175 // Watchdog reset should have occurred during sem.wait() (sleep) above;
163176
164- watchdog. kick (); // Just to buy some time for testsuite failure handling.
177+ kick_wdg_during_test_teardown. release (); // For testsuite failure handling.
165178 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
166179}
167180
@@ -196,7 +209,7 @@ void test_deepsleep_reset()
196209
197210 // Watchdog reset should have occurred during sem.wait() (deepsleep) above;
198211
199- watchdog. kick (); // Just to buy some time for testsuite failure handling.
212+ kick_wdg_during_test_teardown. release (); // For testsuite failure handling.
200213 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
201214}
202215#endif
@@ -241,7 +254,7 @@ void test_restart_reset()
241254
242255 // Watchdog reset should have occurred during that wait() above;
243256
244- watchdog. kick (); // Just to buy some time for testsuite failure handling.
257+ kick_wdg_during_test_teardown. release (); // For testsuite failure handling.
245258 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
246259}
247260
@@ -274,7 +287,7 @@ void test_kick_reset()
274287
275288 // Watchdog reset should have occurred during that wait() above;
276289
277- watchdog. kick (); // Just to buy some time for testsuite failure handling.
290+ kick_wdg_during_test_teardown. release (); // For testsuite failure handling.
278291 TEST_ASSERT_MESSAGE (0 , " Watchdog did not reset the device as expected." );
279292}
280293
@@ -309,6 +322,10 @@ int testsuite_setup(const size_t number_of_cases)
309322 return utest::v1::STATUS_ABORT;
310323 }
311324
325+ // The thread is started here, but feeding the watchdog will start
326+ // when the semaphore is released during a test case teardown.
327+ wdg_kicking_thread.start (mbed::callback (wdg_kicking_thread_fun));
328+
312329 utest_printf (" This test suite is composed of %i test cases. Starting at index %i.\n " , number_of_cases,
313330 current_case.start_index );
314331 return current_case.start_index ;
0 commit comments