Skip to content

Commit e462778

Browse files
committed
tests: posix: semaphores: ensure test is not skipped
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 <cfriedt@tenstorrent.com>
1 parent 140d095 commit e462778

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

tests/posix/semaphores/prj.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ CONFIG_ZTEST=y
33

44
CONFIG_POSIX_AEP_CHOICE_BASE=y
55
CONFIG_POSIX_SEMAPHORES=y
6+
7+
CONFIG_DYNAMIC_THREAD=y
8+
CONFIG_DYNAMIC_THREAD_POOL_SIZE=2
9+
CONFIG_THREAD_STACK_INFO=y

tests/posix/semaphores/src/main.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <zephyr/ztest.h>
1515

1616
#define WAIT_TIME_MS 100
17+
BUILD_ASSERT(WAIT_TIME_MS > 0, "WAIT_TIME_MS must be posistive");
1718

1819
static void *child_func(void *p1)
1920
{
@@ -53,7 +54,8 @@ static void semaphore_test(sem_t *sem)
5354

5455
zassert_equal(clock_gettime(CLOCK_REALTIME, &abstime), 0, "clock_gettime failed");
5556

56-
abstime.tv_nsec += WAIT_TIME_MS * NSEC_PER_MSEC;
57+
abstime.tv_sec += WAIT_TIME_MS / MSEC_PER_SEC;
58+
abstime.tv_nsec += (WAIT_TIME_MS % MSEC_PER_SEC) * NSEC_PER_MSEC;
5759

5860
/* TESPOINT: Wait to acquire sem given by thread1 */
5961
zassert_equal(sem_timedwait(sem, &abstime), 0);
@@ -310,14 +312,4 @@ ZTEST(posix_semaphores, test_named_semaphore)
310312
zassert_equal(nsem_get_list_len(), 0);
311313
}
312314

313-
static void before(void *arg)
314-
{
315-
ARG_UNUSED(arg);
316-
317-
if (!IS_ENABLED(CONFIG_DYNAMIC_THREAD)) {
318-
/* skip redundant testing if there is no thread pool / heap allocation */
319-
ztest_test_skip();
320-
}
321-
}
322-
323-
ZTEST_SUITE(posix_semaphores, NULL, NULL, before, NULL, NULL);
315+
ZTEST_SUITE(posix_semaphores, NULL, NULL, NULL, NULL, NULL);

0 commit comments

Comments
 (0)