From 4d9507ae335dcf72343ea45da5753b9af00ccc67 Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Wed, 12 Jan 2022 09:16:45 +0100 Subject: [PATCH] testsuite: ztress: Minor fixes Fix initial thread priority and move starting of the test timer after threads initialization to ensure that it does not expire before threads are initiated. Signed-off-by: Krzysztof Chruscinski --- subsys/testsuite/ztest/src/ztress.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/subsys/testsuite/ztest/src/ztress.c b/subsys/testsuite/ztest/src/ztress.c index 57c0e7d3756..42406648964 100644 --- a/subsys/testsuite/ztest/src/ztress.c +++ b/subsys/testsuite/ztest/src/ztress.c @@ -322,18 +322,18 @@ int ztress_execute(struct ztress_context_data *timer_data, ztress_init(thread_data); context_cnt = cnt + (timer_data ? 1 : 0); - priority = K_LOWEST_THREAD_PRIO - cnt - 1; + priority = K_LOWEST_APPLICATION_THREAD_PRIO - cnt - 1; k_thread_priority_set(k_current_get(), priority); priority++; tmr_data = timer_data; + if (timer_data != NULL) { active_cnt_init(timer_data); backoff[ztress_prio] = timer_data->t; init_backoff[ztress_prio] = timer_data->t; k_timer_user_data_set(&ztress_timer, timer_data); - k_timer_start(&ztress_timer, backoff[ztress_prio], K_NO_WAIT); ztress_prio++; } @@ -350,6 +350,10 @@ int ztress_execute(struct ztress_context_data *timer_data, ztress_prio++; } + if (timer_data != NULL) { + k_timer_start(&ztress_timer, backoff[0], K_NO_WAIT); + } + /* Wait until all threads complete. */ for (int i = 0; i < cnt; i++) { k_thread_join(tids[i], K_FOREVER);