Skip to content

Commit fc2ea30

Browse files
golowanowkartben
authored andcommitted
tests: logging: logging.thread: fix race condition
Fix race condition in tests/subsys/logging/log_core_additional logging.thread test configuration released semaphore before log message output. Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
1 parent e57cf1e commit fc2ea30

File tree

1 file changed

+8
-8
lines changed
  • tests/subsys/logging/log_core_additional/src

1 file changed

+8
-8
lines changed

tests/subsys/logging/log_core_additional/src/log_test.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020 Intel Corporation
2+
* Copyright (c) 2020-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -95,13 +95,6 @@ static void process(const struct log_backend *const backend,
9595
"Unexpected log severity");
9696
}
9797

98-
cb->counter++;
99-
if (IS_ENABLED(CONFIG_LOG_PROCESS_THREAD)) {
100-
if (cb->counter == cb->total_logs) {
101-
k_sem_give(&log_sem);
102-
}
103-
}
104-
10598
if (k_is_user_context()) {
10699
zassert_equal(log_msg_get_domain(&(msg->log)), domain,
107100
"Unexpected domain id");
@@ -112,6 +105,13 @@ static void process(const struct log_backend *const backend,
112105

113106
flags = log_backend_std_get_flags();
114107
log_output_msg_process(&log_output, &msg->log, flags);
108+
109+
cb->counter++;
110+
if (IS_ENABLED(CONFIG_LOG_PROCESS_THREAD)) {
111+
if (cb->counter == cb->total_logs) {
112+
k_sem_give(&log_sem);
113+
}
114+
}
115115
}
116116

117117
static void panic(const struct log_backend *const backend)

0 commit comments

Comments
 (0)