Skip to content

Commit

Permalink
Fix #299 que test uses sequence of numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
zanzaben committed Jan 4, 2021
1 parent 3a29e2e commit 0b6cc39
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/tests/queue-test/queue-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ void task_1(void)
{
int32 status;
size_t data_size;
char data_received[4] = {0};
char expected[4] = "xyz";
uint32 data_received ;
uint32 expected = 0;

OS_printf("Starting task 1\n");

Expand All @@ -84,8 +84,10 @@ void task_1(void)
if (status == OS_SUCCESS)
{
++task_1_messages;
UtAssert_True(strcmp(data_received, expected) == 0, "TASK 1: data_received (%s) == expected (%s)",
UtAssert_True(data_received == expected, "TASK 1: data_received (%u) == expected (%u)",
data_received, expected);

expected++;
}
else if (status == OS_QUEUE_TIMEOUT)
{
Expand Down Expand Up @@ -194,13 +196,12 @@ void QueueMessageSetup(void)
{
int32 status;
uint32 accuracy;
int i;
uint32 Data = 0;
task_1_failures = 0;
task_1_messages = 0;
task_1_timeouts = 0;

int i;
const char Data[4] = "xyz";


status = OS_QueueCreate(&msgq_id, "MsgQ", OSAL_BLOCKCOUNT_C(MSGQ_DEPTH), OSAL_SIZE_C(MSGQ_SIZE), 0);
UtAssert_True(status == OS_SUCCESS, "MsgQ create Id=%lx Rc=%d", OS_ObjectIdToInteger(msgq_id), (int)status);

Expand All @@ -224,11 +225,17 @@ void QueueMessageSetup(void)
status = OS_TimerSet(timer_id, timer_start, timer_interval);
UtAssert_True(status == OS_SUCCESS, "Timer 1 set Rc=%d", (int)status);

/* Put 10 messages onto the que with some time inbetween to not overfill the que*/
/*
* Put 10 messages onto the que with some time inbetween the later messages
* to make sure the que handles both storing and waiting for messages
*/
for (i = 0; i < 10; i++)
{
OS_TaskDelay(200);
status = OS_QueuePut(msgq_id, Data, sizeof(Data), 0);
if(i > 3)
OS_TaskDelay(400);

Data = i;
status = OS_QueuePut(msgq_id, (void *)&Data, sizeof(Data), 0);
UtAssert_True(status == OS_SUCCESS, "OS Queue Put Rc=%d", (int)status);
}
}
Expand Down

0 comments on commit 0b6cc39

Please sign in to comment.