test: userspace: add a sys_sem test#10481
Conversation
Add a sys_sem test between kernel- and user-space. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
|
SOFCI TEST |
| #include <zephyr/sys/sem.h> | ||
| #include <zephyr/app_memory/mem_domain.h> |
There was a problem hiding this comment.
The include directives should be placed at the top of the file with the other includes, not in the middle of the file after a ZTEST function. This violates standard C coding conventions and can make the code harder to maintain.
| sys_sem_init(&simple_sem.sem1, 0, 1); | ||
| sys_sem_init(&simple_sem.sem2, 0, 1); | ||
|
|
||
| k_thread_create(&user_thread, user_stack, USER_STACKSIZE, |
There was a problem hiding this comment.
The global variable 'user_thread' is being reused from the earlier tests in this file. This can cause issues if multiple tests run in sequence, as the thread structure may contain state from previous test runs. Consider using a separate thread structure for this test, such as 'sys_sem_thread', to avoid potential conflicts.
| }; | ||
|
|
||
| ztest_test_pass(); | ||
| k_mem_domain_init(&dp_mdom, 0, NULL); |
There was a problem hiding this comment.
The memory domain is initialized but never cleaned up after the test completes. The memory domain should be destroyed with k_mem_domain_remove_thread or appropriate cleanup to avoid resource leaks, especially in a test suite where multiple tests may run.
kv2019i
left a comment
There was a problem hiding this comment.
The test code seems fine.
Add a sys_sem test between kernel- and user-space. @dcpleung any idea why this might not be working? Just adding a
sys_sem_take()in the kernel thread with a timeout hangs the DSP, instead of returning with a timeout as expected.