diff --git a/tests/subsys/llext/simple/prj.conf b/tests/subsys/llext/simple/prj.conf index 5ad4b4e1f4b8e42..d2733eb1dc34f29 100644 --- a/tests/subsys/llext/simple/prj.conf +++ b/tests/subsys/llext/simple/prj.conf @@ -2,7 +2,8 @@ CONFIG_ZTEST=y CONFIG_ZTEST_STACK_SIZE=4096 CONFIG_LOG=y CONFIG_LLEXT=y -CONFIG_LLEXT_HEAP_SIZE=32 +CONFIG_LLEXT_HEAP_SIZE=64 +CONFIG_LLEXT_EXPORT_DEVICES=y CONFIG_LLEXT_LOG_LEVEL_DBG=y CONFIG_APPLICATION_DEFINED_SYSCALL=y diff --git a/tests/subsys/llext/simple/src/test_llext_simple.c b/tests/subsys/llext/simple/src/test_llext_simple.c index 2a33d92be4e72e8..bed02cd7feb9783 100644 --- a/tests/subsys/llext/simple/src/test_llext_simple.c +++ b/tests/subsys/llext/simple/src/test_llext_simple.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #if defined(CONFIG_FILE_SYSTEM_LITTLEFS) @@ -108,6 +109,9 @@ static void threads_objects_test_setup(struct llext *, struct k_thread *llext_th k_object_access_grant(&my_sem, llext_thread); k_object_access_grant(&my_thread, llext_thread); k_object_access_grant(&my_thread_stack, llext_thread); +#if DT_HAS_CHOSEN(zephyr_console) + k_object_access_grant(DEVICE_DT_GET(DT_CHOSEN(zephyr_console)), llext_thread); +#endif } #else /* No need to set up permissions for supervisor mode */ diff --git a/tests/subsys/llext/simple/src/threads_kernel_objects_ext.c b/tests/subsys/llext/simple/src/threads_kernel_objects_ext.c index ab9763b91215146..2fdcfb0282f13c5 100644 --- a/tests/subsys/llext/simple/src/threads_kernel_objects_ext.c +++ b/tests/subsys/llext/simple/src/threads_kernel_objects_ext.c @@ -5,21 +5,47 @@ */ /* - * This code demonstrates the use of threads and requires object - * relocation support. + * This code checks the functionality of threads (including synchronization + * primitives) and device access from extensions. + * This test should be valid from both user and privileged modes. */ #include #include +#include #include #include #include "threads_kernel_objects_ext.h" +/* + * This optional check is required because the current qemu_xtensa platform + * does not have any usable DT devices to test with. + */ +#if DT_HAS_CHOSEN(zephyr_console) +#define CONSOLE_DT_NODE DT_CHOSEN(zephyr_console) +#endif + void test_thread(void *arg0, void *arg1, void *arg2) { printk("Take semaphore from test thread\n"); k_sem_take(&my_sem, K_FOREVER); + +#ifdef CONSOLE_DT_NODE + const struct device *const console_dev = DEVICE_DT_GET(CONSOLE_DT_NODE); + const char *const console_name = DEVICE_DT_NAME(CONSOLE_DT_NODE); + const struct device *binding_dev; + + /* Ensure the console device was properly obtained at compile time */ + zassert_not_null(console_dev); + + /* Try to get the same handle at runtime and verify they match */ + binding_dev = device_get_binding(console_name); + zassert_equal(binding_dev, console_dev); + + /* Verify device API functionality, console must be ready in CI tests */ + zassert_true(device_is_ready(console_dev)); +#endif } void test_entry(void)