This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit d02596835f894a8c6196ba56faf03780f25447d4 Author: yangguangcai <[email protected]> AuthorDate: Mon Nov 27 21:25:11 2023 +0800 drivertest/watchdog:add parameter to avoid testing api getstatus. some vendor hardware not support get watchdog status. Signed-off-by: yangguangcai <[email protected]> --- testing/drivertest/drivertest_watchdog.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/testing/drivertest/drivertest_watchdog.c b/testing/drivertest/drivertest_watchdog.c index 65fa8ac94..a5ba7a8b9 100644 --- a/testing/drivertest/drivertest_watchdog.c +++ b/testing/drivertest/drivertest_watchdog.c @@ -80,6 +80,7 @@ struct wdg_state_s uint32_t timeout; uint32_t deviation; int test_case; + bool test_getstatus; }; /**************************************************************************** @@ -161,7 +162,7 @@ static void show_usage(FAR const char *progname, FAR struct wdg_state_s *wdg_state, int exitcode) { printf("Usage: %s -d <devpath> -r <test case> -t <pingtime>" - "-l <pingdelay> -o <timeout> -a <deviation>\n", progname); + "-l <pingdelay> -o <timeout> -a <deviation> -g\n", progname); printf(" [-d devpath] selects the WATCHDOG device.\n" " Default: %s Current: %s\n", WDG_DEFAULT_DEV_PATH, wdg_state->devpath); @@ -180,6 +181,7 @@ static void show_usage(FAR const char *progname, printf(" [-a deviation] Watchdog getstatus precision.\n" " Default: %d Current: %" PRIu32 "\n", WDG_DEFAULT_DEVIATION, wdg_state->deviation); + printf(" [-g] don't test getstatus\n"); printf(" [-h] = Shows this message and exits\n"); exit(exitcode); @@ -195,7 +197,7 @@ static void parse_commandline(FAR struct wdg_state_s *wdg_state, int argc, int ch; int converted; - while ((ch = getopt(argc, argv, "d:r:t:l:o:a:h")) != ERROR) + while ((ch = getopt(argc, argv, "d:r:t:l:o:a:gh")) != ERROR) { switch (ch) { @@ -257,6 +259,9 @@ static void parse_commandline(FAR struct wdg_state_s *wdg_state, int argc, } wdg_state->deviation = (uint32_t)converted; + + case 'g': + wdg_state->test_getstatus = false; break; case '?': @@ -442,16 +447,19 @@ static void test_case_wdog_04(FAR void **state) usleep(wdg_state->pingdelay * 1000); - /* Get Status */ + if (wdg_state->test_getstatus) + { + /* Get Status */ - ret = ioctl(dev_fd, WDIOC_GETSTATUS, &status); - assert_return_code(ret, OK); + ret = ioctl(dev_fd, WDIOC_GETSTATUS, &status); + assert_return_code(ret, OK); - assert_int_equal(status.timeout, wdg_state->timeout); - assert_in_range( - status.timeout - status.timeleft, - wdg_state->pingdelay - wdg_state->deviation, - wdg_state->pingdelay + wdg_state->deviation); + assert_int_equal(status.timeout, wdg_state->timeout); + assert_in_range( + status.timeout - status.timeleft, + wdg_state->pingdelay - wdg_state->deviation, + wdg_state->pingdelay + wdg_state->deviation); + } /* Then ping */ @@ -485,7 +493,8 @@ int main(int argc, FAR char *argv[]) .pingdelay = WDG_DEFAULT_PINGDELAY, .timeout = WDG_DEFAULT_TIMEOUT, .test_case = WDG_DEFAULT_TESTCASE, - .deviation = WDG_DEFAULT_DEVIATION + .deviation = WDG_DEFAULT_DEVIATION, + .test_getstatus = true }; parse_commandline(&wdg_state, argc, argv);
