From 746a3b943db8f56a58138f17bb58986c34797880 Mon Sep 17 00:00:00 2001 From: Christopher Friedt Date: Wed, 13 Dec 2023 19:57:42 -0500 Subject: [PATCH] tests: posix: use consistent min stack sizes * Use PTHREAD_STACK_MIN as provided by the specification instead of a hard-coded value of 1024 * add extra stack size to semaphore tests Signed-off-by: Christopher Friedt --- tests/posix/common/src/key.c | 2 +- tests/posix/common/src/mqueue.c | 2 +- tests/posix/common/src/mutex.c | 3 ++- tests/posix/common/src/pthread.c | 2 +- tests/posix/common/src/rwlock.c | 2 +- tests/posix/common/src/semaphore.c | 3 ++- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/posix/common/src/key.c b/tests/posix/common/src/key.c index eeadf8f0058..58e67a313ac 100644 --- a/tests/posix/common/src/key.c +++ b/tests/posix/common/src/key.c @@ -11,7 +11,7 @@ #define N_THR 2 #define N_KEY 2 -#define STACKSZ (1024 + CONFIG_TEST_EXTRA_STACK_SIZE) +#define STACKSZ (MAX(1024, PTHREAD_STACK_MIN) + CONFIG_TEST_EXTRA_STACK_SIZE) #define BUFFSZ 48 K_THREAD_STACK_ARRAY_DEFINE(stackp, N_THR, STACKSZ); diff --git a/tests/posix/common/src/mqueue.c b/tests/posix/common/src/mqueue.c index 7d1ec257323..65df6fbe777 100644 --- a/tests/posix/common/src/mqueue.c +++ b/tests/posix/common/src/mqueue.c @@ -12,7 +12,7 @@ #include #define N_THR 2 -#define STACKSZ (1024 + CONFIG_TEST_EXTRA_STACK_SIZE) +#define STACKSZ (MAX(1024, PTHREAD_STACK_MIN) + CONFIG_TEST_EXTRA_STACK_SIZE) #define SENDER_THREAD 0 #define RECEIVER_THREAD 1 #define MESSAGE_SIZE 16 diff --git a/tests/posix/common/src/mutex.c b/tests/posix/common/src/mutex.c index 01c49220727..6a63f98e451 100644 --- a/tests/posix/common/src/mutex.c +++ b/tests/posix/common/src/mutex.c @@ -7,9 +7,10 @@ #include #include +#include #include -#define STACK_SIZE (1024 + CONFIG_TEST_EXTRA_STACK_SIZE) +#define STACK_SIZE (MAX(1024, PTHREAD_STACK_MIN) + CONFIG_TEST_EXTRA_STACK_SIZE) static K_THREAD_STACK_DEFINE(stack, STACK_SIZE); diff --git a/tests/posix/common/src/pthread.c b/tests/posix/common/src/pthread.c index 3ff1092df27..58041c7e801 100644 --- a/tests/posix/common/src/pthread.c +++ b/tests/posix/common/src/pthread.c @@ -13,7 +13,7 @@ #define N_THR_E 3 #define N_THR_T 4 #define BOUNCES 64 -#define STACKS (1024 + CONFIG_TEST_EXTRA_STACK_SIZE) +#define STACKS (MAX(1024, PTHREAD_STACK_MIN) + CONFIG_TEST_EXTRA_STACK_SIZE) #define THREAD_PRIORITY 3 #define ONE_SECOND 1 diff --git a/tests/posix/common/src/rwlock.c b/tests/posix/common/src/rwlock.c index aebf459c323..43c573a7007 100644 --- a/tests/posix/common/src/rwlock.c +++ b/tests/posix/common/src/rwlock.c @@ -10,7 +10,7 @@ #include #define N_THR 3 -#define STACKSZ (1024 + CONFIG_TEST_EXTRA_STACK_SIZE) +#define STACKSZ (MAX(1024, PTHREAD_STACK_MIN) + CONFIG_TEST_EXTRA_STACK_SIZE) K_THREAD_STACK_ARRAY_DEFINE(stack, N_THR, STACKSZ); pthread_rwlock_t rwlock; diff --git a/tests/posix/common/src/semaphore.c b/tests/posix/common/src/semaphore.c index 622a34dc073..fef4ddfb0fe 100644 --- a/tests/posix/common/src/semaphore.c +++ b/tests/posix/common/src/semaphore.c @@ -8,9 +8,10 @@ #include #include +#include #include -#define STACK_SIZE 1024 +#define STACK_SIZE (MAX(1024, PTHREAD_STACK_MIN) + CONFIG_TEST_EXTRA_STACK_SIZE) sem_t sema; void *dummy_sem;