logging: fix logging.async test

Test has code to test conditions where CONFIG_LOG_PROCESS_THREAD=y
but this option was not enabled in any of the tests. This code was
using removed APIs and did not build anymore. This change enables
the log thread for the logging.async and fixes the tests.

Signed-off-by: Corey Wharton <xodus7@cwharton.com>
This commit is contained in:
Corey Wharton 2024-04-15 16:15:54 -07:00 committed by Anas Nashif
commit 2b9c552050
3 changed files with 29 additions and 12 deletions

View file

@ -0,0 +1,18 @@
CONFIG_MAIN_THREAD_PRIORITY=5
CONFIG_ZTEST=y
CONFIG_TEST_LOGGING_DEFAULTS=n
CONFIG_LOG=y
CONFIG_LOG_OUTPUT=y
CONFIG_LOG_PRINTK=n
CONFIG_LOG_SPEED=y
CONFIG_LOG_BUFFER_SIZE=1024
CONFIG_CBPRINTF_FP_SUPPORT=y
CONFIG_CBPRINTF_LIBC_SUBSTS=y
CONFIG_ZTEST_STACK_SIZE=4096
CONFIG_LOG_MODE_DEFERRED=y
CONFIG_LOG_PROCESS_THREAD_SLEEP_MS=200
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_MPSC_CLEAR_ALLOCATED=y
CONFIG_LOG_BACKEND_UART=y
CONFIG_THREAD_MONITOR=y

View file

@ -409,8 +409,6 @@ ZTEST(test_log_core_additional, test_multiple_backends)
#ifdef CONFIG_LOG_PROCESS_THREAD
ZTEST(test_log_core_additional, test_log_thread)
{
uint32_t slabs_free, used, max;
TC_PRINT("Logging buffer is configured to %d bytes\n",
CONFIG_LOG_BUFFER_SIZE);
@ -420,25 +418,19 @@ ZTEST(test_log_core_additional, test_log_thread)
log_setup(false);
slabs_free = log_msg_mem_get_free();
used = log_msg_mem_get_used();
max = log_msg_mem_get_max_used();
zassert_equal(used, 0);
zassert_false(log_data_pending());
LOG_INF("log info to log thread");
LOG_WRN("log warning to log thread");
LOG_ERR("log error to log thread");
zassert_equal(log_msg_mem_get_used(), 3);
zassert_equal(log_msg_mem_get_free(), slabs_free - 3);
zassert_equal(log_msg_mem_get_max_used(), max);
zassert_true(log_data_pending());
TC_PRINT("after log, free: %d, used: %d, max: %d\n", slabs_free, used, max);
/* wait 2 seconds for logging thread to handle this log message*/
k_sleep(K_MSEC(2000));
zassert_equal(3, backend1_cb.counter,
"Unexpected amount of messages received by the backend.");
zassert_equal(log_msg_mem_get_used(), 0);
zassert_false(log_data_pending());
}
#else
ZTEST(test_log_core_additional, test_log_thread)
@ -491,7 +483,9 @@ ZTEST(test_log_core_additional, test_log_msg_create)
Z_LOG_MSG_CREATE(!IS_ENABLED(CONFIG_USERSPACE), mode,
Z_LOG_LOCAL_DOMAIN_ID, NULL,
LOG_LEVEL_INTERNAL_RAW_STRING, NULL, 0, TEST_MESSAGE);
LOG_LEVEL_INF, NULL, 0, TEST_MESSAGE);
backend1_cb.total_logs = 3;
while (log_test_process()) {
}

View file

@ -9,3 +9,8 @@ tests:
extra_args: CONF_FILE=log_sync.conf
integration_platforms:
- native_sim
logging.thread:
tags: logging
extra_args: CONF_FILE=log_thread.conf
integration_platforms:
- native_sim