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 #1318, adjust timing on condvar tests #1319

Merged
merged 1 commit into from
Oct 26, 2022
Merged
Changes from all commits
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
14 changes: 10 additions & 4 deletions src/tests/condvar-test/condvar-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void condvar_worker(uint32 my_num)
++my_state->run_count;
UtPrintf("Doing Work task %u, mask=0x%x condition was=%x\n", (unsigned int)my_num, (unsigned int)my_state->mask,
(unsigned int)prev_condition);
OS_TaskDelay(50 + (NUM_TASKS * 5));
OS_TaskDelay(25 + (NUM_TASKS * 5));
}
}

Expand Down Expand Up @@ -169,7 +169,6 @@ void CondVarTest_Execute(void)
UtAssert_UINT32_EQ(total_work, num_signals);
UtAssert_UINT32_NEQ(curr_condition, ALL_RUN_CONDITION);
UtAssert_UINT32_NEQ(curr_condition, 0);
UtAssert_UINT32_EQ(task_states[i].run_count, 1);
UtAssert_INT32_EQ(OS_CondVarUnlock(condvar_id), OS_SUCCESS);

UtAssert_INT32_EQ(OS_CondVarSignal(condvar_id), OS_SUCCESS);
Expand All @@ -180,13 +179,19 @@ void CondVarTest_Execute(void)

/* after a the last signal, all the other tasks should have run */
UtAssert_INT32_EQ(OS_CondVarLock(condvar_id), OS_SUCCESS);
for (i = 0; i < NUM_TASKS; ++i)
{
UtAssert_UINT32_EQ(task_states[i].run_count, 1);
}
UtAssert_UINT32_EQ(total_work, num_signals);
UtAssert_BITMASK_UNSET(curr_condition, ALL_RUN_CONDITION);
curr_condition = ALL_RUN_CONDITION;
UtAssert_INT32_EQ(OS_CondVarBroadcast(condvar_id), OS_SUCCESS);
UtAssert_INT32_EQ(OS_CondVarUnlock(condvar_id), OS_SUCCESS);

OS_TaskDelay(100);
/* Give sufficient time for all tasks to wake up and do their work */
OS_TaskDelay(100 + (NUM_TASKS * 10));

UtAssert_INT32_EQ(OS_CondVarLock(condvar_id), OS_SUCCESS);
UtAssert_BITMASK_UNSET(curr_condition, ALL_RUN_CONDITION);
for (i = 0; i < NUM_TASKS; ++i)
Expand All @@ -198,7 +203,8 @@ void CondVarTest_Execute(void)
UtAssert_INT32_EQ(OS_CondVarBroadcast(condvar_id), OS_SUCCESS);
UtAssert_INT32_EQ(OS_CondVarUnlock(condvar_id), OS_SUCCESS);

OS_TaskDelay(20);
/* Give sufficient time for all tasks to wake up and do their work */
OS_TaskDelay(100 + (NUM_TASKS * 10));

UtAssert_INT32_EQ(OS_CondVarLock(condvar_id), OS_SUCCESS);
UtAssert_UINT32_EQ(total_work, (NUM_TASKS * 2) + 1);
Expand Down