Skip to content

Commit 4d6315a

Browse files
nordic-krchnashif
authored andcommitted
testsuite: ztest: Do logging flush only when default thread is used
Add guard to not pend until all logs are flushed when default logging thread is disabled. In that case, logging has no control where logs are processed and sleeping may not lead to flushing log data. That may result in test hanging. Signed-off-by: Krzysztof Chruscinski <[email protected]>
1 parent 57d41ad commit 4d6315a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

subsys/testsuite/ztest/src/ztest.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,10 @@ static int run_test(struct unit_test *test)
380380
test->teardown();
381381
phase = TEST_PHASE_FRAMEWORK;
382382

383-
/* Flush all logs in case deferred mode is used. */
384-
while (IS_ENABLED(CONFIG_TEST_LOGGING_FLUSH_AFTER_TEST) && log_data_pending()) {
383+
/* Flush all logs in case deferred mode and default logging thread are used. */
384+
while (IS_ENABLED(CONFIG_TEST_LOGGING_FLUSH_AFTER_TEST) &&
385+
IS_ENABLED(CONFIG_LOG_PROCESS_THREAD) &&
386+
log_data_pending()) {
385387
k_msleep(100);
386388
}
387389

0 commit comments

Comments
 (0)