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 <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2021-11-29 15:41:58 +01:00 committed by Anas Nashif
commit 4d6315a681

View file

@ -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);
}