From 4dfcb3e8acc57a6a12418474974c07bfa0dbc320 Mon Sep 17 00:00:00 2001 From: Yasir Khan Date: Thu, 4 Jun 2020 13:16:25 -0400 Subject: [PATCH 1/2] Fix #196, Fix timer-test to be able to use OS_MAX_TIMERS value --- src/tests/timer-test/timer-test.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/tests/timer-test/timer-test.c b/src/tests/timer-test/timer-test.c index 73bf0c242..5f7f08604 100644 --- a/src/tests/timer-test/timer-test.c +++ b/src/tests/timer-test/timer-test.c @@ -20,12 +20,16 @@ #define TASK_1_STACK_SIZE 4096 #define TASK_1_PRIORITY 101 + void TimerTestSetup(void); void TimerTestTask(void); void TimerTestCheck(void); OS_time_t StartTime; OS_time_t EndTime; +uint32 TimerStart[NUMBER_OF_TIMERS]; +uint32 TimerInterval[NUMBER_OF_TIMERS]; + uint32 TimerStart[NUMBER_OF_TIMERS] = {1000, 2000000, 3000000, 4000000 }; uint32 TimerInterval[NUMBER_OF_TIMERS] = {500000, 400000, 800000, 600000 }; @@ -33,11 +37,12 @@ uint32 TimerTestTaskStack[TASK_1_STACK_SIZE]; int32 timer_counter[NUMBER_OF_TIMERS]; uint32 timer_idlookup[OS_MAX_TIMERS]; + /* -** Test timer function. -** Note: For some Host OSs, this is the equivalent of an ISR, so the calls available are limited. -** For example, Linux and vxWorks can call functions like printf, but RTEMS cannot. -*/ + * Test timer function. + * Note: For some Host OSs, this is the equivalent of an ISR, so the calls available are limited. + * For example, Linux and vxWorks can call functions like printf, but RTEMS cannot. + */ void test_func(uint32 timer_id) { OS_ConvertToArrayIndex(timer_id, &timer_id); @@ -99,7 +104,7 @@ void TimerTestTask(void) uint32 ClockAccuracy; - for ( i = 0; i < NUMBER_OF_TIMERS; i++ ) + for ( i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++ ) { TimerStatus[i] = OS_TimerCreate(&TimerID[i], TimerName[i], &ClockAccuracy, &(test_func)); UtAssert_True(TimerStatus[i] == OS_SUCCESS, "Timer %d Created RC=%d ID=%d", i, (int)TimerStatus[i], (int)TimerID[i]); @@ -112,7 +117,7 @@ void TimerTestTask(void) /* Sample the clock now, before starting any timer */ OS_GetLocalTime(&StartTime); - for ( i = 0; i < NUMBER_OF_TIMERS; i++ ) + for ( i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++ ) { /* * to ensure that all timers are started as closely as possible, @@ -124,7 +129,7 @@ void TimerTestTask(void) /* * Now the actual OS_TimerSet() return code can be checked. */ - for ( i = 0; i < NUMBER_OF_TIMERS; i++ ) + for ( i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++ ) { UtAssert_True(TimerStatus[i] == OS_SUCCESS, "Timer %d programmed RC=%d", i, (int)TimerStatus[i]); } @@ -145,12 +150,12 @@ void TimerTestTask(void) } OS_GetLocalTime(&EndTime); - for ( i = 0; i < NUMBER_OF_TIMERS; i++ ) + for ( i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++ ) { TimerStatus[i] = OS_TimerDelete(TimerID[i]); } - for ( i = 0; i < NUMBER_OF_TIMERS; i++ ) + for ( i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++ ) { UtAssert_True(TimerStatus[i] == OS_SUCCESS, "Timer %d delete RC=%d. Count total = %d", i, (int)TimerStatus[i], (int)timer_counter[i]); @@ -180,7 +185,7 @@ void TimerTestCheck(void) } /* Make sure the ratio of the timers are OK */ - for ( i = 0; i < NUMBER_OF_TIMERS; i++ ) + for ( i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++ ) { /* * Expect one tick after the start time (i.e. first tick) From 80bca3f383658b900087e35f58c6291472b7b2dd Mon Sep 17 00:00:00 2001 From: Yasir Khan Date: Fri, 5 Jun 2020 14:36:40 -0400 Subject: [PATCH 2/2] Fix #196, removed redefinition of a variables as requested --- src/tests/timer-test/timer-test.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/tests/timer-test/timer-test.c b/src/tests/timer-test/timer-test.c index 5f7f08604..4d0ed061a 100644 --- a/src/tests/timer-test/timer-test.c +++ b/src/tests/timer-test/timer-test.c @@ -27,9 +27,6 @@ void TimerTestCheck(void); OS_time_t StartTime; OS_time_t EndTime; -uint32 TimerStart[NUMBER_OF_TIMERS]; -uint32 TimerInterval[NUMBER_OF_TIMERS]; - uint32 TimerStart[NUMBER_OF_TIMERS] = {1000, 2000000, 3000000, 4000000 }; uint32 TimerInterval[NUMBER_OF_TIMERS] = {500000, 400000, 800000, 600000 };