fix add functional test of one shot timer.
#include "uttest.h"
#include "utbsp.h"
-#define NUMBER_OF_TIMERS 4
+#define NUMBER_OF_TIMERS 5
#define TASK_1_ID 1
#define TASK_1_STACK_SIZE 4096
@@ -45,8 +45,8 @@ void TimerTestCheck(void);
OS_time_t StartTime;
OS_time_t EndTime;
-uint32 TimerStart[NUMBER_OF_TIMERS] = {1000, 2000000, 3000000, 4000000};
-uint32 TimerInterval[NUMBER_OF_TIMERS] = {500000, 400000, 800000, 600000};
+uint32 TimerStart[NUMBER_OF_TIMERS] = {1000, 2000000, 3000000, 4000000, 1000000};
+uint32 TimerInterval[NUMBER_OF_TIMERS] = {500000, 400000, 800000, 600000, 0};
uint32 TimerTestTaskStack[TASK_1_STACK_SIZE];
int32 timer_counter[NUMBER_OF_TIMERS];
@@ -115,7 +115,7 @@ void TimerTestTask(void)
int32 TimerStatus[NUMBER_OF_TIMERS];
osal_index_t TableId;
osal_id_t TimerID[NUMBER_OF_TIMERS];
- char TimerName[NUMBER_OF_TIMERS][20] = {"TIMER1", "TIMER2", "TIMER3", "TIMER4"};
+ char TimerName[NUMBER_OF_TIMERS][20] = {"TIMER1", "TIMER2", "TIMER3", "TIMER4", "TIMER5"};
uint32 ClockAccuracy;
for (i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++)
@@ -201,6 +201,16 @@ void TimerTestCheck(void)
/* Make sure the ratio of the timers are OK */
for (i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++)
+ {
+ if (TimerInterval[i] == 0)
+ {
+ /*
+ * When the Timer Interval is 0, it's a one shot so expect eaxctly 1 tick
+ */
+ expected = 1;
+ UtAssert_True(timer_counter[i] == (expected), "Timer %d count = %d", (int)i, (int)(expected));
+ }
+ else
{
/*
* Expect one tick after the start time (i.e. first tick)
@@ -217,3 +227,4 @@ void TimerTestCheck(void)
UtAssert_True(timer_counter[i] <= (expected + 3), "Timer %d count <= %d", (int)i, (int)(expected + 3));
}
}
+}
