mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #10777 from fkjagodzinski/fix-watchdog-missing_commits
Bring back the missing watchdog commitspull/10899/head
commit
b3d45c5eef
|
@ -24,6 +24,7 @@
|
|||
#include "unity/unity.h"
|
||||
#include "utest/utest.h"
|
||||
#include "watchdog_api_tests.h"
|
||||
#include "mbed.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -35,7 +36,11 @@
|
|||
#define WORST_TIMEOUT_RESOLUTION_MS 8UL
|
||||
|
||||
#define TIMEOUT_DELTA_MS (WORST_TIMEOUT_RESOLUTION_MS)
|
||||
#define WDG_TIMEOUT_MS 500UL
|
||||
|
||||
// Do not set watchdog timeout shorter than 50 ms as it may cause the
|
||||
// host-test-runner return 'TIMEOUT' instead of 'FAIL' / 'PASS' if watchdog
|
||||
// performs reset during test suite teardown.
|
||||
#define WDG_TIMEOUT_MS 100UL
|
||||
|
||||
#define MSG_VALUE_DUMMY "0"
|
||||
#define MSG_VALUE_LEN 24
|
||||
|
@ -69,6 +74,18 @@ using utest::v1::Harness;
|
|||
|
||||
const watchdog_config_t WDG_CONFIG_DEFAULT = { .timeout_ms = WDG_TIMEOUT_MS };
|
||||
|
||||
Thread wdg_kicking_thread;
|
||||
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);
|
||||
|
@ -133,6 +150,8 @@ utest::v1::status_t case_setup_sync_on_reset(const Case *const source, const siz
|
|||
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)
|
||||
{
|
||||
// Unlock kicking the watchdog during teardown.
|
||||
kick_wdg_during_test_teardown.release();
|
||||
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.
|
||||
|
@ -206,6 +225,10 @@ 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;
|
||||
}
|
||||
|
@ -220,11 +243,8 @@ Case cases[] = {
|
|||
test_update_config,
|
||||
(utest::v1::case_teardown_handler_t) case_teardown_wdg_stop_or_reset),
|
||||
|
||||
// Do not set watchdog timeout shorter than 500 ms as it may cause the
|
||||
// host-test-runner return 'TIMEOUT' instead of 'FAIL' / 'PASS' if watchdog
|
||||
// performs reset during test suite teardown.
|
||||
Case("Init, 500 ms", (utest::v1::case_setup_handler_t) case_setup_sync_on_reset,
|
||||
test_init<500UL>, (utest::v1::case_teardown_handler_t) case_teardown_sync_on_reset),
|
||||
Case("Init, 100 ms", (utest::v1::case_setup_handler_t) case_setup_sync_on_reset,
|
||||
test_init<100UL>, (utest::v1::case_teardown_handler_t) case_teardown_sync_on_reset),
|
||||
Case("Init, max_timeout", (utest::v1::case_setup_handler_t) case_setup_sync_on_reset,
|
||||
test_init_max_timeout, (utest::v1::case_teardown_handler_t) case_teardown_sync_on_reset),
|
||||
};
|
||||
|
|
|
@ -25,13 +25,14 @@
|
|||
#include "watchdog_reset_tests.h"
|
||||
#include "mbed.h"
|
||||
|
||||
#define TIMEOUT_MS 500UL
|
||||
#if TARGET_NUMAKER_PFM_NANO130
|
||||
/* On NUMAKER_PFM_NANO130 target, WDT's clock source is fixed to LIRC, which is more
|
||||
* inaccurate than other targets. Enlarge this delta define to pass this test. */
|
||||
#define TIMEOUT_MS 500UL
|
||||
#define TIMEOUT_DELTA_MS 100UL
|
||||
#else
|
||||
#define TIMEOUT_DELTA_MS 50UL
|
||||
#define TIMEOUT_MS 100UL
|
||||
#define TIMEOUT_DELTA_MS 10UL
|
||||
#endif
|
||||
|
||||
#define MSG_VALUE_DUMMY "0"
|
||||
|
|
|
@ -50,6 +50,12 @@ testcase_data current_case;
|
|||
template<uint32_t timeout_ms, uint32_t delta_ms>
|
||||
void test_timing()
|
||||
{
|
||||
watchdog_features_t features = hal_watchdog_get_platform_features();
|
||||
if (timeout_ms > features.max_timeout) {
|
||||
TEST_IGNORE_MESSAGE("Requested timeout value not supported for this target -- ignoring test case.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Phase 2. -- verify the test results.
|
||||
// Verify the heartbeat time span sent by host is within given delta.
|
||||
if (current_case.received_data != CASE_DATA_INVALID) {
|
||||
|
|
Loading…
Reference in New Issue