@@ -8,3 +8,4 @@ odp_shm
odp_system
odp_pktio
odp_buffer
+odp_thread
@@ -6,9 +6,9 @@ AM_LDFLAGS += -static
TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform}
if ODP_CUNIT_ENABLED
-TESTS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio_run odp_buffer odp_system
+TESTS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio_run odp_buffer odp_system odp_thread
check_PROGRAMS = ${bin_PROGRAMS}
-bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio odp_buffer odp_system
+bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio odp_buffer odp_system odp_thread
odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
odp_buffer_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/buffer
endif
@@ -27,3 +27,4 @@ dist_odp_buffer_SOURCES = buffer/odp_buffer_pool_test.c \
buffer/odp_packet_test.c \
odp_buffer.c common/odp_cunit_common.c
dist_odp_system_SOURCES = odp_system.c common/odp_cunit_common.c
+dist_odp_thread_SOURCES = odp_thread.c common/odp_cunit_common.c
new file mode 100644
@@ -0,0 +1,55 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp.h>
+#include <odp_cunit_common.h>
+
+static void *run_thread_id_core(void *arg)
+{
+ int thr, core, core_count, num_workers;
+ odp_coremask_t mask;
+
+ odp_coremask_zero(&mask);
+
+ thr = odp_thread_id();
+ core = odp_thread_core();
+ core_count = odp_sys_core_count();
+
+ /* threads are limited */
+ if (core_count > MAX_WORKERS)
+ num_workers = MAX_WORKERS;
+ else
+ num_workers = core_count;
+
+ CU_ASSERT(core >= 0);
+ CU_ASSERT(thr >= 0);
+ CU_ASSERT(thr <= num_workers);
+ return arg;
+}
+
+static void test_odp_thread_id_core(void)
+{
+ pthrd_arg thrdarg;
+
+ thrdarg.numthrds = odp_sys_core_count();
+
+ if (thrdarg.numthrds > MAX_WORKERS)
+ thrdarg.numthrds = MAX_WORKERS;
+
+ odp_cunit_thread_create(run_thread_id_core, &thrdarg);
+ odp_cunit_thread_exit(&thrdarg);
+}
+
+CU_TestInfo test_odp_thread[] = {
+ {"id & core range", test_odp_thread_id_core},
+ CU_TEST_INFO_NULL,
+};
+
+CU_SuiteInfo odp_testsuites[] = {
+ {"Thread", NULL, NULL, NULL, NULL, test_odp_thread},
+ CU_SUITE_INFO_NULL,
+};
+
Add tests for odp_thread_core and odp_thread_id Signed-off-by: Mike Holmes <mike.holmes@linaro.org> --- test/validation/.gitignore | 1 + test/validation/Makefile.am | 5 ++-- test/validation/odp_thread.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 test/validation/odp_thread.c