Skip to content

Commit 7090448

Browse files
authored
Merge pull request #12182 from fkjagodzinski/test_update-watchdog_teardown
Update watchdog tests to run with bare metal profile
2 parents fc2a710 + 9523307 commit 7090448

File tree

4 files changed

+31
-99
lines changed

4 files changed

+31
-99
lines changed

TESTS/mbed_drivers/watchdog/main.cpp

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
18-
#if !defined(MBED_CONF_RTOS_PRESENT)
19-
#error [NOT_SUPPORTED] Watchdog test cases require a RTOS to run.
20-
#else
21-
2217
#if !DEVICE_WATCHDOG
2318
#error [NOT_SUPPORTED] Watchdog not supported for this target
2419
#else
@@ -73,18 +68,6 @@ using utest::v1::Harness;
7368

7469
using namespace mbed;
7570

76-
Thread wdg_kicking_thread(osPriorityNormal, 768);
77-
Semaphore kick_wdg_during_test_teardown(0, 1);
78-
79-
void wdg_kicking_thread_fun()
80-
{
81-
kick_wdg_during_test_teardown.wait();
82-
while (true) {
83-
hal_watchdog_kick();
84-
wait_ms(20);
85-
}
86-
}
87-
8871
void test_max_timeout_is_valid()
8972
{
9073
Watchdog &watchdog = Watchdog::get_instance();
@@ -172,8 +155,10 @@ utest::v1::status_t case_teardown_sync_on_reset(const Case *const source, const
172155
if (CASE_IGNORED) {
173156
return utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
174157
}
175-
// Unlock kicking the watchdog during teardown.
176-
kick_wdg_during_test_teardown.release();
158+
// Start kicking the watchdog during teardown.
159+
hal_watchdog_kick();
160+
Ticker wdg_kicking_ticker;
161+
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000);
177162
utest::v1::status_t status = utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
178163
if (failed) {
179164
/* 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)
260245
return utest::v1::STATUS_ABORT;
261246
}
262247

263-
// The thread is started here, but feeding the watchdog will start
264-
// when the semaphore is released during a test case teardown.
265-
wdg_kicking_thread.start(mbed::callback(wdg_kicking_thread_fun));
266-
267248
utest_printf("Starting with test case index %i of all %i defined test cases.\n", CASE_INDEX_START, number_of_cases);
268249
return CASE_INDEX_START;
269250
}
@@ -289,4 +270,3 @@ int main()
289270
}
290271

291272
#endif // !DEVICE_WATCHDOG
292-
#endif // !defined(MBED_CONG_RTOS_PRESENT)

TESTS/mbed_drivers/watchdog_reset/main.cpp

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
#if !defined(MBED_CONF_RTOS_PRESENT)
18-
#error [NOT_SUPPORTED] Watchdog reset test cases require a RTOS to run.
19-
#else
20-
2117
#if !DEVICE_WATCHDOG
2218
#error [NOT_SUPPORTED] Watchdog not supported for this target
2319
#else
@@ -90,18 +86,7 @@ struct testcase_data {
9086

9187
testcase_data current_case;
9288

93-
Thread wdg_kicking_thread(osPriorityNormal, 768);
94-
Semaphore kick_wdg_during_test_teardown(0, 1);
95-
96-
void wdg_kicking_thread_fun()
97-
{
98-
kick_wdg_during_test_teardown.acquire();
99-
Watchdog &watchdog = Watchdog::get_instance();
100-
while (true) {
101-
watchdog.kick();
102-
wait_us(20000);
103-
}
104-
}
89+
Ticker wdg_kicking_ticker;
10590

10691
bool send_reset_notification(testcase_data *tcdata, uint32_t delay_ms)
10792
{
@@ -140,7 +125,8 @@ void test_simple_reset()
140125

141126
// Watchdog reset should have occurred during a wait above.
142127

143-
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
128+
hal_watchdog_kick();
129+
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
144130
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
145131
}
146132

@@ -174,7 +160,8 @@ void test_sleep_reset()
174160

175161
// Watchdog reset should have occurred during the sleep above.
176162

177-
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
163+
hal_watchdog_kick();
164+
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
178165
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
179166
}
180167

@@ -210,7 +197,8 @@ void test_deepsleep_reset()
210197

211198
// Watchdog reset should have occurred during the deepsleep above.
212199

213-
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
200+
hal_watchdog_kick();
201+
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
214202
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
215203
}
216204
#endif
@@ -255,7 +243,8 @@ void test_restart_reset()
255243

256244
// Watchdog reset should have occurred during a wait above.
257245

258-
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
246+
hal_watchdog_kick();
247+
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
259248
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
260249
}
261250

@@ -288,7 +277,8 @@ void test_kick_reset()
288277

289278
// Watchdog reset should have occurred during a wait above.
290279

291-
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
280+
hal_watchdog_kick();
281+
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
292282
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
293283
}
294284

@@ -323,10 +313,6 @@ int testsuite_setup(const size_t number_of_cases)
323313
return utest::v1::STATUS_ABORT;
324314
}
325315

326-
// The thread is started here, but feeding the watchdog will start
327-
// when the semaphore is released during a test case teardown.
328-
wdg_kicking_thread.start(mbed::callback(wdg_kicking_thread_fun));
329-
330316
utest_printf("This test suite is composed of %i test cases. Starting at index %i.\n", number_of_cases,
331317
current_case.start_index);
332318
return current_case.start_index;
@@ -352,4 +338,3 @@ int main()
352338
return !Harness::run(specification);
353339
}
354340
#endif // !DEVICE_WATCHDOG
355-
#endif // !defined(MBED_CONF_RTOS_PRESENT)

TESTS/mbed_hal/watchdog/main.cpp

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
#if !defined(MBED_CONF_RTOS_PRESENT)
18-
#error [NOT_SUPPORTED] Watchdog test cases require a RTOS to run.
19-
#else
20-
2117
#if !DEVICE_WATCHDOG
2218
#error [NOT_SUPPORTED] Watchdog not supported for this target
2319
#else
@@ -73,18 +69,6 @@ using utest::v1::Harness;
7369

7470
const watchdog_config_t WDG_CONFIG_DEFAULT = { .timeout_ms = WDG_TIMEOUT_MS };
7571

76-
Thread wdg_kicking_thread(osPriorityNormal, 768);
77-
Semaphore kick_wdg_during_test_teardown(0, 1);
78-
79-
void wdg_kicking_thread_fun()
80-
{
81-
kick_wdg_during_test_teardown.wait();
82-
while (true) {
83-
hal_watchdog_kick();
84-
wait_ms(20);
85-
}
86-
}
87-
8872
void test_max_timeout_is_valid()
8973
{
9074
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
168152
if (CASE_IGNORED) {
169153
return utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
170154
}
171-
// Unlock kicking the watchdog during teardown.
172-
kick_wdg_during_test_teardown.release();
155+
// Start kicking the watchdog during teardown.
156+
hal_watchdog_kick();
157+
Ticker wdg_kicking_ticker;
158+
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000);
173159
utest::v1::status_t status = utest::v1::greentea_case_teardown_handler(source, passed, failed, failure);
174160
if (failed) {
175161
/* 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)
256242
return utest::v1::STATUS_ABORT;
257243
}
258244

259-
// The thread is started here, but feeding the watchdog will start
260-
// when the semaphore is released during a test case teardown.
261-
wdg_kicking_thread.start(mbed::callback(wdg_kicking_thread_fun));
262-
263245
utest_printf("Starting with test case index %i of all %i defined test cases.\n", CASE_INDEX_START, number_of_cases);
264246
return CASE_INDEX_START;
265247
}
@@ -288,5 +270,4 @@ int main()
288270
return !Harness::run(specification);
289271
}
290272

291-
#endif // !DEVICE_WATCHDOG
292-
#endif // !defined(MBED_CONF_RTOS_PRESENT)
273+
#endif // !DEVICE_WATCHDOG

TESTS/mbed_hal/watchdog_reset/main.cpp

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
#if !MBED_CONF_RTOS_PRESENT
18-
#error [NOT_SUPPORTED] Watchdog reset test cases require a RTOS to run.
19-
#else
20-
2117
#if !DEVICE_WATCHDOG
2218
#error [NOT_SUPPORTED] Watchdog not supported for this target
2319
#else
@@ -88,17 +84,7 @@ struct testcase_data {
8884

8985
testcase_data current_case;
9086

91-
Thread wdg_kicking_thread(osPriorityNormal, 768);
92-
Semaphore kick_wdg_during_test_teardown(0, 1);
93-
94-
void wdg_kicking_thread_fun()
95-
{
96-
kick_wdg_during_test_teardown.acquire();
97-
while (true) {
98-
hal_watchdog_kick();
99-
wait_us(20000);
100-
}
101-
}
87+
Ticker wdg_kicking_ticker;
10288

10389
bool send_reset_notification(testcase_data *tcdata, uint32_t delay_ms)
10490
{
@@ -135,7 +121,8 @@ void test_simple_reset()
135121

136122
// Watchdog reset should have occurred during a wait above.
137123

138-
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
124+
hal_watchdog_kick();
125+
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
139126
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
140127
}
141128

@@ -167,7 +154,8 @@ void test_sleep_reset()
167154

168155
// Watchdog reset should have occurred during the sleep above.
169156

170-
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
157+
hal_watchdog_kick();
158+
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
171159
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
172160
}
173161

@@ -201,7 +189,8 @@ void test_deepsleep_reset()
201189

202190
// Watchdog reset should have occurred during the deepsleep above.
203191

204-
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
192+
hal_watchdog_kick();
193+
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
205194
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
206195
}
207196
#endif
@@ -242,7 +231,8 @@ void test_restart_reset()
242231

243232
// Watchdog reset should have occurred during a wait above.
244233

245-
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
234+
hal_watchdog_kick();
235+
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
246236
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
247237
}
248238

@@ -273,7 +263,8 @@ void test_kick_reset()
273263

274264
// Watchdog reset should have occurred during a wait above.
275265

276-
kick_wdg_during_test_teardown.release(); // For testsuite failure handling.
266+
hal_watchdog_kick();
267+
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
277268
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
278269
}
279270

@@ -308,10 +299,6 @@ int testsuite_setup(const size_t number_of_cases)
308299
return utest::v1::STATUS_ABORT;
309300
}
310301

311-
// The thread is started here, but feeding the watchdog will start
312-
// when the semaphore is released during a test case teardown.
313-
wdg_kicking_thread.start(mbed::callback(wdg_kicking_thread_fun));
314-
315302
utest_printf("This test suite is composed of %i test cases. Starting at index %i.\n", number_of_cases,
316303
current_case.start_index);
317304
return current_case.start_index;
@@ -338,4 +325,3 @@ int main()
338325
}
339326

340327
#endif // !DEVICE_WATCHDOG
341-
#endif // !MBED_CONF_RTOS_PRESENT

0 commit comments

Comments
 (0)