mirror of https://github.com/ARMmbed/mbed-os.git
Test: Watchdog: Fix error handling
Add a watchdog-kicking thread running in the background when the test suite is handling a failed assertion. A single watchdog kick did not provide enough time for the greentea communication if the watchdog reset happened later than expected.pull/11773/head
parent
419556b84a
commit
7af11fa4b5
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue