diff --git a/TESTS/mbed_drivers/watchdog_reset/main.cpp b/TESTS/mbed_drivers/watchdog_reset/main.cpp index 0732d98fa4..530afba7fc 100644 --- a/TESTS/mbed_drivers/watchdog_reset/main.cpp +++ b/TESTS/mbed_drivers/watchdog_reset/main.cpp @@ -87,6 +87,19 @@ void release_sem(Semaphore *sem) testcase_data current_case; +Thread wdg_kicking_thread(osPriorityNormal, 768); +Semaphore kick_wdg_during_test_teardown(0, 1); + +void wdg_kicking_thread_fun() +{ + kick_wdg_during_test_teardown.acquire(); + Watchdog &watchdog = Watchdog::get_instance(); + while (true) { + watchdog.kick(); + wait_us(20000); + } +} + bool send_reset_notification(testcase_data *tcdata, uint32_t delay_ms) { char msg_value[12]; @@ -124,7 +137,7 @@ void test_simple_reset() // Watchdog reset should have occurred during wait_ms() above; - watchdog.kick(); // Just to buy some time for testsuite failure handling. + kick_wdg_during_test_teardown.release(); // For testsuite failure handling. TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected."); } @@ -161,7 +174,7 @@ void test_sleep_reset() // Watchdog reset should have occurred during sem.wait() (sleep) above; - watchdog.kick(); // Just to buy some time for testsuite failure handling. + kick_wdg_during_test_teardown.release(); // For testsuite failure handling. TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected."); } @@ -196,7 +209,7 @@ void test_deepsleep_reset() // Watchdog reset should have occurred during sem.wait() (deepsleep) above; - watchdog.kick(); // Just to buy some time for testsuite failure handling. + kick_wdg_during_test_teardown.release(); // For testsuite failure handling. TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected."); } #endif @@ -241,7 +254,7 @@ void test_restart_reset() // Watchdog reset should have occurred during that wait() above; - watchdog.kick(); // Just to buy some time for testsuite failure handling. + kick_wdg_during_test_teardown.release(); // For testsuite failure handling. TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected."); } @@ -274,7 +287,7 @@ void test_kick_reset() // Watchdog reset should have occurred during that wait() above; - watchdog.kick(); // Just to buy some time for testsuite failure handling. + kick_wdg_during_test_teardown.release(); // For testsuite failure handling. TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected."); } @@ -309,6 +322,10 @@ int testsuite_setup(const size_t number_of_cases) return utest::v1::STATUS_ABORT; } + // The thread is started here, but feeding the watchdog will start + // when the semaphore is released during a test case teardown. + wdg_kicking_thread.start(mbed::callback(wdg_kicking_thread_fun)); + utest_printf("This test suite is composed of %i test cases. Starting at index %i.\n", number_of_cases, current_case.start_index); return current_case.start_index; diff --git a/TESTS/mbed_hal/watchdog_reset/main.cpp b/TESTS/mbed_hal/watchdog_reset/main.cpp index 7300392ddc..0d273b70ad 100644 --- a/TESTS/mbed_hal/watchdog_reset/main.cpp +++ b/TESTS/mbed_hal/watchdog_reset/main.cpp @@ -85,6 +85,18 @@ void release_sem(Semaphore *sem) testcase_data current_case; +Thread wdg_kicking_thread(osPriorityNormal, 768); +Semaphore kick_wdg_during_test_teardown(0, 1); + +void wdg_kicking_thread_fun() +{ + kick_wdg_during_test_teardown.acquire(); + while (true) { + hal_watchdog_kick(); + wait_us(20000); + } +} + bool send_reset_notification(testcase_data *tcdata, uint32_t delay_ms) { char msg_value[12]; @@ -120,7 +132,7 @@ void test_simple_reset() // Watchdog reset should have occurred during wait_ms() above; - hal_watchdog_kick(); // Just to buy some time for testsuite failure handling. + kick_wdg_during_test_teardown.release(); // For testsuite failure handling. TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected."); } @@ -155,7 +167,7 @@ void test_sleep_reset() // Watchdog reset should have occurred during sem.wait() (sleep) above; - hal_watchdog_kick(); // Just to buy some time for testsuite failure handling. + kick_wdg_during_test_teardown.release(); // For testsuite failure handling. TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected."); } @@ -188,7 +200,7 @@ void test_deepsleep_reset() // Watchdog reset should have occurred during sem.wait() (deepsleep) above; - hal_watchdog_kick(); // Just to buy some time for testsuite failure handling. + kick_wdg_during_test_teardown.release(); // For testsuite failure handling. TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected."); } #endif @@ -229,7 +241,7 @@ void test_restart_reset() // Watchdog reset should have occurred during that wait() above; - hal_watchdog_kick(); // Just to buy some time for testsuite failure handling. + kick_wdg_during_test_teardown.release(); // For testsuite failure handling. TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected."); } @@ -260,7 +272,7 @@ void test_kick_reset() // Watchdog reset should have occurred during that wait() above; - hal_watchdog_kick(); // Just to buy some time for testsuite failure handling. + kick_wdg_during_test_teardown.release(); // For testsuite failure handling. TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected."); } @@ -295,6 +307,10 @@ int testsuite_setup(const size_t number_of_cases) return utest::v1::STATUS_ABORT; } + // The thread is started here, but feeding the watchdog will start + // when the semaphore is released during a test case teardown. + wdg_kicking_thread.start(mbed::callback(wdg_kicking_thread_fun)); + utest_printf("This test suite is composed of %i test cases. Starting at index %i.\n", number_of_cases, current_case.start_index); return current_case.start_index;