From 8b2d6a7f282398aafc8449a625441cc87bbd6c9e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 18 Aug 2022 19:11:09 -0400 Subject: Add zix_sem_timed_wait() --- test/test_sem.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/test_sem.c b/test/test_sem.c index d43dac8..36f85e0 100644 --- a/test/test_sem.c +++ b/test/test_sem.c @@ -52,6 +52,19 @@ test_try_wait(void) assert(!zix_sem_destroy(&sem)); } +static void +test_timed_wait(void) +{ + assert(!zix_sem_init(&sem, 0)); + assert(zix_sem_timed_wait(&sem, 0, 0) == ZIX_STATUS_TIMEOUT); + assert(zix_sem_timed_wait(&sem, 0, 5000000) == ZIX_STATUS_TIMEOUT); + assert(!zix_sem_post(&sem)); + assert(!zix_sem_timed_wait(&sem, 0, 5000000)); + assert(!zix_sem_post(&sem)); + assert(!zix_sem_timed_wait(&sem, 1000, 0)); + assert(!zix_sem_destroy(&sem)); +} + int main(int argc, char** argv) { @@ -65,6 +78,7 @@ main(int argc, char** argv) } test_try_wait(); + test_timed_wait(); printf("Testing %u signals...\n", n_signals); -- cgit v1.2.1