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 7e25e9bd29..cd29d90d19 100644 --- a/testing/drivertest/drivertest_timer.c +++ b/testing/drivertest/drivertest_timer.c @@ -38,7 +38,7 @@ #include #include #include - +#include #include /**************************************************************************** @@ -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 \ @@ -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, timer_status.timeout); + assert_in_range(timer_status.timeleft, + 0, timer_state->interval); + + /* 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++) @@ -258,7 +274,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); }