@@ -46,11 +46,11 @@ LOG_MODULE_REGISTER(test_llext_simple);
4646
4747struct llext_test {
4848 const char * name ;
49- bool try_userspace ;
50- size_t buf_len ;
5149
5250 LLEXT_CONST uint8_t * buf ;
51+ size_t buf_len ;
5352
53+ bool kernel_only ;
5454 void (* perm_setup )(struct k_thread * llext_thread );
5555};
5656
@@ -111,7 +111,7 @@ static void threads_objects_perm_setup(struct k_thread *llext_thread)
111111#define threads_objects_perm_setup NULL
112112#endif /* CONFIG_USERSPACE */
113113
114- void load_call_unload (struct llext_test * test_case )
114+ void load_call_unload (const struct llext_test * test_case )
115115{
116116 struct llext_buf_loader buf_loader =
117117 LLEXT_BUF_LOADER (test_case -> buf , test_case -> buf_len );
@@ -176,7 +176,7 @@ void load_call_unload(struct llext_test *test_case)
176176 * of a userspace thread along with the usual supervisor context
177177 * tried above.
178178 */
179- if (test_case -> try_userspace ) {
179+ if (! test_case -> kernel_only ) {
180180 k_thread_create (& llext_thread , llext_stack ,
181181 K_THREAD_STACK_SIZEOF (llext_stack ),
182182 & llext_entry , test_entry_fn , NULL , NULL ,
@@ -206,17 +206,16 @@ void load_call_unload(struct llext_test *test_case)
206206 * unloading each extension which may itself excercise various APIs provided by
207207 * Zephyr.
208208 */
209- #define LLEXT_LOAD_UNLOAD (_name , _userspace , _perm_setup ) \
210- ZTEST(llext, test_load_unload_##_name) \
211- { \
212- struct llext_test test_case = { \
213- .name = STRINGIFY(_name), \
214- .try_userspace = _userspace, \
215- .buf_len = ARRAY_SIZE(_name ## _ext), \
216- .buf = _name ## _ext, \
217- .perm_setup = _perm_setup, \
218- }; \
219- load_call_unload(&test_case); \
209+ #define LLEXT_LOAD_UNLOAD (_name , extra_args ...) \
210+ ZTEST(llext, test_load_unload_##_name) \
211+ { \
212+ const struct llext_test test_case = { \
213+ .name = STRINGIFY(_name), \
214+ .buf = _name ## _ext, \
215+ .buf_len = ARRAY_SIZE(_name ## _ext), \
216+ extra_args \
217+ }; \
218+ load_call_unload(&test_case); \
220219 }
221220
222221/*
@@ -229,40 +228,44 @@ void load_call_unload(struct llext_test *test_case)
229228static LLEXT_CONST uint8_t hello_world_ext [] ELF_ALIGN = {
230229 #include "hello_world.inc"
231230};
232- LLEXT_LOAD_UNLOAD (hello_world , false, NULL )
231+ LLEXT_LOAD_UNLOAD (hello_world ,
232+ .kernel_only = true
233+ )
233234
234235static LLEXT_CONST uint8_t logging_ext [] ELF_ALIGN = {
235236 #include "logging.inc"
236237};
237- LLEXT_LOAD_UNLOAD (logging , true, NULL )
238+ LLEXT_LOAD_UNLOAD (logging )
238239
239240static LLEXT_CONST uint8_t relative_jump_ext [] ELF_ALIGN = {
240241 #include "relative_jump.inc"
241242};
242- LLEXT_LOAD_UNLOAD (relative_jump , true, NULL )
243+ LLEXT_LOAD_UNLOAD (relative_jump )
243244
244245static LLEXT_CONST uint8_t object_ext [] ELF_ALIGN = {
245246 #include "object.inc"
246247};
247- LLEXT_LOAD_UNLOAD (object , true, NULL )
248+ LLEXT_LOAD_UNLOAD (object )
248249
249250#ifndef CONFIG_LLEXT_TYPE_ELF_RELOCATABLE
250251static LLEXT_CONST uint8_t syscalls_ext [] ELF_ALIGN = {
251252 #include "syscalls.inc"
252253};
253- LLEXT_LOAD_UNLOAD (syscalls , true, NULL )
254+ LLEXT_LOAD_UNLOAD (syscalls )
254255
255256static LLEXT_CONST uint8_t threads_kernel_objects_ext [] ELF_ALIGN = {
256257 #include "threads_kernel_objects.inc"
257258};
258- LLEXT_LOAD_UNLOAD (threads_kernel_objects , true, threads_objects_perm_setup )
259+ LLEXT_LOAD_UNLOAD (threads_kernel_objects ,
260+ .perm_setup = threads_objects_perm_setup ,
261+ )
259262#endif
260263
261264#ifndef CONFIG_LLEXT_TYPE_ELF_OBJECT
262265static LLEXT_CONST uint8_t multi_file_ext [] ELF_ALIGN = {
263266 #include "multi_file.inc"
264267};
265- LLEXT_LOAD_UNLOAD (multi_file , true, NULL )
268+ LLEXT_LOAD_UNLOAD (multi_file )
266269#endif
267270
268271#if defined(CONFIG_LLEXT_TYPE_ELF_RELOCATABLE ) && defined(CONFIG_XTENSA )
0 commit comments