-
Notifications
You must be signed in to change notification settings - Fork 349
test: userspace: add a sys_sem test #10481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add a sys_sem test between kernel- and user-space. Signed-off-by: Guennadi Liakhovetski <[email protected]>
|
SOFCI TEST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
| #include <zephyr/sys/sem.h> | ||
| #include <zephyr/app_memory/mem_domain.h> |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test code seems fine.
lgirdwood
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lyakh for record keeping its best we can resolve the AI reviews or answer where wrong. Otherwise this LGTM.
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.