Skip to content

Commit a7178b3

Browse files
Filip Jagodzinski0xc0170
authored andcommitted
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.
1 parent a415e44 commit a7178b3

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

TESTS/mbed_drivers/watchdog/main.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060

6161
int CASE_INDEX_START;
6262
int CASE_INDEX_CURRENT;
63+
bool CASE_IGNORED = false;
6364

6465
using utest::v1::Case;
6566
using utest::v1::Specification;
@@ -91,6 +92,7 @@ void test_stop()
9192
Watchdog &watchdog = Watchdog::get_instance();
9293
if (!features.disable_watchdog) {
9394
TEST_ASSERT_FALSE(watchdog.stop());
95+
CASE_IGNORED = true;
9496
TEST_IGNORE_MESSAGE("Disabling watchdog not supported for this platform");
9597
return;
9698
}
@@ -114,9 +116,15 @@ void test_restart()
114116
{
115117
watchdog_features_t features = hal_watchdog_get_platform_features();
116118
if (!features.update_config) {
119+
CASE_IGNORED = true;
117120
TEST_IGNORE_MESSAGE("Updating watchdog config not supported for this platform");
118121
return;
119122
}
123+
if (!features.disable_watchdog) {
124+
CASE_IGNORED = true;
125+
TEST_IGNORE_MESSAGE("Disabling watchdog not supported for this platform");
126+
return;
127+
}
120128

121129
Watchdog &watchdog = Watchdog::get_instance();
122130
uint32_t max_timeout = watchdog.get_max_timeout();
@@ -129,6 +137,7 @@ void test_restart()
129137

130138
for (size_t i = 0; i < num_timeouts; i++) {
131139
if (timeouts[i] < WDG_MIN_TIMEOUT_MS) {
140+
CASE_IGNORED = true;
132141
TEST_IGNORE_MESSAGE("Requested timeout value is too short -- ignoring test case.");
133142
return;
134143
}
@@ -148,12 +157,16 @@ void test_restart()
148157
utest::v1::status_t case_setup_sync_on_reset(const Case *const source, const size_t index_of_case)
149158
{
150159
CASE_INDEX_CURRENT = index_of_case;
160+
CASE_IGNORED = false;
151161
return utest::v1::greentea_case_setup_handler(source, index_of_case);
152162
}
153163

154164
utest::v1::status_t case_teardown_sync_on_reset(const Case *const source, const size_t passed, const size_t failed,
155165
const utest::v1::failure_t failure)
156166
{
167+
if (CASE_IGNORED) {
168+
return utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
169+
}
157170
// Unlock kicking the watchdog during teardown.
158171
kick_wdg_during_test_teardown.release();
159172
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
178191
utest::v1::status_t case_teardown_wdg_stop_or_reset(const Case *const source, const size_t passed, const size_t failed,
179192
const utest::v1::failure_t failure)
180193
{
194+
if (CASE_IGNORED) {
195+
return utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
196+
}
181197
watchdog_features_t features = hal_watchdog_get_platform_features();
182198
if (features.disable_watchdog) {
183199
hal_watchdog_stop();
@@ -191,6 +207,7 @@ template<uint32_t timeout_ms>
191207
void test_start()
192208
{
193209
if (timeout_ms < WDG_MIN_TIMEOUT_MS) {
210+
CASE_IGNORED = true;
194211
TEST_IGNORE_MESSAGE("Requested timeout value is too short -- ignoring test case.");
195212
return;
196213
}

TESTS/mbed_hal/watchdog/main.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161

6262
int CASE_INDEX_START;
6363
int CASE_INDEX_CURRENT;
64+
bool CASE_IGNORED = false;
6465

6566
using utest::v1::Case;
6667
using utest::v1::Specification;
@@ -89,6 +90,7 @@ void test_restart_is_possible()
8990
{
9091
watchdog_features_t features = hal_watchdog_get_platform_features();
9192
if (!features.disable_watchdog) {
93+
CASE_IGNORED = true;
9294
TEST_IGNORE_MESSAGE("Disabling watchdog not supported for this platform");
9395
return;
9496
}
@@ -100,6 +102,7 @@ void test_stop()
100102
watchdog_features_t features = hal_watchdog_get_platform_features();
101103
if (!features.disable_watchdog) {
102104
TEST_ASSERT_EQUAL(WATCHDOG_STATUS_NOT_SUPPORTED, hal_watchdog_stop());
105+
CASE_IGNORED = true;
103106
TEST_IGNORE_MESSAGE("Disabling watchdog not supported for this platform");
104107
return;
105108
}
@@ -118,6 +121,7 @@ void test_update_config()
118121
{
119122
watchdog_features_t features = hal_watchdog_get_platform_features();
120123
if (!features.update_config) {
124+
CASE_IGNORED = true;
121125
TEST_IGNORE_MESSAGE("Updating watchdog config not supported for this platform");
122126
return;
123127
}
@@ -132,6 +136,7 @@ void test_update_config()
132136

133137
for (size_t i = 0; i < num_timeouts; i++) {
134138
if (timeouts[i] < WDG_MIN_TIMEOUT_MS) {
139+
CASE_IGNORED = true;
135140
TEST_IGNORE_MESSAGE("Requested timeout value is too short -- ignoring test case.");
136141
return;
137142
}
@@ -149,12 +154,16 @@ void test_update_config()
149154
utest::v1::status_t case_setup_sync_on_reset(const Case *const source, const size_t index_of_case)
150155
{
151156
CASE_INDEX_CURRENT = index_of_case;
157+
CASE_IGNORED = false;
152158
return utest::v1::greentea_case_setup_handler(source, index_of_case);
153159
}
154160

155161
utest::v1::status_t case_teardown_sync_on_reset(const Case *const source, const size_t passed, const size_t failed,
156162
const utest::v1::failure_t failure)
157163
{
164+
if (CASE_IGNORED) {
165+
return utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
166+
}
158167
// Unlock kicking the watchdog during teardown.
159168
kick_wdg_during_test_teardown.release();
160169
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
179188
utest::v1::status_t case_teardown_wdg_stop_or_reset(const Case *const source, const size_t passed, const size_t failed,
180189
const utest::v1::failure_t failure)
181190
{
191+
if (CASE_IGNORED) {
192+
return utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
193+
}
182194
watchdog_features_t features = hal_watchdog_get_platform_features();
183195
if (features.disable_watchdog) {
184196
hal_watchdog_stop();
@@ -192,6 +204,7 @@ template<uint32_t timeout_ms>
192204
void test_init()
193205
{
194206
if (timeout_ms < WDG_MIN_TIMEOUT_MS) {
207+
CASE_IGNORED = true;
195208
TEST_IGNORE_MESSAGE("Requested timeout value is too short -- ignoring test case.");
196209
return;
197210
}

0 commit comments

Comments
 (0)