Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #196, Fix timer-test to be able to use OS_MAX_TIMERS value #490

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/tests/timer-test/timer-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,29 @@
#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];

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks odd - variable declared without initializer and then defined with initializer. Possibly a remnant change? Should remove this addition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a typo. Fixed.

uint32 TimerStart[NUMBER_OF_TIMERS] = {1000, 2000000, 3000000, 4000000 };
uint32 TimerInterval[NUMBER_OF_TIMERS] = {500000, 400000, 800000, 600000 };

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);
Expand Down Expand Up @@ -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]);
Expand All @@ -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,
Expand All @@ -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]);
}
Expand All @@ -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]);
Expand Down Expand Up @@ -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)
Expand Down