From 4d6315a6818fcbacaa5e2066cbe1b7ae1f436646 Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Mon, 29 Nov 2021 15:41:58 +0100 Subject: [PATCH] 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 --- subsys/testsuite/ztest/src/ztest.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/subsys/testsuite/ztest/src/ztest.c b/subsys/testsuite/ztest/src/ztest.c index dad2f4b53f2..ee08e4845e3 100644 --- a/subsys/testsuite/ztest/src/ztest.c +++ b/subsys/testsuite/ztest/src/ztest.c @@ -380,8 +380,10 @@ static int run_test(struct unit_test *test) test->teardown(); phase = TEST_PHASE_FRAMEWORK; - /* Flush all logs in case deferred mode is used. */ - while (IS_ENABLED(CONFIG_TEST_LOGGING_FLUSH_AFTER_TEST) && log_data_pending()) { + /* Flush all logs in case deferred mode and default logging thread are used. */ + while (IS_ENABLED(CONFIG_TEST_LOGGING_FLUSH_AFTER_TEST) && + IS_ENABLED(CONFIG_LOG_PROCESS_THREAD) && + log_data_pending()) { k_msleep(100); }