Test: Watchdog: Fix test_restart case

Watchdog::stop() is called in this test. If the target does not support
stopping the watchdog this case needs to be skipped.
Also improve handling ignored test cases.
pull/10857/head
Filip Jagodzinski 2019-07-01 13:45:48 +02:00 committed by Martin Kojtal
parent dc2e8ab35e
commit b89eeb7ec5
2 changed files with 30 additions and 0 deletions

View File

@ -60,6 +60,7 @@
int CASE_INDEX_START; int CASE_INDEX_START;
int CASE_INDEX_CURRENT; int CASE_INDEX_CURRENT;
bool CASE_IGNORED = false;
using utest::v1::Case; using utest::v1::Case;
using utest::v1::Specification; using utest::v1::Specification;
@ -91,6 +92,7 @@ void test_stop()
Watchdog &watchdog = Watchdog::get_instance(); Watchdog &watchdog = Watchdog::get_instance();
if (!features.disable_watchdog) { if (!features.disable_watchdog) {
TEST_ASSERT_FALSE(watchdog.stop()); TEST_ASSERT_FALSE(watchdog.stop());
CASE_IGNORED = true;
TEST_IGNORE_MESSAGE("Disabling watchdog not supported for this platform"); TEST_IGNORE_MESSAGE("Disabling watchdog not supported for this platform");
return; return;
} }
@ -114,9 +116,15 @@ void test_restart()
{ {
watchdog_features_t features = hal_watchdog_get_platform_features(); watchdog_features_t features = hal_watchdog_get_platform_features();
if (!features.update_config) { if (!features.update_config) {
CASE_IGNORED = true;
TEST_IGNORE_MESSAGE("Updating watchdog config not supported for this platform"); TEST_IGNORE_MESSAGE("Updating watchdog config not supported for this platform");
return; return;
} }
if (!features.disable_watchdog) {
CASE_IGNORED = true;
TEST_IGNORE_MESSAGE("Disabling watchdog not supported for this platform");
return;
}
Watchdog &watchdog = Watchdog::get_instance(); Watchdog &watchdog = Watchdog::get_instance();
uint32_t max_timeout = watchdog.get_max_timeout(); uint32_t max_timeout = watchdog.get_max_timeout();
@ -129,6 +137,7 @@ void test_restart()
for (size_t i = 0; i < num_timeouts; i++) { for (size_t i = 0; i < num_timeouts; i++) {
if (timeouts[i] < WDG_MIN_TIMEOUT_MS) { if (timeouts[i] < WDG_MIN_TIMEOUT_MS) {
CASE_IGNORED = true;
TEST_IGNORE_MESSAGE("Requested timeout value is too short -- ignoring test case."); TEST_IGNORE_MESSAGE("Requested timeout value is too short -- ignoring test case.");
return; return;
} }
@ -148,12 +157,16 @@ void test_restart()
utest::v1::status_t case_setup_sync_on_reset(const Case *const source, const size_t index_of_case) utest::v1::status_t case_setup_sync_on_reset(const Case *const source, const size_t index_of_case)
{ {
CASE_INDEX_CURRENT = index_of_case; CASE_INDEX_CURRENT = index_of_case;
CASE_IGNORED = false;
return utest::v1::greentea_case_setup_handler(source, index_of_case); return utest::v1::greentea_case_setup_handler(source, index_of_case);
} }
utest::v1::status_t case_teardown_sync_on_reset(const Case *const source, const size_t passed, const size_t failed, utest::v1::status_t case_teardown_sync_on_reset(const Case *const source, const size_t passed, const size_t failed,
const utest::v1::failure_t failure) const utest::v1::failure_t failure)
{ {
if (CASE_IGNORED) {
return utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
}
// Unlock kicking the watchdog during teardown. // Unlock kicking the watchdog during teardown.
kick_wdg_during_test_teardown.release(); kick_wdg_during_test_teardown.release();
utest::v1::status_t status = utest::v1::greentea_case_teardown_handler(source, passed, failed, failure); utest::v1::status_t status = utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
@ -178,6 +191,9 @@ utest::v1::status_t case_teardown_sync_on_reset(const Case *const source, const
utest::v1::status_t case_teardown_wdg_stop_or_reset(const Case *const source, const size_t passed, const size_t failed, utest::v1::status_t case_teardown_wdg_stop_or_reset(const Case *const source, const size_t passed, const size_t failed,
const utest::v1::failure_t failure) const utest::v1::failure_t failure)
{ {
if (CASE_IGNORED) {
return utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
}
watchdog_features_t features = hal_watchdog_get_platform_features(); watchdog_features_t features = hal_watchdog_get_platform_features();
if (features.disable_watchdog) { if (features.disable_watchdog) {
hal_watchdog_stop(); hal_watchdog_stop();
@ -191,6 +207,7 @@ template<uint32_t timeout_ms>
void test_start() void test_start()
{ {
if (timeout_ms < WDG_MIN_TIMEOUT_MS) { if (timeout_ms < WDG_MIN_TIMEOUT_MS) {
CASE_IGNORED = true;
TEST_IGNORE_MESSAGE("Requested timeout value is too short -- ignoring test case."); TEST_IGNORE_MESSAGE("Requested timeout value is too short -- ignoring test case.");
return; return;
} }

View File

@ -61,6 +61,7 @@
int CASE_INDEX_START; int CASE_INDEX_START;
int CASE_INDEX_CURRENT; int CASE_INDEX_CURRENT;
bool CASE_IGNORED = false;
using utest::v1::Case; using utest::v1::Case;
using utest::v1::Specification; using utest::v1::Specification;
@ -89,6 +90,7 @@ void test_restart_is_possible()
{ {
watchdog_features_t features = hal_watchdog_get_platform_features(); watchdog_features_t features = hal_watchdog_get_platform_features();
if (!features.disable_watchdog) { if (!features.disable_watchdog) {
CASE_IGNORED = true;
TEST_IGNORE_MESSAGE("Disabling watchdog not supported for this platform"); TEST_IGNORE_MESSAGE("Disabling watchdog not supported for this platform");
return; return;
} }
@ -100,6 +102,7 @@ void test_stop()
watchdog_features_t features = hal_watchdog_get_platform_features(); watchdog_features_t features = hal_watchdog_get_platform_features();
if (!features.disable_watchdog) { if (!features.disable_watchdog) {
TEST_ASSERT_EQUAL(WATCHDOG_STATUS_NOT_SUPPORTED, hal_watchdog_stop()); TEST_ASSERT_EQUAL(WATCHDOG_STATUS_NOT_SUPPORTED, hal_watchdog_stop());
CASE_IGNORED = true;
TEST_IGNORE_MESSAGE("Disabling watchdog not supported for this platform"); TEST_IGNORE_MESSAGE("Disabling watchdog not supported for this platform");
return; return;
} }
@ -118,6 +121,7 @@ void test_update_config()
{ {
watchdog_features_t features = hal_watchdog_get_platform_features(); watchdog_features_t features = hal_watchdog_get_platform_features();
if (!features.update_config) { if (!features.update_config) {
CASE_IGNORED = true;
TEST_IGNORE_MESSAGE("Updating watchdog config not supported for this platform"); TEST_IGNORE_MESSAGE("Updating watchdog config not supported for this platform");
return; return;
} }
@ -132,6 +136,7 @@ void test_update_config()
for (size_t i = 0; i < num_timeouts; i++) { for (size_t i = 0; i < num_timeouts; i++) {
if (timeouts[i] < WDG_MIN_TIMEOUT_MS) { if (timeouts[i] < WDG_MIN_TIMEOUT_MS) {
CASE_IGNORED = true;
TEST_IGNORE_MESSAGE("Requested timeout value is too short -- ignoring test case."); TEST_IGNORE_MESSAGE("Requested timeout value is too short -- ignoring test case.");
return; return;
} }
@ -149,12 +154,16 @@ void test_update_config()
utest::v1::status_t case_setup_sync_on_reset(const Case *const source, const size_t index_of_case) utest::v1::status_t case_setup_sync_on_reset(const Case *const source, const size_t index_of_case)
{ {
CASE_INDEX_CURRENT = index_of_case; CASE_INDEX_CURRENT = index_of_case;
CASE_IGNORED = false;
return utest::v1::greentea_case_setup_handler(source, index_of_case); return utest::v1::greentea_case_setup_handler(source, index_of_case);
} }
utest::v1::status_t case_teardown_sync_on_reset(const Case *const source, const size_t passed, const size_t failed, utest::v1::status_t case_teardown_sync_on_reset(const Case *const source, const size_t passed, const size_t failed,
const utest::v1::failure_t failure) const utest::v1::failure_t failure)
{ {
if (CASE_IGNORED) {
return utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
}
// Unlock kicking the watchdog during teardown. // Unlock kicking the watchdog during teardown.
kick_wdg_during_test_teardown.release(); kick_wdg_during_test_teardown.release();
utest::v1::status_t status = utest::v1::greentea_case_teardown_handler(source, passed, failed, failure); utest::v1::status_t status = utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
@ -179,6 +188,9 @@ utest::v1::status_t case_teardown_sync_on_reset(const Case *const source, const
utest::v1::status_t case_teardown_wdg_stop_or_reset(const Case *const source, const size_t passed, const size_t failed, utest::v1::status_t case_teardown_wdg_stop_or_reset(const Case *const source, const size_t passed, const size_t failed,
const utest::v1::failure_t failure) const utest::v1::failure_t failure)
{ {
if (CASE_IGNORED) {
return utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
}
watchdog_features_t features = hal_watchdog_get_platform_features(); watchdog_features_t features = hal_watchdog_get_platform_features();
if (features.disable_watchdog) { if (features.disable_watchdog) {
hal_watchdog_stop(); hal_watchdog_stop();
@ -192,6 +204,7 @@ template<uint32_t timeout_ms>
void test_init() void test_init()
{ {
if (timeout_ms < WDG_MIN_TIMEOUT_MS) { if (timeout_ms < WDG_MIN_TIMEOUT_MS) {
CASE_IGNORED = true;
TEST_IGNORE_MESSAGE("Requested timeout value is too short -- ignoring test case."); TEST_IGNORE_MESSAGE("Requested timeout value is too short -- ignoring test case.");
return; return;
} }