mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #12182 from fkjagodzinski/test_update-watchdog_teardown
Update watchdog tests to run with bare metal profilepull/12055/head
commit
7090448577
|
|
@ -14,11 +14,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if !defined(MBED_CONF_RTOS_PRESENT)
|
||||
#error [NOT_SUPPORTED] Watchdog test cases require a RTOS to run.
|
||||
#else
|
||||
|
||||
#if !DEVICE_WATCHDOG
|
||||
#error [NOT_SUPPORTED] Watchdog not supported for this target
|
||||
#else
|
||||
|
|
@ -73,18 +68,6 @@ using utest::v1::Harness;
|
|||
|
||||
using namespace mbed;
|
||||
|
||||
Thread wdg_kicking_thread(osPriorityNormal, 768);
|
||||
Semaphore kick_wdg_during_test_teardown(0, 1);
|
||||
|
||||
void wdg_kicking_thread_fun()
|
||||
{
|
||||
kick_wdg_during_test_teardown.wait();
|
||||
while (true) {
|
||||
hal_watchdog_kick();
|
||||
wait_ms(20);
|
||||
}
|
||||
}
|
||||
|
||||
void test_max_timeout_is_valid()
|
||||
{
|
||||
Watchdog &watchdog = Watchdog::get_instance();
|
||||
|
|
@ -172,8 +155,10 @@ utest::v1::status_t case_teardown_sync_on_reset(const Case *const source, const
|
|||
if (CASE_IGNORED) {
|
||||
return utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
|
||||
}
|
||||
// Unlock kicking the watchdog during teardown.
|
||||
kick_wdg_during_test_teardown.release();
|
||||
// Start kicking the watchdog during teardown.
|
||||
hal_watchdog_kick();
|
||||
Ticker wdg_kicking_ticker;
|
||||
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000);
|
||||
utest::v1::status_t status = utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
|
||||
if (failed) {
|
||||
/* Return immediately and skip the device reset, if the test case failed.
|
||||
|
|
@ -260,10 +245,6 @@ int testsuite_setup_sync_on_reset(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("Starting with test case index %i of all %i defined test cases.\n", CASE_INDEX_START, number_of_cases);
|
||||
return CASE_INDEX_START;
|
||||
}
|
||||
|
|
@ -289,4 +270,3 @@ int main()
|
|||
}
|
||||
|
||||
#endif // !DEVICE_WATCHDOG
|
||||
#endif // !defined(MBED_CONG_RTOS_PRESENT)
|
||||
|
|
|
|||
|
|
@ -14,10 +14,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#if !defined(MBED_CONF_RTOS_PRESENT)
|
||||
#error [NOT_SUPPORTED] Watchdog reset test cases require a RTOS to run.
|
||||
#else
|
||||
|
||||
#if !DEVICE_WATCHDOG
|
||||
#error [NOT_SUPPORTED] Watchdog not supported for this target
|
||||
#else
|
||||
|
|
@ -90,18 +86,7 @@ struct testcase_data {
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Ticker wdg_kicking_ticker;
|
||||
|
||||
bool send_reset_notification(testcase_data *tcdata, uint32_t delay_ms)
|
||||
{
|
||||
|
|
@ -140,7 +125,8 @@ void test_simple_reset()
|
|||
|
||||
// Watchdog reset should have occurred during a wait above.
|
||||
|
||||
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
|
||||
hal_watchdog_kick();
|
||||
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
|
||||
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
|
||||
}
|
||||
|
||||
|
|
@ -174,7 +160,8 @@ void test_sleep_reset()
|
|||
|
||||
// Watchdog reset should have occurred during the sleep above.
|
||||
|
||||
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
|
||||
hal_watchdog_kick();
|
||||
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
|
||||
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
|
||||
}
|
||||
|
||||
|
|
@ -210,7 +197,8 @@ void test_deepsleep_reset()
|
|||
|
||||
// Watchdog reset should have occurred during the deepsleep above.
|
||||
|
||||
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
|
||||
hal_watchdog_kick();
|
||||
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
|
||||
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
|
||||
}
|
||||
#endif
|
||||
|
|
@ -255,7 +243,8 @@ void test_restart_reset()
|
|||
|
||||
// Watchdog reset should have occurred during a wait above.
|
||||
|
||||
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
|
||||
hal_watchdog_kick();
|
||||
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
|
||||
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
|
||||
}
|
||||
|
||||
|
|
@ -288,7 +277,8 @@ void test_kick_reset()
|
|||
|
||||
// Watchdog reset should have occurred during a wait above.
|
||||
|
||||
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
|
||||
hal_watchdog_kick();
|
||||
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
|
||||
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
|
||||
}
|
||||
|
||||
|
|
@ -323,10 +313,6 @@ 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;
|
||||
|
|
@ -352,4 +338,3 @@ int main()
|
|||
return !Harness::run(specification);
|
||||
}
|
||||
#endif // !DEVICE_WATCHDOG
|
||||
#endif // !defined(MBED_CONF_RTOS_PRESENT)
|
||||
|
|
|
|||
|
|
@ -14,10 +14,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#if !defined(MBED_CONF_RTOS_PRESENT)
|
||||
#error [NOT_SUPPORTED] Watchdog test cases require a RTOS to run.
|
||||
#else
|
||||
|
||||
#if !DEVICE_WATCHDOG
|
||||
#error [NOT_SUPPORTED] Watchdog not supported for this target
|
||||
#else
|
||||
|
|
@ -73,18 +69,6 @@ using utest::v1::Harness;
|
|||
|
||||
const watchdog_config_t WDG_CONFIG_DEFAULT = { .timeout_ms = WDG_TIMEOUT_MS };
|
||||
|
||||
Thread wdg_kicking_thread(osPriorityNormal, 768);
|
||||
Semaphore kick_wdg_during_test_teardown(0, 1);
|
||||
|
||||
void wdg_kicking_thread_fun()
|
||||
{
|
||||
kick_wdg_during_test_teardown.wait();
|
||||
while (true) {
|
||||
hal_watchdog_kick();
|
||||
wait_ms(20);
|
||||
}
|
||||
}
|
||||
|
||||
void test_max_timeout_is_valid()
|
||||
{
|
||||
TEST_ASSERT(hal_watchdog_get_platform_features().max_timeout > 1UL);
|
||||
|
|
@ -168,8 +152,10 @@ utest::v1::status_t case_teardown_sync_on_reset(const Case *const source, const
|
|||
if (CASE_IGNORED) {
|
||||
return utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
|
||||
}
|
||||
// Unlock kicking the watchdog during teardown.
|
||||
kick_wdg_during_test_teardown.release();
|
||||
// Start kicking the watchdog during teardown.
|
||||
hal_watchdog_kick();
|
||||
Ticker wdg_kicking_ticker;
|
||||
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000);
|
||||
utest::v1::status_t status = utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
|
||||
if (failed) {
|
||||
/* Return immediately and skip the device reset, if the test case failed.
|
||||
|
|
@ -256,10 +242,6 @@ int testsuite_setup_sync_on_reset(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("Starting with test case index %i of all %i defined test cases.\n", CASE_INDEX_START, number_of_cases);
|
||||
return CASE_INDEX_START;
|
||||
}
|
||||
|
|
@ -288,5 +270,4 @@ int main()
|
|||
return !Harness::run(specification);
|
||||
}
|
||||
|
||||
#endif // !DEVICE_WATCHDOG
|
||||
#endif // !defined(MBED_CONF_RTOS_PRESENT)
|
||||
#endif // !DEVICE_WATCHDOG
|
||||
|
|
@ -14,10 +14,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#if !MBED_CONF_RTOS_PRESENT
|
||||
#error [NOT_SUPPORTED] Watchdog reset test cases require a RTOS to run.
|
||||
#else
|
||||
|
||||
#if !DEVICE_WATCHDOG
|
||||
#error [NOT_SUPPORTED] Watchdog not supported for this target
|
||||
#else
|
||||
|
|
@ -88,17 +84,7 @@ struct testcase_data {
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Ticker wdg_kicking_ticker;
|
||||
|
||||
bool send_reset_notification(testcase_data *tcdata, uint32_t delay_ms)
|
||||
{
|
||||
|
|
@ -135,7 +121,8 @@ void test_simple_reset()
|
|||
|
||||
// Watchdog reset should have occurred during a wait above.
|
||||
|
||||
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
|
||||
hal_watchdog_kick();
|
||||
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
|
||||
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
|
||||
}
|
||||
|
||||
|
|
@ -167,7 +154,8 @@ void test_sleep_reset()
|
|||
|
||||
// Watchdog reset should have occurred during the sleep above.
|
||||
|
||||
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
|
||||
hal_watchdog_kick();
|
||||
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
|
||||
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +189,8 @@ void test_deepsleep_reset()
|
|||
|
||||
// Watchdog reset should have occurred during the deepsleep above.
|
||||
|
||||
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
|
||||
hal_watchdog_kick();
|
||||
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
|
||||
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
|
||||
}
|
||||
#endif
|
||||
|
|
@ -242,7 +231,8 @@ void test_restart_reset()
|
|||
|
||||
// Watchdog reset should have occurred during a wait above.
|
||||
|
||||
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
|
||||
hal_watchdog_kick();
|
||||
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
|
||||
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
|
||||
}
|
||||
|
||||
|
|
@ -273,7 +263,8 @@ void test_kick_reset()
|
|||
|
||||
// Watchdog reset should have occurred during a wait above.
|
||||
|
||||
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
|
||||
hal_watchdog_kick();
|
||||
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
|
||||
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
|
||||
}
|
||||
|
||||
|
|
@ -308,10 +299,6 @@ 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;
|
||||
|
|
@ -338,4 +325,3 @@ int main()
|
|||
}
|
||||
|
||||
#endif // !DEVICE_WATCHDOG
|
||||
#endif // !MBED_CONF_RTOS_PRESENT
|
||||
|
|
|
|||
Loading…
Reference in New Issue