From 9a34ca7b71e18c37a6391f3b205a09b093beffc3 Mon Sep 17 00:00:00 2001 From: yangguangcai Date: Thu, 23 Mar 2023 21:55:39 +0800 Subject: [PATCH 1/3] testing/drivertest:fix variable may be negative Signed-off-by: yangguangcai --- testing/drivertest/drivertest_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/drivertest/drivertest_timer.c b/testing/drivertest/drivertest_timer.c index 7e25e9bd29..8694d71564 100644 --- a/testing/drivertest/drivertest_timer.c +++ b/testing/drivertest/drivertest_timer.c @@ -258,7 +258,7 @@ static void test_case_timer(FAR void **state) tim = get_timestamp(); usleep(2 * timer_state->interval); tim = get_timestamp() - tim; - range = timer_state->interval / 1000 - tim; + range = abs(timer_state->interval / 1000 - tim); assert_in_range(range, 0, timer_state->range); } From 81da45f157375b84257b7a1be0aee86b3eaefdcd Mon Sep 17 00:00:00 2001 From: yangguangcai Date: Fri, 12 May 2023 17:09:28 +0800 Subject: [PATCH 2/3] drivertest/timer:test interface getstatus. Signed-off-by: yangguangcai --- testing/drivertest/drivertest_timer.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/testing/drivertest/drivertest_timer.c b/testing/drivertest/drivertest_timer.c index 8694d71564..8ab7354283 100644 --- a/testing/drivertest/drivertest_timer.c +++ b/testing/drivertest/drivertest_timer.c @@ -38,7 +38,7 @@ #include #include #include - +#include #include /**************************************************************************** @@ -209,8 +209,10 @@ static void test_case_timer(FAR void **state) int ret; uint32_t range; uint32_t tim; + uint32_t max_timeout; struct sigaction act; struct timer_notify_s notify; + struct timer_status_s timer_status; FAR struct timer_state_s *timer_state; timer_state = (FAR struct timer_state_s *)*state; @@ -251,6 +253,20 @@ static void test_case_timer(FAR void **state) ret = ioctl(fd, TCIOC_START, 0); assert_return_code(ret, OK); + /* Get status */ + + ret = ioctl(fd, TCIOC_GETSTATUS, &timer_status); + assert_return_code(ret, OK); + assert_int_equal(timer_state->interval / 1000, timer_status.timeout); + assert_in_range(timer_status.timeleft, + 0, timer_state->interval / 1000); + + /* Get max timeout */ + + ret = ioctl(fd, TCIOC_MAXTIMEOUT, &max_timeout); + assert_return_code(ret, OK); + syslog(LOG_DEBUG, "max timeout:%ld\n", max_timeout); + /* Set the timer interval */ for (i = 0; i < timer_state->nsamples; i++) From b41160af51ab353c157d61dcffeea4cbd3efab7f Mon Sep 17 00:00:00 2001 From: yangguangcai Date: Thu, 25 May 2023 14:19:10 +0800 Subject: [PATCH 3/3] drivertest:fix timer testcase Signed-off-by: yangguangcai --- testing/drivertest/Makefile | 2 ++ testing/drivertest/drivertest_timer.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/testing/drivertest/Makefile b/testing/drivertest/Makefile index bc4a5ecf49..62d73bc40c 100644 --- a/testing/drivertest/Makefile +++ b/testing/drivertest/Makefile @@ -36,9 +36,11 @@ MAINSRC += drivertest_block.c endif ifneq ($(CONFIG_RTC),) +ifneq ($(CONFIG_SIG_EVTHREAD),) MAINSRC += drivertest_rtc.c PROGNAME += cmocka_driver_rtc endif +endif ifneq ($(CONFIG_TIMER),) MAINSRC += drivertest_timer.c diff --git a/testing/drivertest/drivertest_timer.c b/testing/drivertest/drivertest_timer.c index 8ab7354283..cd29d90d19 100644 --- a/testing/drivertest/drivertest_timer.c +++ b/testing/drivertest/drivertest_timer.c @@ -48,8 +48,8 @@ #define TIMER_DEFAULT_DEVPATH "/dev/timer0" #define TIMER_DEFAULT_INTERVAL 1000000 #define TIMER_DEFAULT_NSAMPLES 20 -#define TIMER_DEFAULT_SIGNO 32 -#define TIMER_DEFAULT_RANGE 1 +#define TIMER_DEFAULT_SIGNO 31 +#define TIMER_DEFAULT_RANGE 1000 #define OPTARG_TO_VALUE(value, type, base) \ do \ @@ -257,9 +257,9 @@ static void test_case_timer(FAR void **state) ret = ioctl(fd, TCIOC_GETSTATUS, &timer_status); assert_return_code(ret, OK); - assert_int_equal(timer_state->interval / 1000, timer_status.timeout); + assert_int_equal(timer_state->interval, timer_status.timeout); assert_in_range(timer_status.timeleft, - 0, timer_state->interval / 1000); + 0, timer_state->interval); /* Get max timeout */