@@ -40,11 +40,11 @@ LOG_MODULE_REGISTER(test_llext_simple);
4040
4141struct llext_test {
4242 const char * name ;
43- bool try_userspace ;
44- size_t buf_len ;
4543
4644 LLEXT_CONST uint8_t * buf ;
45+ size_t buf_len ;
4746
47+ bool kernel_only ;
4848 void (* perm_setup )(struct k_thread * llext_thread );
4949};
5050
@@ -105,7 +105,7 @@ static void threads_objects_perm_setup(struct k_thread *llext_thread)
105105#define threads_objects_perm_setup NULL
106106#endif /* CONFIG_USERSPACE */
107107
108- void load_call_unload (struct llext_test * test_case )
108+ void load_call_unload (const struct llext_test * test_case )
109109{
110110 struct llext_buf_loader buf_loader =
111111 LLEXT_BUF_LOADER (test_case -> buf , test_case -> buf_len );
@@ -170,7 +170,7 @@ void load_call_unload(struct llext_test *test_case)
170170 * of a userspace thread along with the usual supervisor context
171171 * tried above.
172172 */
173- if (test_case -> try_userspace ) {
173+ if (! test_case -> kernel_only ) {
174174 k_thread_create (& llext_thread , llext_stack ,
175175 K_THREAD_STACK_SIZEOF (llext_stack ),
176176 & llext_entry , test_entry_fn , NULL , NULL ,
@@ -200,17 +200,16 @@ void load_call_unload(struct llext_test *test_case)
200200 * unloading each extension which may itself excercise various APIs provided by
201201 * Zephyr.
202202 */
203- #define LLEXT_LOAD_UNLOAD (_name , _userspace , _perm_setup ) \
204- ZTEST(llext, test_load_unload_##_name) \
205- { \
206- struct llext_test test_case = { \
207- .name = STRINGIFY(_name), \
208- .try_userspace = _userspace, \
209- .buf_len = ARRAY_SIZE(_name ## _ext), \
210- .buf = _name ## _ext, \
211- .perm_setup = _perm_setup, \
212- }; \
213- load_call_unload(&test_case); \
203+ #define LLEXT_LOAD_UNLOAD (_name , extra_args ...) \
204+ ZTEST(llext, test_load_unload_##_name) \
205+ { \
206+ const struct llext_test test_case = { \
207+ .name = STRINGIFY(_name), \
208+ .buf = _name ## _ext, \
209+ .buf_len = ARRAY_SIZE(_name ## _ext), \
210+ extra_args \
211+ }; \
212+ load_call_unload(&test_case); \
214213 }
215214
216215/*
@@ -223,40 +222,44 @@ void load_call_unload(struct llext_test *test_case)
223222static LLEXT_CONST uint8_t hello_world_ext [] ELF_ALIGN = {
224223 #include "hello_world.inc"
225224};
226- LLEXT_LOAD_UNLOAD (hello_world , false, NULL )
225+ LLEXT_LOAD_UNLOAD (hello_world ,
226+ .kernel_only = true
227+ )
227228
228229static LLEXT_CONST uint8_t logging_ext [] ELF_ALIGN = {
229230 #include "logging.inc"
230231};
231- LLEXT_LOAD_UNLOAD (logging , true, NULL )
232+ LLEXT_LOAD_UNLOAD (logging )
232233
233234static LLEXT_CONST uint8_t relative_jump_ext [] ELF_ALIGN = {
234235 #include "relative_jump.inc"
235236};
236- LLEXT_LOAD_UNLOAD (relative_jump , true, NULL )
237+ LLEXT_LOAD_UNLOAD (relative_jump )
237238
238239static LLEXT_CONST uint8_t object_ext [] ELF_ALIGN = {
239240 #include "object.inc"
240241};
241- LLEXT_LOAD_UNLOAD (object , true, NULL )
242+ LLEXT_LOAD_UNLOAD (object )
242243
243244#ifndef CONFIG_LLEXT_TYPE_ELF_RELOCATABLE
244245static LLEXT_CONST uint8_t syscalls_ext [] ELF_ALIGN = {
245246 #include "syscalls.inc"
246247};
247- LLEXT_LOAD_UNLOAD (syscalls , true, NULL )
248+ LLEXT_LOAD_UNLOAD (syscalls )
248249
249250static LLEXT_CONST uint8_t threads_kernel_objects_ext [] ELF_ALIGN = {
250251 #include "threads_kernel_objects.inc"
251252};
252- LLEXT_LOAD_UNLOAD (threads_kernel_objects , true, threads_objects_perm_setup )
253+ LLEXT_LOAD_UNLOAD (threads_kernel_objects ,
254+ .perm_setup = threads_objects_perm_setup ,
255+ )
253256#endif
254257
255258#ifndef CONFIG_LLEXT_TYPE_ELF_OBJECT
256259static LLEXT_CONST uint8_t multi_file_ext [] ELF_ALIGN = {
257260 #include "multi_file.inc"
258261};
259- LLEXT_LOAD_UNLOAD (multi_file , true, NULL )
262+ LLEXT_LOAD_UNLOAD (multi_file )
260263#endif
261264
262265#if defined(CONFIG_LLEXT_TYPE_ELF_RELOCATABLE ) && defined(CONFIG_XTENSA )
0 commit comments