diff options
author | Matias Elo <matias.elo@nokia.com> | 2022-07-08 13:34:54 +0300 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2022-07-14 10:23:57 +0300 |
commit | 709291620e0a973687e3f4fedd02013db4140081 (patch) | |
tree | 0f8c659de45b410f7168e72c3bb8c7b961d648d3 | |
parent | 5bda02d465287c01fa0c9882d45e4351b2df2796 (diff) |
test: cunit: enable creating up to ODP_THREAD_COUNT_MAX worker threads
Enable validation tests to create up to ODP_THREAD_COUNT_MAX threads with
odp_cunit_thread_create() helper function. Also, check the number of
created threads to prevent writing over global 'thread_tbl' table.
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
-rw-r--r-- | test/common/odp_cunit_common.c | 8 | ||||
-rw-r--r-- | test/common/odp_cunit_common.h | 2 | ||||
-rw-r--r-- | test/validation/api/atomic/atomic.c | 2 | ||||
-rw-r--r-- | test/validation/api/barrier/barrier.c | 1 | ||||
-rw-r--r-- | test/validation/api/lock/lock.c | 1 | ||||
-rw-r--r-- | test/validation/api/pool/pool.c | 2 | ||||
-rw-r--r-- | test/validation/api/queue/queue.c | 1 | ||||
-rw-r--r-- | test/validation/api/scheduler/scheduler.c | 1 | ||||
-rw-r--r-- | test/validation/api/shmem/shmem.c | 1 | ||||
-rw-r--r-- | test/validation/api/timer/timer.c | 2 |
10 files changed, 18 insertions, 3 deletions
diff --git a/test/common/odp_cunit_common.c b/test/common/odp_cunit_common.c index 935ac9f6d..dbc6cf3d8 100644 --- a/test/common/odp_cunit_common.c +++ b/test/common/odp_cunit_common.c @@ -31,7 +31,7 @@ /* Globals */ static int allow_skip_result; -static odph_thread_t thread_tbl[MAX_WORKERS]; +static odph_thread_t thread_tbl[ODP_THREAD_COUNT_MAX]; static int threads_running; static odp_instance_t instance; static char *progname; @@ -187,6 +187,12 @@ int odp_cunit_thread_create(int num, int func_ptr(void *), void *const arg[], in odph_thread_common_param_t thr_common; odph_thread_param_t thr_param[num]; + if (num > ODP_THREAD_COUNT_MAX) { + fprintf(stderr, "error: %s: too many threads: num=%d max=%d\n", __func__, + num, ODP_THREAD_COUNT_MAX); + return -1; + } + if (threads_running) { /* thread_tbl is already in use */ fprintf(stderr, "error: %s: threads already running\n", __func__); diff --git a/test/common/odp_cunit_common.h b/test/common/odp_cunit_common.h index cb3fe4b89..5959163d3 100644 --- a/test/common/odp_cunit_common.h +++ b/test/common/odp_cunit_common.h @@ -20,8 +20,6 @@ #include <CUnit/Basic.h> #include <odp_api.h> -#define MAX_WORKERS 32 /**< Maximum number of work threads */ - typedef int (*cunit_test_check_active)(void); typedef struct { diff --git a/test/validation/api/atomic/atomic.c b/test/validation/api/atomic/atomic.c index 85b08ce30..d795c3631 100644 --- a/test/validation/api/atomic/atomic.c +++ b/test/validation/api/atomic/atomic.c @@ -12,6 +12,8 @@ #include <odp_cunit_common.h> #include <unistd.h> +#define MAX_WORKERS 32 + #define ADD_SUB_CNT 5 #define CNT 100000ULL diff --git a/test/validation/api/barrier/barrier.c b/test/validation/api/barrier/barrier.c index 6a82ff8ca..78534327b 100644 --- a/test/validation/api/barrier/barrier.c +++ b/test/validation/api/barrier/barrier.c @@ -13,6 +13,7 @@ #include <unistd.h> #define VERBOSE 0 +#define MAX_WORKERS 32 #define MAX_ITERATIONS 1000 #define BARRIER_ITERATIONS 64 diff --git a/test/validation/api/lock/lock.c b/test/validation/api/lock/lock.c index 75502ccd1..1ee49b713 100644 --- a/test/validation/api/lock/lock.c +++ b/test/validation/api/lock/lock.c @@ -13,6 +13,7 @@ #define VERBOSE 0 +#define MAX_WORKERS 32 #define MIN_ITERATIONS 1000 #define MAX_ITERATIONS 30000 #define ITER_MPLY_FACTOR 3 diff --git a/test/validation/api/pool/pool.c b/test/validation/api/pool/pool.c index 90690be92..e8d2a9bc5 100644 --- a/test/validation/api/pool/pool.c +++ b/test/validation/api/pool/pool.c @@ -11,6 +11,8 @@ #include "test_common_macros.h" #include <odp/helper/odph_api.h> +#define MAX_WORKERS 32 + #define BUF_SIZE 1500 #define BUF_NUM 1000 #define TMO_NUM 1000 diff --git a/test/validation/api/queue/queue.c b/test/validation/api/queue/queue.c index 241013ded..0fc782c2a 100644 --- a/test/validation/api/queue/queue.c +++ b/test/validation/api/queue/queue.c @@ -8,6 +8,7 @@ #include <odp_api.h> #include <odp_cunit_common.h> +#define MAX_WORKERS 32 #define BURST_SIZE (8) #define MAX_NUM_EVENT (1 * 1024) #define MAX_ITERATION (100) diff --git a/test/validation/api/scheduler/scheduler.c b/test/validation/api/scheduler/scheduler.c index ab1a72499..982b09636 100644 --- a/test/validation/api/scheduler/scheduler.c +++ b/test/validation/api/scheduler/scheduler.c @@ -9,6 +9,7 @@ #include "odp_cunit_common.h" #include <odp/helper/odph_api.h> +#define MAX_WORKERS 32 #define MAX_ORDERED_LOCKS 2 #define MAX_POOL_SIZE (1024 * 1024) #define MSG_POOL_SIZE (64 * 1024) diff --git a/test/validation/api/shmem/shmem.c b/test/validation/api/shmem/shmem.c index 2fdfb4b10..2c7fab718 100644 --- a/test/validation/api/shmem/shmem.c +++ b/test/validation/api/shmem/shmem.c @@ -10,6 +10,7 @@ #include <odp/helper/odph_api.h> #include <stdlib.h> +#define MAX_WORKERS 32 #define ALIGN_SIZE (128) #define MEM_NAME "test_shmem" #define NAME_LEN (sizeof(MEM_NAME) + 20) diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index fe34b2001..261a2b248 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -15,6 +15,8 @@ #include <odp/helper/odph_api.h> #include "odp_cunit_common.h" +#define MAX_WORKERS 32 + #define GLOBAL_SHM_NAME "GlobalTimerTest" #define MAX(a, b) (((a) > (b)) ? (a) : (b)) |