-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Changes from all commits
92b66e4
d0de2ef
20b8322
a6a106c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,12 @@ | |
#include <zephyr/sys/util.h> | ||
#include <zephyr/ztest.h> | ||
|
||
#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; | ||
|
@@ -51,11 +57,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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, probably not. I've actually been working on a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed! |
||
abstime.tv_nsec += (WAIT_TIME_MS % MSEC_PER_SEC) * NSEC_PER_MSEC; | ||
|
||
/* TESPOINT: Wait for 5 seconds and acquire sema given | ||
* by thread1 | ||
*/ | ||
/* TESPOINT: Wait to acquire sem given by thread1 */ | ||
zassert_equal(sem_timedwait(sem, &abstime), 0); | ||
|
||
/* TESTPOINT: Semaphore is already acquired, check if | ||
|
@@ -71,9 +76,7 @@ static void semaphore_test(sem_t *sem) | |
zassert_equal(sem_getvalue(sem, &val), 0); | ||
zassert_equal(val, 1); | ||
|
||
zassert_equal(sem_destroy(sem), -1, | ||
"acquired semaphore" | ||
" is destroyed"); | ||
zassert_equal(sem_destroy(sem), -1, "acquired semaphore is destroyed"); | ||
zassert_equal(errno, EBUSY); | ||
|
||
/* TESTPOINT: take semaphore which is initialized with 1 */ | ||
|
@@ -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); |
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
ingCONFIG_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!