Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions tests/posix/common/src/pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,17 +563,15 @@ void test_posix_pthread_create_negative(void)

void test_pthread_descriptor_leak(void)
{
void *unused;
pthread_t pthread1;
pthread_attr_t attr;

zassert_ok(pthread_attr_init(&attr), NULL);
zassert_ok(pthread_attr_setstack(&attr, &stack_e[0][0], STACKS), NULL);

/* If we are leaking descriptors, then this loop will never complete */
for (size_t i = 0; i < CONFIG_MAX_PTHREAD_COUNT * 2; ++i) {
zassert_ok(pthread_create(&pthread1, &attr, create_thread1, NULL),
zassert_equal(0, pthread_attr_init(&attr), NULL);
zassert_equal(0, pthread_attr_setstack(&attr, &stack_e[0][0], STACKS), NULL);
zassert_equal(0, pthread_create(&pthread1, &attr, create_thread1, NULL),
"unable to create thread %zu", i);
zassert_ok(pthread_join(pthread1, &unused), "unable to join thread %zu", i);
zassert_equal(0, pthread_join(pthread1, NULL), "unable to join thread %zu", i);
}
}