tests/kernel: fifo_timeout: Remove wake-up order checking
There is no guarantee of wake-up order when multiple threads are woken up on the same tick. Hence, modified the tests accordingly. Fixes #8159. Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
This commit is contained in:
parent
6da970e593
commit
fa77e400aa
1 changed files with 35 additions and 4 deletions
|
@ -135,7 +135,8 @@ static void test_thread_pend_and_timeout(void *p1, void *p2, void *p3)
|
|||
static int test_multiple_threads_pending(struct timeout_order_data *test_data,
|
||||
int test_data_size)
|
||||
{
|
||||
int ii;
|
||||
int ii, j;
|
||||
u32_t diff_ms;
|
||||
|
||||
for (ii = 0; ii < test_data_size; ii++) {
|
||||
tid[ii] = k_thread_create(&ttdata[ii], ttstack[ii], TSTACK_SIZE,
|
||||
|
@ -144,6 +145,14 @@ static int test_multiple_threads_pending(struct timeout_order_data *test_data,
|
|||
FIFO_THREAD_PRIO, K_INHERIT_PERMS, 0);
|
||||
}
|
||||
|
||||
/* In general, there is no guarantee of wakeup order when multiple
|
||||
* threads are woken up on the same tick. This can especially happen
|
||||
* when the system is loaded. However, in this particular test, we
|
||||
* are controlling the system state and hence we can make a reasonable
|
||||
* estimation of a timeout occurring with the max deviation of an
|
||||
* additional tick. Hence the timeout order may slightly be different
|
||||
* from what we normally expect.
|
||||
*/
|
||||
for (ii = 0; ii < test_data_size; ii++) {
|
||||
struct timeout_order_data *data =
|
||||
k_fifo_get(&timeout_order_fifo, K_FOREVER);
|
||||
|
@ -152,9 +161,31 @@ static int test_multiple_threads_pending(struct timeout_order_data *test_data,
|
|||
TC_PRINT(" thread (q order: %d, t/o: %d, fifo %p)\n",
|
||||
data->q_order, data->timeout, data->fifo);
|
||||
} else {
|
||||
TC_ERROR(" *** thread %d woke up, expected %d\n",
|
||||
data->timeout_order, ii);
|
||||
return TC_FAIL;
|
||||
/* Get the index of the thread which should have
|
||||
* actually timed out.
|
||||
*/
|
||||
for (j = 0; j < test_data_size; j++) {
|
||||
if (test_data[j].timeout_order == ii) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (data->timeout > test_data[j].timeout) {
|
||||
diff_ms = data->timeout - test_data[j].timeout;
|
||||
} else {
|
||||
diff_ms = test_data[j].timeout - data->timeout;
|
||||
}
|
||||
|
||||
if (_ms_to_ticks(diff_ms) == 1) {
|
||||
TC_PRINT(
|
||||
" thread (q order: %d, t/o: %d, fifo %p)\n",
|
||||
data->q_order, data->timeout, data->fifo);
|
||||
} else {
|
||||
TC_ERROR(
|
||||
" *** thread %d woke up, expected %d\n",
|
||||
data->timeout_order, ii);
|
||||
return TC_FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue