tests: logging: restore userspace testing
Restore userspace testing that was removed with commit 'aa2b72d32a
(tests: logging: remove userspace testing, 2024-04-10)' and reported in
the issue #49213.
For the tests running with threads in user space (with ZTEST_USER),
the memory partitions are configured in the test-suite setup.
Signed-off-by: Christoph Winklhofer <cj.winklhofer@gmail.com>
This commit is contained in:
parent
501f33edea
commit
3b29b9fa3b
3 changed files with 30 additions and 1 deletions
|
@ -5,9 +5,11 @@ CONFIG_TEST_LOGGING_DEFAULTS=n
|
|||
CONFIG_LOG=y
|
||||
CONFIG_LOG_OUTPUT=y
|
||||
CONFIG_LOG_RUNTIME_FILTERING=y
|
||||
CONFIG_LOG_ALWAYS_RUNTIME=y
|
||||
CONFIG_LOG_PROCESS_THREAD=n
|
||||
CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD=1
|
||||
CONFIG_THREAD_MONITOR=y
|
||||
CONFIG_LOG_PRINTK=y
|
||||
CONFIG_LOG_PRINTK=n
|
||||
CONFIG_LOG_BLOCK_IN_THREAD=y
|
||||
CONFIG_MAIN_STACK_SIZE=4096
|
||||
CONFIG_STACK_SENTINEL=n
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <zephyr/logging/log.h>
|
||||
#include <zephyr/logging/log_output.h>
|
||||
#include <zephyr/sys/iterable_sections.h>
|
||||
#include <zephyr/sys/libc-hooks.h>
|
||||
|
||||
#define TEST_MESSAGE "test msg"
|
||||
|
||||
|
@ -33,6 +34,18 @@ ZTEST_BMEM uint32_t source_id;
|
|||
ZTEST_BMEM uint8_t domain, level;
|
||||
ZTEST_DMEM uint32_t msg_data = 0x1234;
|
||||
|
||||
/* Memory domain for tests with threads in user space (ZTEST_USER) */
|
||||
#if CONFIG_USERSPACE
|
||||
static struct k_mem_domain mem_domain;
|
||||
static struct k_mem_partition *mem_parts[] = {
|
||||
#if Z_LIBC_PARTITION_EXISTS
|
||||
&z_libc_partition,
|
||||
#endif
|
||||
&ztest_mem_partition,
|
||||
&k_log_partition
|
||||
};
|
||||
#endif
|
||||
|
||||
static uint8_t buf;
|
||||
static int char_out(uint8_t *data, size_t length, void *ctx)
|
||||
{
|
||||
|
@ -571,6 +584,12 @@ static void *test_log_core_additional_setup(void)
|
|||
#ifdef CONFIG_LOG_PROCESS_THREAD
|
||||
k_thread_foreach(promote_log_thread, NULL);
|
||||
#endif
|
||||
|
||||
#if CONFIG_USERSPACE
|
||||
/* Set memory domain for threads in user space */
|
||||
k_mem_domain_init(&mem_domain, ARRAY_SIZE(mem_parts), mem_parts);
|
||||
k_mem_domain_add_thread(&mem_domain, k_current_get());
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,3 +14,11 @@ tests:
|
|||
extra_args: CONF_FILE=log_thread.conf
|
||||
integration_platforms:
|
||||
- native_sim
|
||||
logging.log_user:
|
||||
tags: logging
|
||||
filter: CONFIG_USERSPACE
|
||||
extra_args:
|
||||
- CONF_FILE=log_user.conf
|
||||
- USERSPACE_TEST=1
|
||||
integration_platforms:
|
||||
- qemu_x86
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue