From 9535a69af852d30498a1048306b8f75b8d9eae6d Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Thu, 17 Apr 2025 09:27:36 -0400 Subject: [PATCH] tests: posix: semaphores: ensure test is not skipped Commit f7633a55aa098de8409724f3a6211af4a4687101 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 --- tests/posix/semaphores/prj.conf | 4 ++++ tests/posix/semaphores/src/main.c | 15 ++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/posix/semaphores/prj.conf b/tests/posix/semaphores/prj.conf index 5376678d6a9..49b867610a0 100644 --- a/tests/posix/semaphores/prj.conf +++ b/tests/posix/semaphores/prj.conf @@ -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 +CONFIG_THREAD_STACK_INFO=y diff --git a/tests/posix/semaphores/src/main.c b/tests/posix/semaphores/src/main.c index 24cbb85b32a..c99e0fca1e9 100644 --- a/tests/posix/semaphores/src/main.c +++ b/tests/posix/semaphores/src/main.c @@ -16,6 +16,9 @@ #define WAIT_TIME_MS 100 BUILD_ASSERT(WAIT_TIME_MS > 0, "WAIT_TIME_MS must be posistive"); +/* based on the current structure of this unit test */ +BUILD_ASSERT(CONFIG_DYNAMIC_THREAD_POOL_SIZE >= 2, "CONFIG_DYNAMIC_THREAD_POOL_SIZE must be >= 2"); + static void *child_func(void *p1) { sem_t *sem = (sem_t *)p1; @@ -312,14 +315,4 @@ ZTEST(posix_semaphores, test_named_semaphore) zassert_equal(nsem_get_list_len(), 0); } -static void before(void *arg) -{ - ARG_UNUSED(arg); - - if (!IS_ENABLED(CONFIG_DYNAMIC_THREAD)) { - /* skip redundant testing if there is no thread pool / heap allocation */ - ztest_test_skip(); - } -} - -ZTEST_SUITE(posix_semaphores, NULL, NULL, before, NULL, NULL); +ZTEST_SUITE(posix_semaphores, NULL, NULL, NULL, NULL, NULL);