Skip to content

Commit 9396cd1

Browse files
committed
tests: posix: semaphore: run normal semaphore test with named semaphore
Run the normal semaphore test with a named semaphore. Signed-off-by: Yong Cong Sin <[email protected]>
1 parent eb1f8c8 commit 9396cd1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/posix/common/src/semaphore.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,4 +294,21 @@ ZTEST(posix_apis, test_named_semaphore)
294294

295295
/* All named semaphores should be destroyed here */
296296
zassert_equal(nsem_get_list_len(), 0);
297+
298+
/* Create a new named sem to be used in the normal semaphore test */
299+
sem1 = sem_open("nsem", O_CREAT, 0, 0);
300+
zassert_equal(nsem_get_list_len(), 1);
301+
zassert_equal(nsem_get_ref_count(sem1), 1);
302+
303+
/* Run the semaphore test with the created named semaphore */
304+
semaphore_test(sem1);
305+
306+
/* List length and ref_count shouldn't change after the test */
307+
zassert_equal(nsem_get_list_len(), 1);
308+
zassert_equal(nsem_get_ref_count(sem1), 1);
309+
310+
/* Unless it is unlinked and closed */
311+
sem_unlink("nsem");
312+
sem_close(sem1);
313+
zassert_equal(nsem_get_list_len(), 0);
297314
}

0 commit comments

Comments
 (0)