-
Notifications
You must be signed in to change notification settings - Fork 7.3k
tests: posix: semaphores: ensure test is not skipped #88769
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
tests: posix: semaphores: ensure test is not skipped #88769
Conversation
@@ -3,3 +3,7 @@ CONFIG_ZTEST=y | |||
|
|||
CONFIG_POSIX_AEP_CHOICE_BASE=y | |||
CONFIG_POSIX_SEMAPHORES=y | |||
|
|||
CONFIG_DYNAMIC_THREAD=y | |||
CONFIG_DYNAMIC_THREAD_POOL_SIZE=2 |
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.
Same as #88767, we can make it bulletproof by BUILD_ASSERT
ing CONFIG_DYNAMIC_THREAD_POOL_SIZE>=2
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.
Fixed!
650aa24
to
c1df1b3
Compare
This needs another change unfortunately - it should be visible after a rebase, but due to #88538, the default heap-add with I'll add another commit ahead of this one to create a heap-add for posix semaphores. The above failure can be traced to zephyr/lib/posix/options/semaphore.c Line 275 in e41909a
|
4b5ae9e
4b5ae9e
to
61f1411
Compare
|
@nashif - this should reduce test execution time for semaphores by a good amount (for cortex-a53, and likely x86-64 as well) |
61f1411
to
4e6a92d
Compare
The implementation of POSIX_SEMAPHORES historically used heap allocation and has not yet been transitioned to a pool allocator. However, since 590258b, the default heap-add with CONFIG_POSIX_API has been reduced from 1 kiB which causes tests/posix/semaphores to fail due to NULL being returned from a call to k_calloc(). Create a minimal heap-add for the POSIX_SEMAPHORES Option Group. This can be removed at a future date if semaphores are changed to use a pooled allocator and fixed-size name, rather than heap allocation. Signed-off-by: Chris Friedt <[email protected]>
bec2865
to
e462778
Compare
|
@@ -51,11 +54,10 @@ static void semaphore_test(sem_t *sem) | |||
|
|||
zassert_equal(clock_gettime(CLOCK_REALTIME, &abstime), 0, "clock_gettime failed"); | |||
|
|||
abstime.tv_sec += 5; | |||
abstime.tv_sec += WAIT_TIME_MS / MSEC_PER_SEC; |
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.
Is this supposed to be in the second commit?
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.
Yeah, probably not.
I've actually been working on a timespec_util.h
header as well that includes a few useful functions. That's been long overdue.
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.
Fixed!
There is no reason to use a 5s wait time in tests. This can add up quite significantly across multiple platforms that execute in real-time under qemu (or even just on real hardware). Speedup observed with qemu_cortex_a53/qemu_cortex_a53/smp Before: ``` START - test_named_semaphore PASS - test_named_semaphore in 5.688 seconds ``` After: ``` START - test_named_semaphore PASS - test_named_semaphore in 0.783 seconds ``` Signed-off-by: Chris Friedt <[email protected]>
Just a formatting change, in a separate commit. Signed-off-by: Chris Friedt <[email protected]>
Commit f7633a5 moved the tests for the POSIX_SEMAPHORES Option Group from the tests/posix/common testsuite to its own dedicated testsuite. However, there was a copy-paste error. Previously, tests would have been run only once when dynamic threads were enabled, and then skipped when dynamic threads were disabled, since that follows the posix programming model better. However, dynamic threads were never actually enabled after moving to the new testsuite. So all tests were effectively skipped. Add the necessary options to prj.conf in order to ensure that there are sufficient dynamic threads available to run the testsuite. Signed-off-by: Chris Friedt <[email protected]>
e462778
to
a6a106c
Compare
Commit f7633a5 moved the tests for the
POSIX_SEMAPHORES
Option Group from thetests/posix/common
testsuite totests/posix/semaphores
.However, there was a copy-paste error. Previously, tests would have been run only once when dynamic threads were enabled, and then skipped when dynamic threads were disabled, since that follows the posix programming model better. However, dynamic threads were never actually enabled after moving to the new testsuite. So all tests were effectively skipped.
Add the necessary options to prj.conf in order to ensure that there are sufficient dynamic threads available to run the testsuite.
Fixes #88768