aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Uvarov <maxim.uvarov@linaro.org>2015-07-03 14:12:30 +0300
committerMaxim Uvarov <maxim.uvarov@linaro.org>2015-07-03 14:12:30 +0300
commit7f4ad12cb88f187db26e2d9f97dfd543ec35efc8 (patch)
treedf0d0a5a6d53df8c41a28ca881ca4ad315681930
parentb16c3dd9e9cf90197217ab1fff3425b454f9c80c (diff)
parent624ef9dfacc5b76513fce70dcd6fbe300a8cc419 (diff)
Merge branch 'master' into api-next
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> Conflicts: helper/linux.c test/validation/pool/pool.c
-rw-r--r--configure.ac13
-rw-r--r--doc/odp.dox7
-rw-r--r--doc/release.dox65
-rw-r--r--example/classifier/Makefile.am2
-rw-r--r--example/generator/Makefile.am2
-rw-r--r--example/ipsec/Makefile.am2
-rw-r--r--example/packet/Makefile.am2
-rw-r--r--example/timer/Makefile.am2
-rw-r--r--helper/linux.c37
-rw-r--r--helper/odph_debug.h93
-rw-r--r--helper/odph_pause.h54
-rw-r--r--helper/ring.c42
-rw-r--r--helper/test/.gitignore1
-rw-r--r--helper/test/Makefile.am6
-rw-r--r--platform/linux-generic/Makefile.am4
-rw-r--r--platform/linux-generic/include/odp_buffer_inlines.h4
-rw-r--r--platform/linux-generic/include/odp_buffer_internal.h11
-rw-r--r--platform/linux-generic/odp_timer.c1
-rw-r--r--platform/linux-generic/test/Makefile.am17
-rwxr-xr-xscripts/checkpatch.pl3
-rw-r--r--test/api_test/Makefile.am2
-rw-r--r--test/miscellaneous/Makefile.am4
-rw-r--r--test/performance/Makefile.am6
-rw-r--r--test/performance/odp_pktio_perf.c4
-rw-r--r--test/validation/.gitignore14
-rw-r--r--test/validation/Makefile.am54
-rw-r--r--test/validation/buffer/.gitignore2
-rw-r--r--test/validation/buffer/Makefile.am8
-rw-r--r--test/validation/buffer/buffer.c (renamed from test/validation/odp_buffer.c)32
-rw-r--r--test/validation/buffer/buffer.h7
-rw-r--r--test/validation/buffer/buffer_main.c11
-rw-r--r--test/validation/buffer/odp_buffer_pool_test.c269
-rw-r--r--test/validation/classification/.gitignore2
-rw-r--r--test/validation/classification/Makefile.am10
-rw-r--r--test/validation/classification/classification.c27
-rw-r--r--test/validation/classification/classification.h7
-rw-r--r--test/validation/classification/classification_main.c12
-rw-r--r--test/validation/classification/odp_classification_basic.c34
-rw-r--r--test/validation/classification/odp_classification_tests.c31
-rw-r--r--test/validation/classification/odp_classification_testsuites.h8
-rw-r--r--test/validation/common/odp_cunit_common.c37
-rw-r--r--test/validation/common/odp_cunit_common.h24
-rw-r--r--test/validation/cpumask/.gitignore2
-rw-r--r--test/validation/cpumask/Makefile.am8
-rw-r--r--test/validation/cpumask/cpumask.c (renamed from test/validation/odp_cpumask.c)78
-rw-r--r--test/validation/cpumask/cpumask.h7
-rw-r--r--test/validation/cpumask/cpumask_main.c11
-rw-r--r--test/validation/crypto/Makefile.am2
-rw-r--r--test/validation/init/.gitignore4
-rw-r--r--test/validation/init/Makefile.am14
-rw-r--r--test/validation/init/init.c151
-rw-r--r--test/validation/init/init.h9
-rw-r--r--test/validation/init/init_main_abort.c11
-rw-r--r--test/validation/init/init_main_log.c11
-rw-r--r--test/validation/init/init_main_ok.c11
-rw-r--r--test/validation/init/odp_init.c46
-rw-r--r--test/validation/init/odp_init_abort.c56
-rw-r--r--test/validation/init/odp_init_log.c72
-rw-r--r--test/validation/odp_classification.c19
-rw-r--r--test/validation/odp_thread.c41
-rw-r--r--test/validation/packet/.gitignore2
-rw-r--r--test/validation/packet/Makefile.am8
-rw-r--r--test/validation/packet/packet.c (renamed from test/validation/odp_packet.c)200
-rw-r--r--test/validation/packet/packet.h7
-rw-r--r--test/validation/packet/packet_main.c12
-rw-r--r--test/validation/pktio/Makefile.am2
-rw-r--r--test/validation/pktio/pktio.c8
-rw-r--r--test/validation/pool/.gitignore2
-rw-r--r--test/validation/pool/Makefile.am8
-rw-r--r--test/validation/pool/pool.c (renamed from test/validation/odp_pool.c)28
-rw-r--r--test/validation/pool/pool.h7
-rw-r--r--test/validation/pool/pool_main.c12
-rw-r--r--test/validation/queue/.gitignore2
-rw-r--r--test/validation/queue/Makefile.am8
-rw-r--r--test/validation/queue/queue.c (renamed from test/validation/odp_queue.c)25
-rw-r--r--test/validation/queue/queue.h7
-rw-r--r--test/validation/queue/queue_main.c12
-rw-r--r--test/validation/random/.gitignore2
-rw-r--r--test/validation/random/Makefile.am8
-rw-r--r--test/validation/random/random.c (renamed from test/validation/odp_random.c)16
-rw-r--r--test/validation/random/random.h7
-rw-r--r--test/validation/random/random_main.c12
-rw-r--r--test/validation/scheduler/.gitignore2
-rw-r--r--test/validation/scheduler/Makefile.am8
-rw-r--r--test/validation/scheduler/scheduler.c (renamed from test/validation/odp_scheduler.c)164
-rw-r--r--test/validation/scheduler/scheduler.h7
-rw-r--r--test/validation/scheduler/scheduler_main.c12
-rw-r--r--test/validation/synchronizers/.gitignore2
-rw-r--r--test/validation/synchronizers/Makefile.am8
-rw-r--r--test/validation/synchronizers/synchronizers.c (renamed from test/validation/odp_synchronizers.c)155
-rw-r--r--test/validation/synchronizers/synchronizers.h7
-rw-r--r--test/validation/synchronizers/synchronizers_main.c12
-rw-r--r--test/validation/system/.gitignore2
-rw-r--r--test/validation/system/Makefile.am8
-rw-r--r--test/validation/system/system.c (renamed from test/validation/odp_time.c)26
-rw-r--r--test/validation/system/system.h7
-rw-r--r--test/validation/system/system_main.c12
-rw-r--r--test/validation/thread/.gitignore2
-rw-r--r--test/validation/thread/Makefile.am8
-rw-r--r--test/validation/thread/thread.c47
-rw-r--r--test/validation/thread/thread.h7
-rw-r--r--test/validation/thread/thread_main.c12
102 files changed, 1461 insertions, 968 deletions
diff --git a/configure.ac b/configure.ac
index 3010789..28dad3b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -303,9 +303,21 @@ AC_CONFIG_FILES([Makefile
test/api_test/Makefile
test/performance/Makefile
test/validation/Makefile
+ test/validation/buffer/Makefile
+ test/validation/classification/Makefile
+ test/validation/cpumask/Makefile
test/validation/common/Makefile
test/validation/crypto/Makefile
+ test/validation/init/Makefile
+ test/validation/packet/Makefile
test/validation/pktio/Makefile
+ test/validation/pool/Makefile
+ test/validation/queue/Makefile
+ test/validation/random/Makefile
+ test/validation/scheduler/Makefile
+ test/validation/synchronizers/Makefile
+ test/validation/system/Makefile
+ test/validation/thread/Makefile
test/miscellaneous/Makefile
])
@@ -323,6 +335,7 @@ AC_SUBST([AM_CFLAGS])
AC_SUBST([CFLAGS])
AC_SUBST([AM_LDFLAGS])
AC_SUBST([LDFLAGS])
+AC_SUBST([EXEEXT])
AC_OUTPUT
AC_MSG_RESULT([
diff --git a/doc/odp.dox b/doc/odp.dox
index f574e21..0a3bc73 100644
--- a/doc/odp.dox
+++ b/doc/odp.dox
@@ -35,13 +35,6 @@
* of ODP, linux-generic is designed to provide best-in-class performance
* for general Linux data plane support.
*
- * @section ODP Releases
- *
- * ODP releases follow a standard three-level naming designation.
- * Changes to the API are reflected in the #ODP_VERSION_API_GENERATION
- * and #ODP_VERSION_API_MAJOR numbers. A change to the #ODP_VERSION_API_MINOR
- * number is used only for updates not breaking the API compatibility.
- *
* @section contact Contact Details
* - The main web site is http://www.opendataplane.org/
* - The git repo is https://git.linaro.org/lng/odp.git
diff --git a/doc/release.dox b/doc/release.dox
new file mode 100644
index 0000000..eb6eca7
--- /dev/null
+++ b/doc/release.dox
@@ -0,0 +1,65 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+@page release Release Management
+@tableofcontents
+@section api_numbering API Numbering
+
+The API uses a three digit release number, for ODP this number refers to
+- The API header definitions
+- The documentation
+
+ODP API releases follow a standard three-level naming designation.
+Changes to the API are reflected in the #ODP_VERSION_API_GENERATION and #ODP_VERSION_API_MAJOR numbers.
+A change to the #ODP_VERSION_API_MINOR number is used only for updates not breaking the API compatibility but which do touch the API source files in the include directory.
+
+The header file odp_version.h contains helper macros for dealing with ODP versions in application code.
+
+@note The version refers to API source compatibility and not binary compatibility.
+Every change in API version will require a recompilation, relinking will not be sufficient.
+
+The ODP API generation & major version will only change at well-defined release points.
+A release will be tagged @code v-<generation>.<major> @endcode and bug fix releases will be tagged @code v-<generation>.<major>.<minor> @endcode The first bug fix release minor = 1.
+
+The API odp_version_api_str() returns this string.
+
+@subsection generation Generation
+The digit is the ODP API generation.
+A change to this digit indicates a break in backwards compatibility.
+@note The incompatibility covers the whole ODP API, however the change may be a tiny change to an esoteric function that is not used by a given application.
+
+- Altering API signature
+- Altering a structure other than adding optional items at the end
+- Changing the required calling sequence for APIs
+- Changes to the installed structure i.e. the output from "make install" moves a file in a way that breaks compilation
+- New element to an enum that is an output from ODP
+
+@subsection major Major
+The digit is for changes that are likely backwards incompatible.
+For example changes such as the addition of a new API.
+Existing application code shall not have to change if the new API is not used.
+- Adding a new struct
+- Adding a new function
+- Adding an additional alternate API to an existing one
+- New element to an enum that is an input to ODP
+
+@subsection minor Minor
+The digit is used for backward compatible changes
+Any existing app should work as before.
+- Documentation updates
+
+@section implementation_string Implementation String
+
+The API odp_version_impl_str() returns a platform specific version string defined by the vendor.
+The intent of this string is to provide a unique identifier of the service level or build number of the implementation.
+Implementations should change this for each change they make (e.g., bug fix, performance improvement, etc.).
+It is recommended that this be in a format suitable for logging for serviceability tracking.
+
+This affects
+- The implementation
+- In the case of linux-generic it also covers the test & validation suite.
+*/
diff --git a/example/classifier/Makefile.am b/example/classifier/Makefile.am
index 938f094..0c66e14 100644
--- a/example/classifier/Makefile.am
+++ b/example/classifier/Makefile.am
@@ -1,6 +1,6 @@
include $(top_srcdir)/example/Makefile.inc
-bin_PROGRAMS = odp_classifier
+bin_PROGRAMS = odp_classifier$(EXEEXT)
odp_classifier_LDFLAGS = $(AM_LDFLAGS) -static
odp_classifier_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/example
diff --git a/example/generator/Makefile.am b/example/generator/Makefile.am
index fcb5965..49a7497 100644
--- a/example/generator/Makefile.am
+++ b/example/generator/Makefile.am
@@ -1,6 +1,6 @@
include $(top_srcdir)/example/Makefile.inc
-bin_PROGRAMS = odp_generator
+bin_PROGRAMS = odp_generator$(EXEEXT)
odp_generator_LDFLAGS = $(AM_LDFLAGS) -static
odp_generator_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/example
diff --git a/example/ipsec/Makefile.am b/example/ipsec/Makefile.am
index 0194f1b..c82ea0a 100644
--- a/example/ipsec/Makefile.am
+++ b/example/ipsec/Makefile.am
@@ -1,6 +1,6 @@
include $(top_srcdir)/example/Makefile.inc
-bin_PROGRAMS = odp_ipsec
+bin_PROGRAMS = odp_ipsec$(EXEEXT)
odp_ipsec_LDFLAGS = $(AM_LDFLAGS) -static
odp_ipsec_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/example
diff --git a/example/packet/Makefile.am b/example/packet/Makefile.am
index a36e29a..a811234 100644
--- a/example/packet/Makefile.am
+++ b/example/packet/Makefile.am
@@ -1,6 +1,6 @@
include $(top_srcdir)/example/Makefile.inc
-bin_PROGRAMS = odp_pktio
+bin_PROGRAMS = odp_pktio$(EXEEXT)
odp_pktio_LDFLAGS = $(AM_LDFLAGS) -static
odp_pktio_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/example
diff --git a/example/timer/Makefile.am b/example/timer/Makefile.am
index 04d51c4..fcb67a9 100644
--- a/example/timer/Makefile.am
+++ b/example/timer/Makefile.am
@@ -1,6 +1,6 @@
include $(top_srcdir)/example/Makefile.inc
-bin_PROGRAMS = odp_timer_test
+bin_PROGRAMS = odp_timer_test$(EXEEXT)
odp_timer_test_LDFLAGS = $(AM_LDFLAGS) -static
odp_timer_test_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/example
diff --git a/helper/linux.c b/helper/linux.c
index 2d5842c..4256f43 100644
--- a/helper/linux.c
+++ b/helper/linux.c
@@ -17,12 +17,10 @@
#include <stdio.h>
#include <odp/helper/linux.h>
-#include <odp_internal.h>
#include <odp/thread.h>
#include <odp/init.h>
#include <odp/system_info.h>
-#include <odp_debug_internal.h>
-
+#include "odph_debug.h"
static void *odp_run_start_routine(void *arg)
{
@@ -30,16 +28,16 @@ static void *odp_run_start_routine(void *arg)
/* ODP thread local init */
if (odp_init_local(ODP_THREAD_WORKER)) {
- ODP_ERR("Local init failed\n");
+ ODPH_ERR("Local init failed\n");
return NULL;
}
void *ret_ptr = start_args->start_routine(start_args->arg);
int ret = odp_term_local();
if (ret < 0)
- ODP_ERR("Local term failed\n");
+ ODPH_ERR("Local term failed\n");
else if (ret == 0 && odp_term_global())
- ODP_ERR("Global term failed\n");
+ ODPH_ERR("Global term failed\n");
return ret_ptr;
}
@@ -64,8 +62,8 @@ int odph_linux_pthread_create(odph_linux_pthread_t *thread_tbl,
cpu_count = odp_cpu_count();
if (num < 1 || num > cpu_count) {
- ODP_ERR("Invalid number of threads: %d (%d cores available)\n",
- num, cpu_count);
+ ODPH_ERR("Invalid number of threads: %d (%d cores available)\n",
+ num, cpu_count);
return 0;
}
@@ -85,7 +83,7 @@ int odph_linux_pthread_create(odph_linux_pthread_t *thread_tbl,
thread_tbl[i].start_args = malloc(sizeof(odp_start_args_t));
if (thread_tbl[i].start_args == NULL)
- ODP_ABORT("Malloc failed");
+ ODPH_ABORT("Malloc failed");
thread_tbl[i].start_args->start_routine = start_routine;
thread_tbl[i].start_args->arg = arg;
@@ -93,7 +91,7 @@ int odph_linux_pthread_create(odph_linux_pthread_t *thread_tbl,
ret = pthread_create(&thread_tbl[i].thread, &thread_tbl[i].attr,
odp_run_start_routine, thread_tbl[i].start_args);
if (ret != 0) {
- ODP_ERR("Failed to start thread on cpu #%d\n", cpu);
+ ODPH_ERR("Failed to start thread on cpu #%d\n", cpu);
free(thread_tbl[i].start_args);
break;
}
@@ -108,10 +106,15 @@ int odph_linux_pthread_create(odph_linux_pthread_t *thread_tbl,
void odph_linux_pthread_join(odph_linux_pthread_t *thread_tbl, int num)
{
int i;
+ int ret;
for (i = 0; i < num; i++) {
/* Wait thread to exit */
- pthread_join(thread_tbl[i].thread, NULL);
+ ret = pthread_join(thread_tbl[i].thread, NULL);
+ if (ret != 0) {
+ ODPH_ERR("Failed to join thread from cpu #%d\n",
+ thread_tbl[i].cpu);
+ }
pthread_attr_destroy(&thread_tbl[i].attr);
free(thread_tbl[i].start_args);
}
@@ -136,7 +139,7 @@ int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl,
cpu_count = odp_cpu_count();
if (num < 1 || num > cpu_count) {
- ODP_ERR("Bad num\n");
+ ODPH_ERR("Bad num\n");
return -1;
}
@@ -150,7 +153,7 @@ int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl,
pid = fork();
if (pid < 0) {
- ODP_ERR("fork() failed\n");
+ ODPH_ERR("fork() failed\n");
return -1;
}
@@ -165,12 +168,12 @@ int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl,
/* Child process */
if (sched_setaffinity(0, sizeof(cpu_set_t), &proc_mask.set)) {
- ODP_ERR("sched_setaffinity() failed\n");
+ ODPH_ERR("sched_setaffinity() failed\n");
return -2;
}
if (odp_init_local(ODP_THREAD_WORKER)) {
- ODP_ERR("Local init failed\n");
+ ODPH_ERR("Local init failed\n");
return -2;
}
@@ -201,7 +204,7 @@ int odph_linux_process_wait_n(odph_linux_process_t *proc_tbl, int num)
pid = wait(&status);
if (pid < 0) {
- ODP_ERR("wait() failed\n");
+ ODPH_ERR("wait() failed\n");
return -1;
}
@@ -213,7 +216,7 @@ int odph_linux_process_wait_n(odph_linux_process_t *proc_tbl, int num)
}
if (j == num) {
- ODP_ERR("Bad pid\n");
+ ODPH_ERR("Bad pid\n");
return -1;
}
}
diff --git a/helper/odph_debug.h b/helper/odph_debug.h
new file mode 100644
index 0000000..9c216cd
--- /dev/null
+++ b/helper/odph_debug.h
@@ -0,0 +1,93 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+/**
+ * @file
+ *
+ * HELPER debug
+ */
+
+#ifndef HELPER_DEBUG_H_
+#define HELPER_DEBUG_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef ODPH_DEBUG_PRINT
+#define ODPH_DEBUG_PRINT 1
+#endif
+
+/**
+ * log level.
+ */
+typedef enum HELPER_log_level {
+ ODPH_LOG_DBG,
+ ODPH_LOG_ERR,
+ ODPH_LOG_ABORT
+} HELPER_log_level_e;
+
+/**
+ * default LOG macro.
+ */
+#define ODPH_LOG(level, fmt, ...) \
+do { \
+ switch (level) { \
+ case ODPH_LOG_ERR: \
+ fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \
+ __LINE__, __func__, ##__VA_ARGS__); \
+ break; \
+ case ODPH_LOG_DBG: \
+ if (ODPH_DEBUG_PRINT == 1) \
+ fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \
+ __LINE__, __func__, ##__VA_ARGS__); \
+ break; \
+ case ODPH_LOG_ABORT: \
+ fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
+ __LINE__, __func__, ##__VA_ARGS__); \
+ abort(); \
+ break; \
+ default: \
+ fprintf(stderr, "Unknown LOG level"); \
+ break;\
+ } \
+} while (0)
+
+/**
+ * Debug printing macro, which prints output when DEBUG flag is set.
+ */
+#define ODPH_DBG(fmt, ...) \
+ ODPH_LOG(ODPH_LOG_DBG, fmt, ##__VA_ARGS__)
+
+/**
+ * Print output to stderr (file, line and function).
+ */
+#define ODPH_ERR(fmt, ...) \
+ ODPH_LOG(ODPH_LOG_ERR, fmt, ##__VA_ARGS__)
+
+/**
+ * Print output to stderr (file, line and function),
+ * then abort.
+ */
+#define ODPH_ABORT(fmt, ...) \
+ ODPH_LOG(ODPH_LOG_ABORT, fmt, ##__VA_ARGS__)
+
+/**
+ * @}
+ */
+
+/**
+ * Mark intentionally unused argument for functions
+ */
+#define ODPH_UNUSED __attribute__((__unused__))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/helper/odph_pause.h b/helper/odph_pause.h
new file mode 100644
index 0000000..5618f1f
--- /dev/null
+++ b/helper/odph_pause.h
@@ -0,0 +1,54 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ODPH_PAUSE_H_
+#define ODPH_PAUSE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Spin loop for helper internal use
+ */
+static inline void odph_pause(void)
+{
+#if defined __x86_64__ || defined __i386__
+
+#ifdef __SSE2__
+ __asm__ __volatile__ ("pause");
+#else
+ __asm__ __volatile__ ("rep; nop");
+#endif
+
+#elif defined __arm__
+
+#if __ARM_ARCH == 7
+ __asm__ __volatile__ ("nop");
+ __asm__ __volatile__ ("nop");
+ __asm__ __volatile__ ("nop");
+ __asm__ __volatile__ ("nop");
+#endif
+
+#elif defined __OCTEON__
+
+ __asm__ __volatile__ ("nop");
+ __asm__ __volatile__ ("nop");
+ __asm__ __volatile__ ("nop");
+ __asm__ __volatile__ ("nop");
+ __asm__ __volatile__ ("nop");
+ __asm__ __volatile__ ("nop");
+ __asm__ __volatile__ ("nop");
+ __asm__ __volatile__ ("nop");
+
+#endif
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/helper/ring.c b/helper/ring.c
index 67fece9..3122173 100644
--- a/helper/ring.c
+++ b/helper/ring.c
@@ -70,20 +70,20 @@
***************************************************************************/
#include <odp/shared_memory.h>
-#include <odp_internal.h>
-#include <odp_spin_internal.h>
-#include <odp_align_internal.h>
#include <odp/spinlock.h>
+#include "odph_pause.h"
#include <odp/align.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
-#include <odp_debug_internal.h>
+#include "odph_debug.h"
#include <odp/rwlock.h>
#include <odp/helper/ring.h>
static TAILQ_HEAD(, odph_ring) odp_ring_list;
+#define RING_VAL_IS_POWER_2(x) ((((x) - 1) & (x)) == 0)
+
/*
* the enqueue of pointers on the ring.
*/
@@ -161,9 +161,9 @@ odph_ring_create(const char *name, unsigned count, unsigned flags)
odp_shm_t shm;
/* count must be a power of 2 */
- if (!ODP_VAL_IS_POWER_2(count) || (count > ODPH_RING_SZ_MASK)) {
- ODP_ERR("Requested size is invalid, must be power of 2, and do not exceed the size limit %u\n",
- ODPH_RING_SZ_MASK);
+ if (!RING_VAL_IS_POWER_2(count) || (count > ODPH_RING_SZ_MASK)) {
+ ODPH_ERR("Requested size is invalid, must be power of 2, and do not exceed the size limit %u\n",
+ ODPH_RING_SZ_MASK);
return NULL;
}
@@ -194,7 +194,7 @@ odph_ring_create(const char *name, unsigned count, unsigned flags)
TAILQ_INSERT_TAIL(&odp_ring_list, r, next);
} else {
- ODP_ERR("Cannot reserve memory\n");
+ ODPH_ERR("Cannot reserve memory\n");
}
odp_rwlock_write_unlock(&qlock);
@@ -283,7 +283,7 @@ int __odph_ring_mp_do_enqueue(odph_ring_t *r, void * const *obj_table,
* we need to wait for them to complete
*/
while (odp_unlikely(r->prod.tail != prod_head))
- odp_spin();
+ odph_pause();
/* Release our entries and the memory they refer to */
__atomic_thread_fence(__ATOMIC_RELEASE);
@@ -400,7 +400,7 @@ int __odph_ring_mc_do_dequeue(odph_ring_t *r, void **obj_table,
* we need to wait for them to complete
*/
while (odp_unlikely(r->cons.tail != cons_head))
- odp_spin();
+ odph_pause();
/* Release our entries and the memory they refer to */
__atomic_thread_fence(__ATOMIC_RELEASE);
@@ -532,19 +532,19 @@ unsigned odph_ring_free_count(const odph_ring_t *r)
/* dump the status of the ring on the console */
void odph_ring_dump(const odph_ring_t *r)
{
- ODP_DBG("ring <%s>@%p\n", r->name, r);
- ODP_DBG(" flags=%x\n", r->flags);
- ODP_DBG(" size=%"PRIu32"\n", r->prod.size);
- ODP_DBG(" ct=%"PRIu32"\n", r->cons.tail);
- ODP_DBG(" ch=%"PRIu32"\n", r->cons.head);
- ODP_DBG(" pt=%"PRIu32"\n", r->prod.tail);
- ODP_DBG(" ph=%"PRIu32"\n", r->prod.head);
- ODP_DBG(" used=%u\n", odph_ring_count(r));
- ODP_DBG(" avail=%u\n", odph_ring_free_count(r));
+ ODPH_DBG("ring <%s>@%p\n", r->name, r);
+ ODPH_DBG(" flags=%x\n", r->flags);
+ ODPH_DBG(" size=%" PRIu32 "\n", r->prod.size);
+ ODPH_DBG(" ct=%" PRIu32 "\n", r->cons.tail);
+ ODPH_DBG(" ch=%" PRIu32 "\n", r->cons.head);
+ ODPH_DBG(" pt=%" PRIu32 "\n", r->prod.tail);
+ ODPH_DBG(" ph=%" PRIu32 "\n", r->prod.head);
+ ODPH_DBG(" used=%u\n", odph_ring_count(r));
+ ODPH_DBG(" avail=%u\n", odph_ring_free_count(r));
if (r->prod.watermark == r->prod.size)
- ODP_DBG(" watermark=0\n");
+ ODPH_DBG(" watermark=0\n");
else
- ODP_DBG(" watermark=%"PRIu32"\n", r->prod.watermark);
+ ODPH_DBG(" watermark=%" PRIu32 "\n", r->prod.watermark);
}
/* dump the status of all rings on the console */
diff --git a/helper/test/.gitignore b/helper/test/.gitignore
index fe65f30..3542630 100644
--- a/helper/test/.gitignore
+++ b/helper/test/.gitignore
@@ -1,4 +1,5 @@
*.trs
*.log
+odp_chksum
odp_process
odp_thread
diff --git a/helper/test/Makefile.am b/helper/test/Makefile.am
index ec8d2c7..9ac82eb 100644
--- a/helper/test/Makefile.am
+++ b/helper/test/Makefile.am
@@ -5,9 +5,9 @@ AM_LDFLAGS += -static
TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform} TEST_DIR=${builddir}
-EXECUTABLES = odp_chksum \
- odp_thread \
- odp_process
+EXECUTABLES = odp_chksum$(EXEEXT) \
+ odp_thread$(EXEEXT) \
+ odp_process$(EXEEXT)
COMPILE_ONLY =
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index 65a1bbf..765db34 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -140,7 +140,9 @@ subdirheaders_HEADERS = \
$(top_srcdir)/helper/include/odp/helper/linux.h \
$(top_srcdir)/helper/include/odp/helper/ring.h \
$(top_srcdir)/helper/include/odp/helper/tcp.h \
- $(top_srcdir)/helper/include/odp/helper/udp.h
+ $(top_srcdir)/helper/include/odp/helper/udp.h \
+ $(top_srcdir)/helper/odph_debug.h \
+ $(top_srcdir)/helper/odph_pause.h
__LIB__libodp_la_SOURCES = \
odp_barrier.c \
diff --git a/platform/linux-generic/include/odp_buffer_inlines.h b/platform/linux-generic/include/odp_buffer_inlines.h
index 91e56bd..74af38b 100644
--- a/platform/linux-generic/include/odp_buffer_inlines.h
+++ b/platform/linux-generic/include/odp_buffer_inlines.h
@@ -182,7 +182,9 @@ static inline void *segment_map(odp_buffer_hdr_t *buf,
/* Set seglen if caller is asking for it */
if (seglen != NULL) {
buf_left = limit - seg_offset;
- *seglen = buf_left < buf->segsize ? buf_left : buf->segsize;
+ *seglen = buf_left < buf->segsize ? buf_left :
+ (seg_offset >= buf->segsize ? buf->segsize :
+ buf->segsize - seg_offset);
}
return (void *)seg_addr;
diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h
index a3632fe..ef116c3 100644
--- a/platform/linux-generic/include/odp_buffer_internal.h
+++ b/platform/linux-generic/include/odp_buffer_internal.h
@@ -107,7 +107,6 @@ struct odp_buffer_hdr_t;
/* Common buffer header */
typedef struct odp_buffer_hdr_t {
struct odp_buffer_hdr_t *next; /* next buf in a list */
- int allocator; /* allocating thread id */
odp_buffer_bits_t handle; /* handle */
union {
uint32_t all;
@@ -116,8 +115,9 @@ typedef struct odp_buffer_hdr_t {
uint32_t hdrdata:1; /* Data is in buffer hdr */
};
} flags;
- int type; /* buffer type */
- int event_type; /* for reuse as event */
+ int16_t allocator; /* allocating thread id */
+ int8_t type; /* buffer type */
+ int8_t event_type; /* for reuse as event */
uint32_t size; /* max data size */
odp_atomic_u32_t ref_count; /* reference count */
odp_pool_t pool_hdl; /* buffer pool handle */
@@ -133,6 +133,11 @@ typedef struct odp_buffer_hdr_t {
void *addr[ODP_BUFFER_MAX_SEG]; /* block addrs */
} odp_buffer_hdr_t;
+/** @internal Compile time assert that the
+ * allocator field can handle any allocator id*/
+_ODP_STATIC_ASSERT(INT16_MAX >= ODP_CONFIG_MAX_THREADS,
+ "ODP_BUFFER_HDR_T__ALLOCATOR__SIZE_ERROR");
+
typedef struct odp_buffer_hdr_stride {
uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(odp_buffer_hdr_t))];
} odp_buffer_hdr_stride;
diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c
index f51d2de..d0c1f30 100644
--- a/platform/linux-generic/odp_timer.c
+++ b/platform/linux-generic/odp_timer.c
@@ -238,6 +238,7 @@ static odp_timer_pool *odp_timer_pool_new(
/* Initialize all odp_timer entries */
uint32_t i;
for (i = 0; i < tp->param.num_timers; i++) {
+ tp->timers[i].queue = ODP_QUEUE_INVALID;
set_next_free(&tp->timers[i], i + 1);
tp->timers[i].user_ptr = NULL;
odp_atomic_init_u64(&tp->tick_buf[i].exp_tck, TMO_UNUSED);
diff --git a/platform/linux-generic/test/Makefile.am b/platform/linux-generic/test/Makefile.am
index fd593f1..4f63dd0 100644
--- a/platform/linux-generic/test/Makefile.am
+++ b/platform/linux-generic/test/Makefile.am
@@ -4,7 +4,22 @@ ODP_MODULES = pktio
if test_vald
TESTS = pktio/pktio_run \
- ${top_builddir}/test/validation/crypto/crypto_main
+ ${top_builddir}/test/validation/buffer/buffer_main$(EXEEXT) \
+ ${top_builddir}/test/validation/classification/classification_main$(EXEEXT) \
+ ${top_builddir}/test/validation/cpumask/cpumask_main$(EXEEXT) \
+ ${top_builddir}/test/validation/crypto/crypto_main \
+ ${top_builddir}/test/validation/init/init_main_ok$(EXEEXT) \
+ ${top_builddir}/test/validation/init/init_main_abort$(EXEEXT) \
+ ${top_builddir}/test/validation/init/init_main_log$(EXEEXT) \
+ ${top_builddir}/test/validation/packet/packet_main$(EXEEXT) \
+ ${top_builddir}/test/validation/pool/pool_main$(EXEEXT) \
+ ${top_builddir}/test/validation/queue/queue_main$(EXEEXT) \
+ ${top_builddir}/test/validation/random/random_main$(EXEEXT) \
+ ${top_builddir}/test/validation/scheduler/scheduler_main$(EXEEXT) \
+ ${top_builddir}/test/validation/synchronizers/synchronizers_main$(EXEEXT) \
+ ${top_builddir}/test/validation/system/system_main$(EXEEXT) \
+ ${top_builddir}/test/validation/thread/thread_main$(EXEEXT)
+
SUBDIRS = $(ODP_MODULES)
endif
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index cee734a..00d30b2 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4259,6 +4259,9 @@ sub process {
$var !~ /\bCU_/ &&
$var !~ /\bPRI[diux]32/ &&
$var !~ /\bPRI[diux]64/ &&
+ $var !~ /\bSCN[diux]8/ &&
+ $var !~ /\bSCN[diux]32/ &&
+ $var !~ /\bSCN[diux]64/ &&
$var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/) {
while ($var =~ m{($Ident)}g) {
my $word = $1;
diff --git a/test/api_test/Makefile.am b/test/api_test/Makefile.am
index ddbac53..fcdba48 100644
--- a/test/api_test/Makefile.am
+++ b/test/api_test/Makefile.am
@@ -1,6 +1,6 @@
include $(top_srcdir)/test/Makefile.inc
-bin_PROGRAMS = odp_ring
+bin_PROGRAMS = odp_ring$(EXEEXT)
odp_ring_CFLAGS = $(AM_CFLAGS)
diff --git a/test/miscellaneous/Makefile.am b/test/miscellaneous/Makefile.am
index 863643c..7d8cf35 100644
--- a/test/miscellaneous/Makefile.am
+++ b/test/miscellaneous/Makefile.am
@@ -1,8 +1,8 @@
include $(top_srcdir)/test/Makefile.inc
if test_cpp
-bin_PROGRAMS = odp_api_from_cpp
-TESTS = odp_api_from_cpp
+bin_PROGRAMS = odp_api_from_cpp$(EXEEXT)
+TESTS = odp_api_from_cpp$(EXEEXT)
endif
odp_api_from_cpp_CXXFLAGS = $(AM_CXXFLAGS)
diff --git a/test/performance/Makefile.am b/test/performance/Makefile.am
index f128756..fc37305 100644
--- a/test/performance/Makefile.am
+++ b/test/performance/Makefile.am
@@ -2,10 +2,10 @@ include $(top_srcdir)/test/Makefile.inc
TESTS_ENVIRONMENT = TEST_DIR=${builddir} ODP_PLATFORM=${with_platform}
-EXECUTABLES = odp_atomic odp_pktio_perf
+EXECUTABLES = odp_atomic$(EXEEXT) odp_pktio_perf$(EXEEXT)
-COMPILE_ONLY = odp_l2fwd \
- odp_scheduling
+COMPILE_ONLY = odp_l2fwd$(EXEEXT) \
+ odp_scheduling$(EXEEXT)
TESTSCRIPTS = odp_l2fwd_run \
odp_scheduling_run
diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c
index 7a4582e..b21ef9c 100644
--- a/test/performance/odp_pktio_perf.c
+++ b/test/performance/odp_pktio_perf.c
@@ -605,18 +605,18 @@ static int run_test_single(odp_cpumask_t *thd_mask_tx,
odph_linux_pthread_create(&thd_tbl[0], thd_mask_rx,
run_thread_rx, &args_rx);
odp_barrier_wait(&gbl_args->rx_barrier);
+ num_rx_workers = odp_cpumask_count(thd_mask_rx);
/* then start transmitters */
num_tx_workers = odp_cpumask_count(thd_mask_tx);
args_tx.pps = status->pps_curr / num_tx_workers;
args_tx.duration = gbl_args->args.duration;
args_tx.batch_len = gbl_args->args.tx_batch_len;
- odph_linux_pthread_create(&thd_tbl[num_tx_workers], thd_mask_tx,
+ odph_linux_pthread_create(&thd_tbl[num_rx_workers], thd_mask_tx,
run_thread_tx, &args_tx);
odp_barrier_wait(&gbl_args->tx_barrier);
/* wait for transmitter threads to terminate */
- num_rx_workers = odp_cpumask_count(thd_mask_rx);
odph_linux_pthread_join(&thd_tbl[num_rx_workers],
num_tx_workers);
diff --git a/test/validation/.gitignore b/test/validation/.gitignore
index 765c8b0..b208bac 100644
--- a/test/validation/.gitignore
+++ b/test/validation/.gitignore
@@ -1,19 +1,5 @@
*.log
*.trs
odp_ver_abt_log_dbg
-odp_buffer
-odp_classification
-odp_cpumask
-odp_init
-odp_init_abort
-odp_init_log
-odp_packet
-odp_pool
-odp_queue
-odp_random
-odp_scheduler
odp_shared_memory
-odp_synchronizers
-odp_time
odp_timer
-odp_thread
diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index a0277e7..a2aef17 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -4,23 +4,9 @@ include $(top_srcdir)/test/Makefile.inc
AM_CFLAGS += -I$(srcdir)/common
AM_LDFLAGS += -static
-EXECUTABLES = odp_buffer \
- odp_classification \
- odp_cpumask \
- odp_init \
- odp_init_abort \
- odp_init_log \
- odp_packet \
- odp_pool \
- odp_queue \
- odp_random \
- odp_scheduler \
- odp_shared_memory \
- odp_synchronizers \
- odp_time \
- odp_timer \
- odp_thread \
- odp_ver_abt_log_dbg
+EXECUTABLES = odp_shared_memory$(EXEEXT) \
+ odp_timer$(EXEEXT) \
+ odp_ver_abt_log_dbg$(EXEEXT)
if test_vald
TESTS = $(EXECUTABLES)
@@ -30,33 +16,27 @@ bin_PROGRAMS = $(EXECUTABLES) $(COMPILE_ONLY)
ODP_CU_COMMON=common/odp_cunit_common.c
-odp_buffer_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/buffer
-dist_odp_buffer_SOURCES = odp_buffer.c
-odp_classification_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/classification
-dist_odp_classification_SOURCES = classification/odp_classification_tests.c \
- classification/odp_classification_basic.c \
- odp_classification.c
odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
-dist_odp_init_SOURCES = init/odp_init.c
-dist_odp_init_abort_SOURCES = init/odp_init_abort.c
-dist_odp_init_log_SOURCES = init/odp_init_log.c
-dist_odp_queue_SOURCES = odp_queue.c
-dist_odp_random_SOURCES = odp_random.c
-dist_odp_scheduler_SOURCES = odp_scheduler.c
dist_odp_shared_memory_SOURCES = odp_shared_memory.c
-dist_odp_synchronizers_SOURCES = odp_synchronizers.c
-dist_odp_time_SOURCES = odp_time.c
dist_odp_timer_SOURCES = odp_timer.c
-dist_odp_packet_SOURCES = odp_packet.c
-dist_odp_pool_SOURCES = odp_pool.c
-dist_odp_cpumask_SOURCES = odp_cpumask.c
-dist_odp_thread_SOURCES = odp_thread.c
odp_ver_abt_log_dbg_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/ver_abt_log_dbg
dist_odp_ver_abt_log_dbg_SOURCES = ver_abt_log_dbg/odp_system.c \
ver_abt_log_dbg/odp_errno.c \
ver_abt_log_dbg/odp_ver_abt_log_dbg.c
-ODP_MODULES = crypto \
- pktio
+ODP_MODULES = buffer \
+ classification \
+ cpumask \
+ crypto \
+ init \
+ queue \
+ packet \
+ pktio \
+ pool \
+ random \
+ scheduler \
+ synchronizers \
+ system \
+ thread
SUBDIRS = common $(ODP_MODULES)
diff --git a/test/validation/buffer/.gitignore b/test/validation/buffer/.gitignore
new file mode 100644
index 0000000..01a6b36
--- /dev/null
+++ b/test/validation/buffer/.gitignore
@@ -0,0 +1,2 @@
+buffer_main
+libbuffer.a
diff --git a/test/validation/buffer/Makefile.am b/test/validation/buffer/Makefile.am
new file mode 100644
index 0000000..8060240
--- /dev/null
+++ b/test/validation/buffer/Makefile.am
@@ -0,0 +1,8 @@
+include ../Makefile.inc
+
+noinst_LIBRARIES = libbuffer.a
+libbuffer_a_SOURCES = buffer.c
+
+bin_PROGRAMS = buffer_main$(EXEEXT)
+dist_buffer_main_SOURCES = buffer_main.c
+buffer_main_LDADD = libbuffer.a $(LIBCUNIT_COMMON) $(LIBODP)
diff --git a/test/validation/odp_buffer.c b/test/validation/buffer/buffer.c
index 141ecab..f67c55f 100644
--- a/test/validation/odp_buffer.c
+++ b/test/validation/buffer/buffer.c
@@ -6,6 +6,7 @@
#include <odp.h>
#include "odp_cunit_common.h"
+#include "buffer.h"
/* Helper macro for CU_TestInfo initialization */
#define _CU_TEST_INFO(test_func) {#test_func, test_func}
@@ -14,7 +15,7 @@ static odp_pool_t raw_pool;
static odp_buffer_t raw_buffer = ODP_BUFFER_INVALID;
static const size_t raw_buffer_size = 1500;
-static int buffer_testsuite_init(void)
+static int buffer_suite_init(void)
{
odp_pool_param_t params = {
.buf = {
@@ -34,7 +35,7 @@ static int buffer_testsuite_init(void)
return 0;
}
-static int buffer_testsuite_finalize(void)
+static int buffer_suite_term(void)
{
odp_buffer_free(raw_buffer);
if (odp_pool_destroy(raw_pool) != 0)
@@ -42,7 +43,7 @@ static int buffer_testsuite_finalize(void)
return 0;
}
-static void buffer_pool_alloc(void)
+static void buffer_test_pool_alloc(void)
{
odp_pool_t pool;
const int num = 3;
@@ -94,7 +95,7 @@ static void buffer_pool_alloc(void)
CU_ASSERT(odp_pool_destroy(pool) == 0);
}
-static void buffer_pool_free(void)
+static void buffer_test_pool_free(void)
{
odp_pool_t pool;
odp_buffer_t buffer;
@@ -126,7 +127,7 @@ static void buffer_pool_free(void)
CU_ASSERT(odp_pool_destroy(pool) == 0);
}
-static void buffer_management_basic(void)
+static void buffer_test_management_basic(void)
{
odp_event_t ev = odp_buffer_to_event(raw_buffer);
@@ -141,18 +142,23 @@ static void buffer_management_basic(void)
CU_ASSERT(odp_event_to_u64(ev) != odp_event_to_u64(ODP_EVENT_INVALID));
}
-static CU_TestInfo buffer_tests[] = {
- _CU_TEST_INFO(buffer_pool_alloc),
- _CU_TEST_INFO(buffer_pool_free),
- _CU_TEST_INFO(buffer_management_basic),
+static CU_TestInfo buffer_suite[] = {
+ _CU_TEST_INFO(buffer_test_pool_alloc),
+ _CU_TEST_INFO(buffer_test_pool_free),
+ _CU_TEST_INFO(buffer_test_management_basic),
CU_TEST_INFO_NULL,
};
-CU_SuiteInfo odp_testsuites[] = {
+static CU_SuiteInfo buffer_suites[] = {
{ .pName = "buffer tests",
- .pTests = buffer_tests,
- .pInitFunc = buffer_testsuite_init,
- .pCleanupFunc = buffer_testsuite_finalize,
+ .pTests = buffer_suite,
+ .pInitFunc = buffer_suite_init,
+ .pCleanupFunc = buffer_suite_term,
},
CU_SUITE_INFO_NULL,
};
+
+int buffer_main(void)
+{
+ return odp_cunit_run(buffer_suites);
+}
diff --git a/test/validation/buffer/buffer.h b/test/validation/buffer/buffer.h
new file mode 100644
index 0000000..44d05a2
--- /dev/null
+++ b/test/validation/buffer/buffer.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+int buffer_main(void);
diff --git a/test/validation/buffer/buffer_main.c b/test/validation/buffer/buffer_main.c
new file mode 100644
index 0000000..b9b5146
--- /dev/null
+++ b/test/validation/buffer/buffer_main.c
@@ -0,0 +1,11 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+#include "buffer.h"
+
+int main(void)
+{
+ return buffer_main();
+}
diff --git a/test/validation/buffer/odp_buffer_pool_test.c b/test/validation/buffer/odp_buffer_pool_test.c
deleted file mode 100644
index ebeae75..0000000
--- a/test/validation/buffer/odp_buffer_pool_test.c
+++ /dev/null
@@ -1,269 +0,0 @@
-/* Copyright (c) 2014, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "odp_buffer_tests.h"
-
-static int pool_name_number = 1;
-static const int default_buffer_size = 1500;
-static const int default_buffer_num = 1000;
-
-odp_pool_t pool_create(int num, int size, int type)
-{
- odp_pool_t pool;
- char pool_name[ODP_POOL_NAME_LEN];
- odp_pool_param_t param;
-
- memset(&param, 0, sizeof(param));
-
- switch (type) {
- case ODP_POOL_BUFFER:
- param.buf.size = size;
- param.buf.align = ODP_CACHE_LINE_SIZE;
- param.buf.num = num;
- break;
- case ODP_POOL_PACKET:
- param.pkt.seg_len = size;
- param.pkt.len = size;
- param.pkt.num = num;
- break;
- case ODP_POOL_TIMEOUT:
- param.tmo.num = num;
- break;
- default:
- CU_FAIL("Bad pool type");
- return ODP_POOL_INVALID;
- }
-
- param.type = type;
-
- snprintf(pool_name, sizeof(pool_name),
- "test_buffer_pool-%d", pool_name_number++);
-
- pool = odp_pool_create(pool_name, ODP_SHM_INVALID, &param);
- CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
-
- return pool;
-}
-
-static void pool_create_destroy_type(int type)
-{
- odp_pool_t pool;
- pool = pool_create(default_buffer_num, default_buffer_size, type);
-
- CU_ASSERT(odp_pool_destroy(pool) == 0);
-}
-
-static void pool_create_destroy_raw(void)
-{
- pool_create_destroy_type(ODP_POOL_BUFFER);
-}
-
-static void pool_create_destroy_packet(void)
-{
- pool_create_destroy_type(ODP_POOL_PACKET);
-}
-
-static void pool_create_destroy_timeout(void)
-{
- pool_create_destroy_type(ODP_POOL_TIMEOUT);
-}
-
-static void pool_create_destroy_raw_shm(void)
-{
- odp_pool_t pool;
- odp_shm_t test_shm;
- odp_pool_param_t params = {
- .buf = {
- .size = 1500,
- .align = ODP_CACHE_LINE_SIZE,
- .num = 10,
- },
- .type = ODP_POOL_BUFFER,
- };
-
- test_shm = odp_shm_reserve("test_shm",
- params.buf.size * params.buf.num * 2,
- ODP_CACHE_LINE_SIZE,
- 0);
- CU_ASSERT_FATAL(test_shm != ODP_SHM_INVALID);
-
- pool = odp_pool_create("test_shm_pool", test_shm, &params);
- CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
-
- CU_ASSERT(odp_pool_destroy(pool) == 0);
- CU_ASSERT(odp_shm_free(test_shm) == 0);
-}
-
-static void pool_lookup_info_print(void)
-{
- odp_pool_t pool;
- const char pool_name[] = "pool_for_lookup_test";
- odp_pool_info_t info;
- odp_pool_param_t params = {
- .buf = {
- .size = default_buffer_size,
- .align = ODP_CACHE_LINE_SIZE,
- .num = default_buffer_num,
- },
- .type = ODP_POOL_BUFFER,
- };
-
- pool = odp_pool_create(pool_name, ODP_SHM_INVALID, &params);
- CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
-
- pool = odp_pool_lookup(pool_name);
- CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
-
- CU_ASSERT_FATAL(odp_pool_info(pool, &info) == 0);
- CU_ASSERT(strncmp(pool_name, info.name, sizeof(pool_name)) == 0);
- CU_ASSERT(info.shm == ODP_SHM_INVALID);
- CU_ASSERT(params.buf.size <= info.params.buf.size);
- CU_ASSERT(params.buf.align <= info.params.buf.align);
- CU_ASSERT(params.buf.num <= info.params.buf.num);
- CU_ASSERT(params.type == info.params.type);
-
- odp_pool_print(pool);
-
- CU_ASSERT(odp_pool_destroy(pool) == 0);
-}
-
-static void pool_alloc_type(int type)
-{
- odp_pool_t pool;
- const int num = 3;
- const size_t size = 1500;
- odp_buffer_t buffer[num];
- odp_packet_t packet[num];
- odp_timeout_t tmo[num];
- odp_event_t ev;
- int index;
- char wrong_type = 0, wrong_size = 0;
-
- pool = pool_create(num, size, type);
- odp_pool_print(pool);
-
- /* Try to allocate num items from the pool */
- for (index = 0; index < num; index++) {
- switch (type) {
- case ODP_POOL_BUFFER:
- buffer[index] = odp_buffer_alloc(pool);
-
- if (buffer[index] == ODP_BUFFER_INVALID)
- break;
-
- ev = odp_buffer_to_event(buffer[index]);
- if (odp_event_type(ev) != ODP_EVENT_BUFFER)
- wrong_type = 1;
- if (odp_buffer_size(buffer[index]) < size)
- wrong_size = 1;
- if (wrong_type || wrong_size)
- odp_buffer_print(buffer[index]);
- break;
- case ODP_POOL_PACKET:
- packet[index] = odp_packet_alloc(pool, size);
-
- if (packet[index] == ODP_PACKET_INVALID)
- break;
-
- ev = odp_packet_to_event(packet[index]);
- if (odp_event_type(ev) != ODP_EVENT_PACKET)
- wrong_type = 1;
- break;
- case ODP_POOL_TIMEOUT:
- tmo[index] = odp_timeout_alloc(pool);
-
- if (tmo[index] == ODP_TIMEOUT_INVALID)
- break;
-
- ev = odp_timeout_to_event(tmo[index]);
- if (odp_event_type(ev) != ODP_EVENT_TIMEOUT)
- wrong_type = 1;
- break;
- default:
- break;
- }
-
- }
-
- /* Check that the pool had at least num items */
- CU_ASSERT(index == num);
- /* index points out of buffer[] or it point to an invalid buffer */
- index--;
-
- /* Check that the pool had correct buffers */
- CU_ASSERT(wrong_type == 0);
- CU_ASSERT(wrong_size == 0);
-
- switch (type) {
- case ODP_POOL_BUFFER:
- for (; index >= 0; index--)
- odp_buffer_free(buffer[index]);
- break;
- case ODP_POOL_PACKET:
- for (; index >= 0; index--)
- odp_packet_free(packet[index]);
- break;
- case ODP_POOL_TIMEOUT:
- for (; index >= 0; index--)
- odp_timeout_free(tmo[index]);
- break;
- default:
- break;
- }
-
- CU_ASSERT(odp_pool_destroy(pool) == 0);
-}
-
-static void pool_alloc_buffer_raw(void)
-{
- pool_alloc_type(ODP_POOL_BUFFER);
-}
-
-static void pool_alloc_buffer_packet(void)
-{
- pool_alloc_type(ODP_POOL_PACKET);
-}
-
-static void pool_alloc_buffer_timeout(void)
-{
- pool_alloc_type(ODP_POOL_TIMEOUT);
-}
-
-static void pool_free_buffer(void)
-{
- odp_pool_t pool;
- odp_buffer_t buffer;
- pool = pool_create(1, 64, ODP_POOL_BUFFER);
-
- /* Allocate the only buffer from the pool */
- buffer = odp_buffer_alloc(pool);
- CU_ASSERT_FATAL(buffer != ODP_BUFFER_INVALID);
-
- /** @todo: is it correct to assume the pool had only one buffer? */
- CU_ASSERT_FATAL(odp_buffer_alloc(pool) == ODP_BUFFER_INVALID)
-
- odp_buffer_free(buffer);
-
- /* Check that the buffer was returned back to the pool */
- buffer = odp_buffer_alloc(pool);
- CU_ASSERT_FATAL(buffer != ODP_BUFFER_INVALID);
-
- odp_buffer_free(buffer);
- CU_ASSERT(odp_pool_destroy(pool) == 0);
-}
-
-CU_TestInfo buffer_pool_tests[] = {
- _CU_TEST_INFO(pool_create_destroy_raw),
- _CU_TEST_INFO(pool_create_destroy_packet),
- _CU_TEST_INFO(pool_create_destroy_timeout),
- _CU_TEST_INFO(pool_create_destroy_raw_shm),
- _CU_TEST_INFO(pool_lookup_info_print),
- _CU_TEST_INFO(pool_alloc_buffer_raw),
- _CU_TEST_INFO(pool_alloc_buffer_packet),
- _CU_TEST_INFO(pool_alloc_buffer_timeout),
- _CU_TEST_INFO(pool_free_buffer),
- CU_TEST_INFO_NULL,
-};
diff --git a/test/validation/classification/.gitignore b/test/validation/classification/.gitignore
new file mode 100644
index 0000000..3887aec
--- /dev/null
+++ b/test/validation/classification/.gitignore
@@ -0,0 +1,2 @@
+classification_main
+libclassification.a
diff --git a/test/validation/classification/Makefile.am b/test/validation/classification/Makefile.am
new file mode 100644
index 0000000..35ed7ad
--- /dev/null
+++ b/test/validation/classification/Makefile.am
@@ -0,0 +1,10 @@
+include ../Makefile.inc
+
+noinst_LIBRARIES = libclassification.a
+libclassification_a_SOURCES = odp_classification_basic.c \
+ odp_classification_tests.c \
+ classification.c
+
+bin_PROGRAMS = classification_main$(EXEEXT)
+dist_classification_main_SOURCES = classification_main.c
+classification_main_LDADD = libclassification.a $(LIBCUNIT_COMMON) $(LIBODP)
diff --git a/test/validation/classification/classification.c b/test/validation/classification/classification.c
new file mode 100644
index 0000000..2582aaa
--- /dev/null
+++ b/test/validation/classification/classification.c
@@ -0,0 +1,27 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp.h>
+#include <odp_cunit_common.h>
+#include "odp_classification_testsuites.h"
+#include "classification.h"
+
+static CU_SuiteInfo classification_suites[] = {
+ { .pName = "classification basic",
+ .pTests = classification_suite_basic,
+ },
+ { .pName = "classification tests",
+ .pTests = classification_suite,
+ .pInitFunc = classification_suite_init,
+ .pCleanupFunc = classification_suite_term,
+ },
+ CU_SUITE_INFO_NULL,
+};
+
+int classification_main(void)
+{
+ return odp_cunit_run(classification_suites);
+}
diff --git a/test/validation/classification/classification.h b/test/validation/classification/classification.h
new file mode 100644
index 0000000..e677343
--- /dev/null
+++ b/test/validation/classification/classification.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+int classification_main(void);
diff --git a/test/validation/classification/classification_main.c b/test/validation/classification/classification_main.c
new file mode 100644
index 0000000..712fada
--- /dev/null
+++ b/test/validation/classification/classification_main.c
@@ -0,0 +1,12 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "classification.h"
+
+int main(void)
+{
+ return classification_main();
+}
diff --git a/test/validation/classification/odp_classification_basic.c b/test/validation/classification/odp_classification_basic.c
index b327e35..99202ee 100644
--- a/test/validation/classification/odp_classification_basic.c
+++ b/test/validation/classification/odp_classification_basic.c
@@ -8,7 +8,7 @@
#define PMR_SET_NUM 5
-static void classification_create_cos(void)
+static void classification_test_create_cos(void)
{
odp_cos_t cos;
char name[ODP_COS_NAME_LEN];
@@ -19,7 +19,7 @@ static void classification_create_cos(void)
odp_cos_destroy(cos);
}
-static void classification_destroy_cos(void)
+static void classification_test_destroy_cos(void)
{
odp_cos_t cos;
char name[ODP_COS_NAME_LEN];
@@ -33,7 +33,7 @@ static void classification_destroy_cos(void)
CU_ASSERT(retval < 0);
}
-static void classification_create_pmr_match(void)
+static void classification_test_create_pmr_match(void)
{
odp_pmr_t pmr;
uint16_t val;
@@ -46,7 +46,7 @@ static void classification_create_pmr_match(void)
odp_pmr_destroy(pmr);
}
-static void classification_destroy_pmr(void)
+static void classification_test_destroy_pmr(void)
{
odp_pmr_t pmr;
uint16_t val;
@@ -62,7 +62,7 @@ static void classification_destroy_pmr(void)
CU_ASSERT(retval < 0);
}
-static void classification_cos_set_queue(void)
+static void classification_test_cos_set_queue(void)
{
int retval;
char cosname[ODP_COS_NAME_LEN];
@@ -87,7 +87,7 @@ static void classification_cos_set_queue(void)
odp_queue_destroy(queue_cos);
}
-static void classification_cos_set_drop(void)
+static void classification_test_cos_set_drop(void)
{
int retval;
char cosname[ODP_COS_NAME_LEN];
@@ -103,7 +103,7 @@ static void classification_cos_set_drop(void)
odp_cos_destroy(cos_drop);
}
-static void classification_pmr_match_set_create(void)
+static void classification_test_pmr_match_set_create(void)
{
odp_pmr_set_t pmr_set;
int retval;
@@ -127,7 +127,7 @@ static void classification_pmr_match_set_create(void)
CU_ASSERT(retval == 0);
}
-static void classification_pmr_match_set_destroy(void)
+static void classification_test_pmr_match_set_destroy(void)
{
odp_pmr_set_t pmr_set;
int retval;
@@ -153,14 +153,14 @@ static void classification_pmr_match_set_destroy(void)
CU_ASSERT(retval == 0);
}
-CU_TestInfo classification_basic[] = {
- _CU_TEST_INFO(classification_create_cos),
- _CU_TEST_INFO(classification_destroy_cos),
- _CU_TEST_INFO(classification_create_pmr_match),
- _CU_TEST_INFO(classification_destroy_pmr),
- _CU_TEST_INFO(classification_cos_set_queue),
- _CU_TEST_INFO(classification_cos_set_drop),
- _CU_TEST_INFO(classification_pmr_match_set_create),
- _CU_TEST_INFO(classification_pmr_match_set_destroy),
+CU_TestInfo classification_suite_basic[] = {
+ _CU_TEST_INFO(classification_test_create_cos),
+ _CU_TEST_INFO(classification_test_destroy_cos),
+ _CU_TEST_INFO(classification_test_create_pmr_match),
+ _CU_TEST_INFO(classification_test_destroy_pmr),
+ _CU_TEST_INFO(classification_test_cos_set_queue),
+ _CU_TEST_INFO(classification_test_cos_set_drop),
+ _CU_TEST_INFO(classification_test_pmr_match_set_create),
+ _CU_TEST_INFO(classification_test_pmr_match_set_destroy),
CU_TEST_INFO_NULL,
};
diff --git a/test/validation/classification/odp_classification_tests.c b/test/validation/classification/odp_classification_tests.c
index db50ad5..ba7b360 100644
--- a/test/validation/classification/odp_classification_tests.c
+++ b/test/validation/classification/odp_classification_tests.c
@@ -267,7 +267,7 @@ odp_packet_t create_packet(bool vlan)
return pkt;
}
-int classification_tests_init(void)
+int classification_suite_init(void)
{
odp_pool_t pool;
odp_pool_param_t param;
@@ -326,7 +326,7 @@ int classification_tests_init(void)
return 0;
}
-int classification_tests_finalize(void)
+int classification_suite_term(void)
{
int i;
int retcode = 0;
@@ -567,7 +567,7 @@ void test_pktio_error_cos(void)
odp_packet_free(pkt);
}
-static void classification_pktio_set_skip(void)
+static void classification_test_pktio_set_skip(void)
{
int retval;
size_t offset = 5;
@@ -584,7 +584,7 @@ static void classification_pktio_set_skip(void)
CU_ASSERT(retval == 0);
}
-static void classification_pktio_set_headroom(void)
+static void classification_test_pktio_set_headroom(void)
{
size_t headroom;
int retval;
@@ -796,7 +796,7 @@ void test_pktio_pmr_match_set_cos(void)
odp_packet_free(pkt);
}
-static void classification_pmr_terms_avail(void)
+static void classification_test_pmr_terms_avail(void)
{
int retval;
/* Since this API called at the start of the suite the return value
@@ -805,7 +805,7 @@ static void classification_pmr_terms_avail(void)
CU_ASSERT(retval > 0);
}
-static void classification_pmr_terms_cap(void)
+static void classification_test_pmr_terms_cap(void)
{
unsigned long long retval;
/* Need to check different values for different platforms */
@@ -813,7 +813,7 @@ static void classification_pmr_terms_cap(void)
CU_ASSERT(retval | (1 << ODP_PMR_IPPROTO));
}
-static void classification_pktio_configure(void)
+static void classification_test_pktio_configure(void)
{
/* Configure the Different CoS for the pktio interface */
if (TEST_DEFAULT)
@@ -829,7 +829,8 @@ static void classification_pktio_configure(void)
if (TEST_PMR_SET)
configure_pktio_pmr_match_set_cos();
}
-static void classification_pktio_test(void)
+
+static void classification_test_pktio_test(void)
{
/* Test Different CoS on the pktio interface */
if (TEST_DEFAULT)
@@ -846,12 +847,12 @@ static void classification_pktio_test(void)
test_pktio_pmr_match_set_cos();
}
-CU_TestInfo classification_tests[] = {
- _CU_TEST_INFO(classification_pmr_terms_avail),
- _CU_TEST_INFO(classification_pktio_set_skip),
- _CU_TEST_INFO(classification_pktio_set_headroom),
- _CU_TEST_INFO(classification_pmr_terms_cap),
- _CU_TEST_INFO(classification_pktio_configure),
- _CU_TEST_INFO(classification_pktio_test),
+CU_TestInfo classification_suite[] = {
+ _CU_TEST_INFO(classification_test_pmr_terms_avail),
+ _CU_TEST_INFO(classification_test_pktio_set_skip),
+ _CU_TEST_INFO(classification_test_pktio_set_headroom),
+ _CU_TEST_INFO(classification_test_pmr_terms_cap),
+ _CU_TEST_INFO(classification_test_pktio_configure),
+ _CU_TEST_INFO(classification_test_pktio_test),
CU_TEST_INFO_NULL,
};
diff --git a/test/validation/classification/odp_classification_testsuites.h b/test/validation/classification/odp_classification_testsuites.h
index 0ac5eda..f603f30 100644
--- a/test/validation/classification/odp_classification_testsuites.h
+++ b/test/validation/classification/odp_classification_testsuites.h
@@ -14,11 +14,11 @@
/* Helper macro for CU_TestInfo initialization */
#define _CU_TEST_INFO(test_func) {#test_func, test_func}
-extern CU_TestInfo classification_tests[];
-extern CU_TestInfo classification_basic[];
+extern CU_TestInfo classification_suite[];
+extern CU_TestInfo classification_suite_basic[];
-extern int classification_tests_init(void);
-extern int classification_tests_finalize(void);
+int classification_suite_init(void);
+int classification_suite_term(void);
odp_packet_t create_packet(bool vlan);
void configure_pktio_default_cos(void);
diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c
index 690dca0..caf4ace 100644
--- a/test/validation/common/odp_cunit_common.c
+++ b/test/validation/common/odp_cunit_common.c
@@ -11,6 +11,15 @@
/* Globals */
static odph_linux_pthread_t thread_tbl[MAX_WORKERS];
+/*
+ * global init/term functions which may be registered
+ * defaults to functions performing odp init/term.
+ */
+static struct {
+ int (*global_init_ptr)(void);
+ int (*global_term_ptr)(void);
+} global_init_term = {tests_global_init, tests_global_term};
+
/** create test thread */
int odp_cunit_thread_create(void *func_ptr(void *), pthrd_arg *arg)
{
@@ -62,6 +71,26 @@ ODP_WEAK_SYMBOL int tests_global_term(void)
return 0;
}
+/*
+ * register tests_global_init and tests_global_term functions.
+ * If some of these functions are not registered, the defaults functions
+ * (tests_global_init() and tests_global_term()) defined above are used.
+ * One should use these register functions when defining these hooks.
+ * (overloading the weak symbol above is obsolete and will be removed in
+ * the future).
+ * Note that passing NULL as function pointer is valid and will simply
+ * prevent the default (odp init/term) to be done.
+ */
+void odp_cunit_register_global_init(int (*func_init_ptr)(void))
+{
+ global_init_term.global_init_ptr = func_init_ptr;
+}
+
+void odp_cunit_register_global_term(int (*func_term_ptr)(void))
+{
+ global_init_term.global_term_ptr = func_term_ptr;
+}
+
int odp_cunit_run(CU_SuiteInfo testsuites[])
{
int ret;
@@ -69,7 +98,9 @@ int odp_cunit_run(CU_SuiteInfo testsuites[])
printf("\tODP API version: %s\n", odp_version_api_str());
printf("\tODP implementation version: %s\n", odp_version_impl_str());
- if (0 != tests_global_init())
+ /* call test executable init hook, if any */
+ if (global_init_term.global_init_ptr &&
+ ((*global_init_term.global_init_ptr)() != 0))
return -1;
CU_set_error_action(CUEA_ABORT);
@@ -83,7 +114,9 @@ int odp_cunit_run(CU_SuiteInfo testsuites[])
CU_cleanup_registry();
- if (0 != tests_global_term())
+ /* call test executable terminason hook, if any */
+ if (global_init_term.global_term_ptr &&
+ ((*global_init_term.global_term_ptr)() != 0))
return -1;
return (ret) ? -1 : 0;
diff --git a/test/validation/common/odp_cunit_common.h b/test/validation/common/odp_cunit_common.h
index 3b4d9fb..bfb4cbf 100644
--- a/test/validation/common/odp_cunit_common.h
+++ b/test/validation/common/odp_cunit_common.h
@@ -43,21 +43,25 @@ typedef struct {
/** create thread fro start_routine function */
extern int odp_cunit_thread_create(void *func_ptr(void *), pthrd_arg *arg);
extern int odp_cunit_thread_exit(pthrd_arg *);
+
/**
- * Global tests initialization.
- *
- * Initialize global resources needed by all testsuites. Default weak definition
- * do nothing. Test application can override it by defining a strong version.
- * The function is called by the common main() just after ODP global/local
- * initialization.
+ * Global tests initialization/termination.
*
- * @note: This function is a workaround for Crypto test and other applications
- * should try not to use it, because it will complicate migration to a
- * single test application in future. Normally each testsuite have to
- * prepare its environment in its own init function.
+ * Initialize global resources needed by the test executable. Default
+ * definition does ODP init / term (both global and local).
+ * Test executables can override it by calling one of the register function
+ * below (or by defining a strong version, but this is deprecated).
+ * The functions are called at the very beginning and very end of the test
+ * execution. Passing NULL to odp_cunit_register_global_init() and/or
+ * odp_cunit_register_global_term() is legal and will simply prevent the
+ * default (ODP init/term) to be done.
*/
extern int tests_global_init(void);
extern int tests_global_term(void);
+void odp_cunit_register_global_init(int (*func_init_ptr)(void));
+
+void odp_cunit_register_global_term(int (*func_term_ptr)(void));
+
#endif /* ODP_CUNICT_COMMON_H */
diff --git a/test/validation/cpumask/.gitignore b/test/validation/cpumask/.gitignore
new file mode 100644
index 0000000..1dd4350
--- /dev/null
+++ b/test/validation/cpumask/.gitignore
@@ -0,0 +1,2 @@
+cpumask_main
+libcpumask.a
diff --git a/test/validation/cpumask/Makefile.am b/test/validation/cpumask/Makefile.am
new file mode 100644
index 0000000..61b65ec
--- /dev/null
+++ b/test/validation/cpumask/Makefile.am
@@ -0,0 +1,8 @@
+include ../Makefile.inc
+
+noinst_LIBRARIES = libcpumask.a
+libcpumask_a_SOURCES = cpumask.c
+
+bin_PROGRAMS = cpumask_main$(EXEEXT)
+dist_cpumask_main_SOURCES = cpumask_main.c
+cpumask_main_LDADD = libcpumask.a $(LIBCUNIT_COMMON) $(LIBODP)
diff --git a/test/validation/odp_cpumask.c b/test/validation/cpumask/cpumask.c
index 1b1c104..943a8e0 100644
--- a/test/validation/odp_cpumask.c
+++ b/test/validation/cpumask/cpumask.c
@@ -6,7 +6,7 @@
#include <odp.h>
#include "odp_cunit_common.h"
-
+#include "cpumask.h"
/*
* The following string are used to build cpu masks with
@@ -30,8 +30,6 @@
/* padding pattern used to check buffer overflow: */
#define FILLING_PATTERN 0x55
-
-
/*
* returns the length of a string, excluding terminating NULL.
* As its C lib strlen equivalent. Just rewritten here to avoid C lib
@@ -60,6 +58,7 @@ static void cpu_to_str(char *buff, int cpu)
{
const char *hex_nibble = "1248";
int i = 0;
+
buff[i++] = '0';
buff[i++] = 'x';
buff[i++] = hex_nibble[cpu % CPUS_PER_NIBBLE];
@@ -80,8 +79,7 @@ static unsigned int get_max_number_of_cpus_in_a_mask(void)
return odp_cpu_count();
}
-
-static void test_odp_cpumask_to_from_str(void)
+static void cpumask_test_odp_cpumask_to_from_str(void)
{
odp_cpumask_t mask;
int32_t str_sz;
@@ -99,7 +97,7 @@ static void test_odp_cpumask_to_from_str(void)
buf_sz = (get_max_number_of_cpus_in_a_mask() >> 2) + 20;
buf_in = malloc(buf_sz);
buf_out = malloc(buf_sz);
- CU_ASSERT_FATAL((buf_in != NULL) && (buf_out != NULL));
+ CU_ASSERT_FATAL(buf_in && buf_out);
/* test 1 CPU at a time for all possible cpu positions in the mask */
for (cpu = 0; cpu < get_max_number_of_cpus_in_a_mask(); cpu++) {
@@ -153,7 +151,7 @@ static void test_odp_cpumask_to_from_str(void)
free(buf_in);
}
-static void test_odp_cpumask_equal(void)
+static void cpumask_test_odp_cpumask_equal(void)
{
odp_cpumask_t mask1;
odp_cpumask_t mask2;
@@ -184,20 +182,22 @@ static void test_odp_cpumask_equal(void)
CU_ASSERT_FALSE(odp_cpumask_equal(&mask1, &mask3));
}
-static void test_odp_cpumask_zero(void)
+static void cpumask_test_odp_cpumask_zero(void)
{
odp_cpumask_t mask1;
odp_cpumask_t mask2;
+
odp_cpumask_from_str(&mask1, TEST_MASK_NO_CPU);
odp_cpumask_from_str(&mask2, TEST_MASK_CPU_0);
odp_cpumask_zero(&mask2);
CU_ASSERT(odp_cpumask_equal(&mask1, &mask2));
}
-static void test_odp_cpumask_set(void)
+static void cpumask_test_odp_cpumask_set(void)
{
odp_cpumask_t mask1;
odp_cpumask_t mask2;
+
odp_cpumask_from_str(&mask1, TEST_MASK_NO_CPU);
odp_cpumask_from_str(&mask2, TEST_MASK_CPU_0);
odp_cpumask_set(&mask1, 0);
@@ -215,7 +215,7 @@ static void test_odp_cpumask_set(void)
CU_ASSERT(odp_cpumask_equal(&mask1, &mask2));
}
-static void test_odp_cpumask_clr(void)
+static void cpumask_test_odp_cpumask_clr(void)
{
odp_cpumask_t mask1;
odp_cpumask_t mask2;
@@ -242,7 +242,7 @@ static void test_odp_cpumask_clr(void)
CU_ASSERT(odp_cpumask_equal(&mask1, &mask2));
}
-static void test_odp_cpumask_isset(void)
+static void cpumask_test_odp_cpumask_isset(void)
{
odp_cpumask_t mask1;
@@ -262,7 +262,7 @@ static void test_odp_cpumask_isset(void)
CU_ASSERT_FALSE(odp_cpumask_isset(&mask1, 3));
}
-static void test_odp_cpumask_count(void)
+static void cpumask_test_odp_cpumask_count(void)
{
odp_cpumask_t mask1;
@@ -279,7 +279,7 @@ static void test_odp_cpumask_count(void)
CU_ASSERT(odp_cpumask_count(&mask1) == 2);
}
-static void test_odp_cpumask_and(void)
+static void cpumask_test_odp_cpumask_and(void)
{
odp_cpumask_t mask1;
odp_cpumask_t mask2;
@@ -314,7 +314,7 @@ static void test_odp_cpumask_and(void)
CU_ASSERT(odp_cpumask_equal(&mask3, &mask4));
}
-static void test_odp_cpumask_or(void)
+static void cpumask_test_odp_cpumask_or(void)
{
odp_cpumask_t mask1;
odp_cpumask_t mask2;
@@ -349,7 +349,7 @@ static void test_odp_cpumask_or(void)
CU_ASSERT(odp_cpumask_equal(&mask3, &mask4));
}
-static void test_odp_cpumask_xor(void)
+static void cpumask_test_odp_cpumask_xor(void)
{
odp_cpumask_t mask1;
odp_cpumask_t mask2;
@@ -384,16 +384,17 @@ static void test_odp_cpumask_xor(void)
CU_ASSERT(odp_cpumask_equal(&mask3, &mask4));
}
-static void test_odp_cpumask_copy(void)
+static void cpumask_test_odp_cpumask_copy(void)
{
odp_cpumask_t mask1;
odp_cpumask_t mask2;
+
odp_cpumask_from_str(&mask1, TEST_MASK_CPU_0);
odp_cpumask_copy(&mask2, &mask1);
CU_ASSERT(odp_cpumask_equal(&mask1, &mask2));
}
-static void test_odp_cpumask_first(void)
+static void cpumask_test_odp_cpumask_first(void)
{
odp_cpumask_t mask1;
@@ -412,7 +413,7 @@ static void test_odp_cpumask_first(void)
CU_ASSERT(odp_cpumask_first(&mask1) == 1);
}
-static void test_odp_cpumask_last(void)
+static void cpumask_test_odp_cpumask_last(void)
{
odp_cpumask_t mask1;
@@ -431,7 +432,7 @@ static void test_odp_cpumask_last(void)
CU_ASSERT(odp_cpumask_last(&mask1) == 3);
}
-static void test_odp_cpumask_next(void)
+static void cpumask_test_odp_cpumask_next(void)
{
unsigned int i;
int expected[] = {1, 3, 3, -1};
@@ -455,25 +456,30 @@ static void test_odp_cpumask_next(void)
CU_ASSERT(odp_cpumask_next(&mask1, i) == expected[i]);
}
-CU_TestInfo test_odp_cpumask[] = {
- {"odp_cpumask_to/from_str()", test_odp_cpumask_to_from_str},
- {"odp_cpumask_equal()" , test_odp_cpumask_equal},
- {"odp_cpumask_zero()" , test_odp_cpumask_zero},
- {"odp_cpumask_set()" , test_odp_cpumask_set},
- {"odp_cpumask_clr()" , test_odp_cpumask_clr},
- {"odp_cpumask_isset()" , test_odp_cpumask_isset},
- {"odp_cpumask_count()" , test_odp_cpumask_count},
- {"odp_cpumask_and()" , test_odp_cpumask_and},
- {"odp_cpumask_or()" , test_odp_cpumask_or},
- {"odp_cpumask_xor()" , test_odp_cpumask_xor},
- {"odp_cpumask_copy()" , test_odp_cpumask_copy},
- {"odp_cpumask_first()" , test_odp_cpumask_first},
- {"odp_cpumask_last()" , test_odp_cpumask_last},
- {"odp_cpumask_next()" , test_odp_cpumask_next},
+static CU_TestInfo cpumask_suite[] = {
+ {"odp_cpumask_to/from_str()", cpumask_test_odp_cpumask_to_from_str},
+ {"odp_cpumask_equal()", cpumask_test_odp_cpumask_equal},
+ {"odp_cpumask_zero()", cpumask_test_odp_cpumask_zero},
+ {"odp_cpumask_set()", cpumask_test_odp_cpumask_set},
+ {"odp_cpumask_clr()", cpumask_test_odp_cpumask_clr},
+ {"odp_cpumask_isset()", cpumask_test_odp_cpumask_isset},
+ {"odp_cpumask_count()", cpumask_test_odp_cpumask_count},
+ {"odp_cpumask_and()", cpumask_test_odp_cpumask_and},
+ {"odp_cpumask_or()", cpumask_test_odp_cpumask_or},
+ {"odp_cpumask_xor()", cpumask_test_odp_cpumask_xor},
+ {"odp_cpumask_copy()", cpumask_test_odp_cpumask_copy},
+ {"odp_cpumask_first()", cpumask_test_odp_cpumask_first},
+ {"odp_cpumask_last()", cpumask_test_odp_cpumask_last},
+ {"odp_cpumask_next()", cpumask_test_odp_cpumask_next},
CU_TEST_INFO_NULL,
};
-CU_SuiteInfo odp_testsuites[] = {
- {"Cpumask", NULL, NULL, NULL, NULL, test_odp_cpumask},
+static CU_SuiteInfo cpumask_suites[] = {
+ {"Cpumask", NULL, NULL, NULL, NULL, cpumask_suite},
CU_SUITE_INFO_NULL,
};
+
+int cpumask_main(void)
+{
+ return odp_cunit_run(cpumask_suites);
+}
diff --git a/test/validation/cpumask/cpumask.h b/test/validation/cpumask/cpumask.h
new file mode 100644
index 0000000..c0d19a9
--- /dev/null
+++ b/test/validation/cpumask/cpumask.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+int cpumask_main(void);
diff --git a/test/validation/cpumask/cpumask_main.c b/test/validation/cpumask/cpumask_main.c
new file mode 100644
index 0000000..ceac674
--- /dev/null
+++ b/test/validation/cpumask/cpumask_main.c
@@ -0,0 +1,11 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+#include "cpumask.h"
+
+int main(void)
+{
+ return cpumask_main();
+}
diff --git a/test/validation/crypto/Makefile.am b/test/validation/crypto/Makefile.am
index 0ce3aa5..3bf5c56 100644
--- a/test/validation/crypto/Makefile.am
+++ b/test/validation/crypto/Makefile.am
@@ -4,6 +4,6 @@ noinst_LIBRARIES = libcrypto.a
libcrypto_a_SOURCES = crypto.c \
odp_crypto_test_inp.c
-bin_PROGRAMS = crypto_main
+bin_PROGRAMS = crypto_main$(EXEEXT)
dist_crypto_main_SOURCES = crypto_main.c
crypto_main_LDADD = libcrypto.a $(LIBCUNIT_COMMON) $(LIBODP)
diff --git a/test/validation/init/.gitignore b/test/validation/init/.gitignore
new file mode 100644
index 0000000..79eb713
--- /dev/null
+++ b/test/validation/init/.gitignore
@@ -0,0 +1,4 @@
+libinit.a
+init_main_abort
+init_main_log
+init_main_ok
diff --git a/test/validation/init/Makefile.am b/test/validation/init/Makefile.am
new file mode 100644
index 0000000..8fdafb3
--- /dev/null
+++ b/test/validation/init/Makefile.am
@@ -0,0 +1,14 @@
+include ../Makefile.inc
+noinst_LIBRARIES = libinit.a
+libinit_a_SOURCES = init.c
+
+# most platforms are expected not to support multiple ODP inits
+# following each other: therefore 3 separate binaries are
+# created, each containing its ODP init test.
+bin_PROGRAMS = init_main_abort$(EXEEXT) init_main_log$(EXEEXT) init_main_ok$(EXEEXT)
+dist_init_main_abort_SOURCES = init_main_abort.c
+dist_init_main_log_SOURCES = init_main_log.c
+dist_init_main_ok_SOURCES = init_main_ok.c
+init_main_abort_LDADD = libinit.a $(LIBCUNIT_COMMON) $(LIBODP)
+init_main_log_LDADD = libinit.a $(LIBCUNIT_COMMON) $(LIBODP)
+init_main_ok_LDADD = libinit.a $(LIBCUNIT_COMMON) $(LIBODP)
diff --git a/test/validation/init/init.c b/test/validation/init/init.c
new file mode 100644
index 0000000..169bd5c
--- /dev/null
+++ b/test/validation/init/init.c
@@ -0,0 +1,151 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <odp.h>
+#include <CUnit/Basic.h>
+#include "odp_cunit_common.h"
+#include "init.h"
+
+/* flag set when the replacement logging function is used */
+int replacement_logging_used;
+
+/* replacement abort function: */
+static void odp_init_abort(void) ODP_NORETURN;
+
+/* replacement log function: */
+ODP_PRINTF_FORMAT(2, 3)
+static int odp_init_log(odp_log_level_e level, const char *fmt, ...);
+
+/* test ODP global init, with alternate abort function */
+static void init_test_odp_init_global_replace_abort(void)
+{
+ int status;
+ struct odp_init_t init_data;
+
+ memset(&init_data, 0, sizeof(init_data));
+ init_data.abort_fn = &odp_init_abort;
+
+ status = odp_init_global(&init_data, NULL);
+ CU_ASSERT_FATAL(status == 0);
+
+ status = odp_term_global();
+ CU_ASSERT(status == 0);
+}
+
+static CU_TestInfo init_suite_abort[] = {
+ {"replace abort", init_test_odp_init_global_replace_abort},
+ CU_TEST_INFO_NULL,
+};
+
+static CU_SuiteInfo init_suites_abort[] = {
+ {"Init", NULL, NULL, NULL, NULL, init_suite_abort},
+ CU_SUITE_INFO_NULL,
+};
+
+static void odp_init_abort(void)
+{
+ abort();
+}
+
+int init_main_abort(void)
+{
+ /* prevent default ODP init: */
+ odp_cunit_register_global_init(NULL);
+ odp_cunit_register_global_term(NULL);
+
+ /* run the tests: */
+ return odp_cunit_run(init_suites_abort);
+}
+
+/* test ODP global init, with alternate log function */
+static void init_test_odp_init_global_replace_log(void)
+{
+ int status;
+ struct odp_init_t init_data;
+
+ memset(&init_data, 0, sizeof(init_data));
+ init_data.log_fn = &odp_init_log;
+
+ replacement_logging_used = 0;
+
+ status = odp_init_global(&init_data, NULL);
+ CU_ASSERT_FATAL(status == 0);
+
+ CU_ASSERT_TRUE(replacement_logging_used);
+
+ status = odp_term_global();
+ CU_ASSERT(status == 0);
+}
+
+static CU_TestInfo init_suite_log[] = {
+ {"replace log", init_test_odp_init_global_replace_log},
+ CU_TEST_INFO_NULL,
+};
+
+static CU_SuiteInfo init_suites_log[] = {
+ {"Init", NULL, NULL, NULL, NULL, init_suite_log},
+ CU_SUITE_INFO_NULL,
+};
+
+static int odp_init_log(odp_log_level_e level __attribute__((unused)),
+ const char *fmt, ...)
+{
+ va_list args;
+ int r;
+
+ /* just set a flag to be sure the replacement fn was used */
+ replacement_logging_used = 1;
+
+ va_start(args, fmt);
+ r = vfprintf(stderr, fmt, args);
+ va_end(args);
+
+ return r;
+}
+
+int init_main_log(void)
+{
+ /* prevent default ODP init: */
+ odp_cunit_register_global_init(NULL);
+ odp_cunit_register_global_term(NULL);
+
+ /* run the tests: */
+ return odp_cunit_run(init_suites_log);
+}
+
+/* test normal ODP global init */
+static void init_test_odp_init_global(void)
+{
+ int status;
+
+ status = odp_init_global(NULL, NULL);
+ CU_ASSERT_FATAL(status == 0);
+
+ status = odp_term_global();
+ CU_ASSERT(status == 0);
+}
+
+static CU_TestInfo init_suite_ok[] = {
+ {"test_odp_init_global", init_test_odp_init_global},
+ CU_TEST_INFO_NULL,
+};
+
+static CU_SuiteInfo init_suites_ok[] = {
+ {"Init", NULL, NULL, NULL, NULL, init_suite_ok},
+ CU_SUITE_INFO_NULL,
+};
+
+int init_main_ok(void)
+{
+ /* prevent default ODP init: */
+ odp_cunit_register_global_init(NULL);
+ odp_cunit_register_global_term(NULL);
+
+ /* run the tests: */
+ return odp_cunit_run(init_suites_ok);
+}
diff --git a/test/validation/init/init.h b/test/validation/init/init.h
new file mode 100644
index 0000000..ca03994
--- /dev/null
+++ b/test/validation/init/init.h
@@ -0,0 +1,9 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+int init_main_abort(void);
+int init_main_log(void);
+int init_main_ok(void);
diff --git a/test/validation/init/init_main_abort.c b/test/validation/init/init_main_abort.c
new file mode 100644
index 0000000..c7bdd9d
--- /dev/null
+++ b/test/validation/init/init_main_abort.c
@@ -0,0 +1,11 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+#include "init.h"
+
+int main(void)
+{
+ return init_main_abort();
+}
diff --git a/test/validation/init/init_main_log.c b/test/validation/init/init_main_log.c
new file mode 100644
index 0000000..f35ac38
--- /dev/null
+++ b/test/validation/init/init_main_log.c
@@ -0,0 +1,11 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+#include "init.h"
+
+int main(void)
+{
+ return init_main_log();
+}
diff --git a/test/validation/init/init_main_ok.c b/test/validation/init/init_main_ok.c
new file mode 100644
index 0000000..285c747
--- /dev/null
+++ b/test/validation/init/init_main_ok.c
@@ -0,0 +1,11 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+#include "init.h"
+
+int main(void)
+{
+ return init_main_ok();
+}
diff --git a/test/validation/init/odp_init.c b/test/validation/init/odp_init.c
deleted file mode 100644
index 082e7c2..0000000
--- a/test/validation/init/odp_init.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Copyright (c) 2014, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <stdarg.h>
-#include <odp.h>
-#include <CUnit/Basic.h>
-#include "odp_cunit_common.h"
-
-#define DEFAULT_MSG_POOL_SIZE (4 * 1024 * 1024)
-#define DEFAULT_MSG_SIZE (8)
-
-/* overwrite common default so as not to perform odp init in main */
-int tests_global_init(void)
-{
- return 0;
-}
-
-/* overwrite common default so as not to perform odp term in main */
-int tests_global_term(void)
-{
- return 0;
-}
-
-static void test_odp_init_global(void)
-{
- int status;
-
- status = odp_init_global(NULL, NULL);
- CU_ASSERT_FATAL(status == 0);
-
- status = odp_term_global();
- CU_ASSERT(status == 0);
-}
-
-CU_TestInfo test_odp_init[] = {
- {"test_odp_init_global", test_odp_init_global},
- CU_TEST_INFO_NULL,
-};
-
-CU_SuiteInfo odp_testsuites[] = {
- {"Init", NULL, NULL, NULL, NULL, test_odp_init},
- CU_SUITE_INFO_NULL,
-};
diff --git a/test/validation/init/odp_init_abort.c b/test/validation/init/odp_init_abort.c
deleted file mode 100644
index c83c8d3..0000000
--- a/test/validation/init/odp_init_abort.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright (c) 2015, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <stdarg.h>
-#include <stdlib.h>
-#include <odp.h>
-#include <CUnit/Basic.h>
-#include "odp_cunit_common.h"
-
-/* overwrite common default so as not to perform odp init in main */
-int tests_global_init(void)
-{
- return 0;
-}
-
-/* overwrite common default so as not to perform odp term in main */
-int tests_global_term(void)
-{
- return 0;
-}
-
-
-static void odp_init_abort(void) ODP_NORETURN;
-
-static void test_odp_init_global_replace_abort(void)
-{
- int status;
- struct odp_init_t init_data;
-
- memset(&init_data, 0, sizeof(init_data));
- init_data.abort_fn = &odp_init_abort;
-
- status = odp_init_global(&init_data, NULL);
- CU_ASSERT_FATAL(status == 0);
-
- status = odp_term_global();
- CU_ASSERT(status == 0);
-}
-
-CU_TestInfo test_odp_init[] = {
- {"replace abort", test_odp_init_global_replace_abort},
- CU_TEST_INFO_NULL,
-};
-
-CU_SuiteInfo odp_testsuites[] = {
- {"Init", NULL, NULL, NULL, NULL, test_odp_init},
- CU_SUITE_INFO_NULL,
-};
-
-void odp_init_abort(void)
-{
- abort();
-}
diff --git a/test/validation/init/odp_init_log.c b/test/validation/init/odp_init_log.c
deleted file mode 100644
index fe1be71..0000000
--- a/test/validation/init/odp_init_log.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/* Copyright (c) 2015, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <stdarg.h>
-#include <odp.h>
-#include <CUnit/Basic.h>
-#include "odp_cunit_common.h"
-
-int replacement_logging_used;
-
-/* overwrite common default so as not to perform odp init in main */
-int tests_global_init(void)
-{
- return 0;
-}
-
-/* overwrite common default so as not to perform odp term in main */
-int tests_global_term(void)
-{
- return 0;
-}
-
-ODP_PRINTF_FORMAT(2, 3)
-static int odp_init_log(odp_log_level_e level, const char *fmt, ...);
-
-static void test_odp_init_global_replace_log(void)
-{
- int status;
- struct odp_init_t init_data;
-
- memset(&init_data, 0, sizeof(init_data));
- init_data.log_fn = &odp_init_log;
-
- replacement_logging_used = 0;
-
- status = odp_init_global(&init_data, NULL);
- CU_ASSERT_FATAL(status == 0);
-
- CU_ASSERT_TRUE(replacement_logging_used);
-
- status = odp_term_global();
- CU_ASSERT(status == 0);
-}
-
-CU_TestInfo test_odp_init[] = {
- {"replace log", test_odp_init_global_replace_log},
- CU_TEST_INFO_NULL,
-};
-
-CU_SuiteInfo odp_testsuites[] = {
- {"Init", NULL, NULL, NULL, NULL, test_odp_init},
- CU_SUITE_INFO_NULL,
-};
-
-int odp_init_log(odp_log_level_e level __attribute__((unused)),
- const char *fmt, ...)
-{
- va_list args;
- int r;
-
- /* just set a flag to be sure the replacement fn was used */
- replacement_logging_used = 1;
-
- va_start(args, fmt);
- r = vfprintf(stderr, fmt, args);
- va_end(args);
-
- return r;
-}
diff --git a/test/validation/odp_classification.c b/test/validation/odp_classification.c
deleted file mode 100644
index b501015..0000000
--- a/test/validation/odp_classification.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright (c) 2015, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "odp_classification_testsuites.h"
-
-CU_SuiteInfo odp_testsuites[] = {
- { .pName = "classification basic",
- .pTests = classification_basic,
- },
- { .pName = "classification tests",
- .pTests = classification_tests,
- .pInitFunc = classification_tests_init,
- .pCleanupFunc = classification_tests_finalize,
- },
- CU_SUITE_INFO_NULL,
-};
diff --git a/test/validation/odp_thread.c b/test/validation/odp_thread.c
deleted file mode 100644
index 84db1e7..0000000
--- a/test/validation/odp_thread.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright (c) 2015, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <odp.h>
-#include <odp_cunit_common.h>
-
-/* Helper macro for CU_TestInfo initialization */
-#define _CU_TEST_INFO(test_func) {#test_func, test_func}
-
-static void test_odp_cpu_id(void)
-{
- (void) odp_cpu_id();
- CU_PASS();
-}
-
-static void test_odp_thread_id(void)
-{
- (void) odp_thread_id();
- CU_PASS();
-}
-
-static void test_odp_thread_count(void)
-{
- (void) odp_thread_count();
- CU_PASS();
-}
-
-CU_TestInfo test_odp_thread[] = {
- _CU_TEST_INFO(test_odp_cpu_id),
- _CU_TEST_INFO(test_odp_thread_id),
- _CU_TEST_INFO(test_odp_thread_count),
- CU_TEST_INFO_NULL,
-};
-
-CU_SuiteInfo odp_testsuites[] = {
- {"thread", NULL, NULL, NULL, NULL, test_odp_thread},
- CU_SUITE_INFO_NULL,
-};
diff --git a/test/validation/packet/.gitignore b/test/validation/packet/.gitignore
new file mode 100644
index 0000000..36fb9d3
--- /dev/null
+++ b/test/validation/packet/.gitignore
@@ -0,0 +1,2 @@
+libpacket.a
+packet_main
diff --git a/test/validation/packet/Makefile.am b/test/validation/packet/Makefile.am
new file mode 100644
index 0000000..8e58808
--- /dev/null
+++ b/test/validation/packet/Makefile.am
@@ -0,0 +1,8 @@
+include ../Makefile.inc
+
+noinst_LIBRARIES = libpacket.a
+libpacket_a_SOURCES = packet.c
+
+bin_PROGRAMS = packet_main$(EXEEXT)
+dist_packet_main_SOURCES = packet_main.c
+packet_main_LDADD = libpacket.a $(LIBCUNIT_COMMON) $(LIBODP)
diff --git a/test/validation/odp_packet.c b/test/validation/packet/packet.c
index 2628404..e6fb18a 100644
--- a/test/validation/odp_packet.c
+++ b/test/validation/packet/packet.c
@@ -8,6 +8,7 @@
#include <odp.h>
#include "odp_cunit_common.h"
+#include "packet.h"
/* Helper macro for CU_TestInfo initialization */
#define _CU_TEST_INFO(test_func) {#test_func, test_func}
@@ -22,7 +23,11 @@ static const uint32_t packet_len = PACKET_BUF_LEN -
ODP_CONFIG_PACKET_TAILROOM -
PACKET_TAILROOM_RESERVE;
-odp_packet_t test_packet;
+static const uint32_t segmented_packet_len = PACKET_BUF_LEN * 5 -
+ ODP_CONFIG_PACKET_HEADROOM - ODP_CONFIG_PACKET_TAILROOM -
+ PACKET_TAILROOM_RESERVE;
+
+odp_packet_t test_packet, segmented_test_packet;
static struct udata_struct {
uint64_t u64;
@@ -34,7 +39,7 @@ static struct udata_struct {
"abcdefg",
};
-static int packet_testsuite_init(void)
+static int packet_suite_init(void)
{
odp_pool_param_t params = {
.pkt = {
@@ -53,29 +58,39 @@ static int packet_testsuite_init(void)
return -1;
test_packet = odp_packet_alloc(packet_pool, packet_len);
+ segmented_test_packet = odp_packet_alloc(packet_pool,
+ segmented_packet_len);
- if (odp_packet_is_valid(test_packet) == 0)
+ if (odp_packet_is_valid(test_packet) == 0 ||
+ odp_packet_is_valid(segmented_test_packet) == 0)
return -1;
udat = odp_packet_user_area(test_packet);
udat_size = odp_packet_user_area_size(test_packet);
- if (udat == NULL || udat_size != sizeof(struct udata_struct))
+ if (!udat || udat_size != sizeof(struct udata_struct))
return -1;
odp_pool_print(packet_pool);
memcpy(udat, &test_packet_udata, sizeof(struct udata_struct));
+ udat = odp_packet_user_area(segmented_test_packet);
+ udat_size = odp_packet_user_area_size(segmented_test_packet);
+ if (udat == NULL || udat_size != sizeof(struct udata_struct))
+ return -1;
+ memcpy(udat, &test_packet_udata, sizeof(struct udata_struct));
+
return 0;
}
-static int packet_testsuite_finalize(void)
+static int packet_suite_term(void)
{
odp_packet_free(test_packet);
+ odp_packet_free(segmented_test_packet);
if (odp_pool_destroy(packet_pool) != 0)
return -1;
return 0;
}
-static void packet_alloc_free(void)
+static void packet_test_alloc_free(void)
{
odp_pool_t pool;
odp_packet_t packet;
@@ -114,7 +129,7 @@ static void packet_alloc_free(void)
CU_ASSERT(odp_pool_destroy(pool) == 0);
}
-static void packet_alloc_segmented(void)
+static void packet_test_alloc_segmented(void)
{
odp_packet_t pkt;
const uint32_t len = ODP_CONFIG_PACKET_BUF_LEN_MAX -
@@ -127,7 +142,7 @@ static void packet_alloc_segmented(void)
odp_packet_free(pkt);
}
-static void packet_event_conversion(void)
+static void packet_test_event_conversion(void)
{
odp_packet_t pkt = test_packet;
odp_packet_t tmp_pkt;
@@ -142,18 +157,19 @@ static void packet_event_conversion(void)
/** @todo: Need an API to compare packets */
}
-static void packet_basic_metadata(void)
+static void packet_test_basic_metadata(void)
{
odp_packet_t pkt = test_packet;
- CU_ASSERT(odp_packet_head(pkt) != NULL);
- CU_ASSERT(odp_packet_data(pkt) != NULL);
+
+ CU_ASSERT_PTR_NOT_NULL(odp_packet_head(pkt));
+ CU_ASSERT_PTR_NOT_NULL(odp_packet_data(pkt));
CU_ASSERT(odp_packet_pool(pkt) != ODP_POOL_INVALID);
/* Packet was allocated by application so shouldn't have valid pktio. */
CU_ASSERT(odp_packet_input(pkt) == ODP_PKTIO_INVALID);
}
-static void packet_length(void)
+static void packet_test_length(void)
{
odp_packet_t pkt = test_packet;
uint32_t buf_len, headroom, tailroom;
@@ -172,13 +188,13 @@ static void packet_length(void)
CU_ASSERT(buf_len >= packet_len + headroom + tailroom);
}
-static void packet_debug(void)
+static void packet_test_debug(void)
{
CU_ASSERT(odp_packet_is_valid(test_packet) == 1);
odp_packet_print(test_packet);
}
-static void packet_context(void)
+static void packet_test_context(void)
{
odp_packet_t pkt = test_packet;
char ptr_test_value = 2;
@@ -191,7 +207,7 @@ static void packet_context(void)
odp_packet_user_ptr_set(pkt, prev_ptr);
udat = odp_packet_user_area(pkt);
- CU_ASSERT(udat != NULL);
+ CU_ASSERT_PTR_NOT_NULL(udat);
CU_ASSERT(odp_packet_user_area_size(pkt) ==
sizeof(struct udata_struct));
CU_ASSERT(memcmp(udat, &test_packet_udata, sizeof(struct udata_struct))
@@ -200,7 +216,7 @@ static void packet_context(void)
odp_packet_reset(pkt, packet_len);
}
-static void packet_layer_offsets(void)
+static void packet_test_layer_offsets(void)
{
odp_packet_t pkt = test_packet;
uint8_t *l2_addr, *l3_addr, *l4_addr;
@@ -225,7 +241,7 @@ static void packet_layer_offsets(void)
CU_ASSERT(seg_len != 0);
l4_addr = odp_packet_l4_ptr(pkt, &seg_len);
CU_ASSERT(seg_len != 0);
- CU_ASSERT(l2_addr != NULL);
+ CU_ASSERT_PTR_NOT_NULL(l2_addr);
CU_ASSERT(l2_addr == l3_addr);
CU_ASSERT(l2_addr == l4_addr);
@@ -239,11 +255,11 @@ static void packet_layer_offsets(void)
/* Addresses should not be the same */
l2_addr = odp_packet_l2_ptr(pkt, NULL);
- CU_ASSERT(l2_addr != NULL);
+ CU_ASSERT_PTR_NOT_NULL(l2_addr);
l3_addr = odp_packet_l3_ptr(pkt, NULL);
- CU_ASSERT(l3_addr != NULL);
+ CU_ASSERT_PTR_NOT_NULL(l3_addr);
l4_addr = odp_packet_l4_ptr(pkt, NULL);
- CU_ASSERT(l4_addr != NULL);
+ CU_ASSERT_PTR_NOT_NULL(l4_addr);
CU_ASSERT(l2_addr != l3_addr);
CU_ASSERT(l2_addr != l4_addr);
@@ -265,7 +281,7 @@ static void _verify_headroom_shift(odp_packet_t packet,
else
data = odp_packet_pull_head(packet, -shift);
- CU_ASSERT(data != NULL);
+ CU_ASSERT_PTR_NOT_NULL(data);
CU_ASSERT(odp_packet_headroom(packet) == room - shift);
CU_ASSERT(odp_packet_seg_len(packet) == seg_data_len + shift);
CU_ASSERT(odp_packet_len(packet) == pkt_data_len + shift);
@@ -274,7 +290,7 @@ static void _verify_headroom_shift(odp_packet_t packet,
CU_ASSERT(data == data_orig - shift);
}
-static void packet_headroom(void)
+static void packet_test_headroom(void)
{
odp_packet_t pkt = test_packet;
uint32_t room;
@@ -317,6 +333,7 @@ static void _verify_tailroom_shift(odp_packet_t pkt,
if (shift >= 0) {
uint32_t l2_off, l3_off, l4_off;
+
l2_off = odp_packet_l2_offset(pkt);
l3_off = odp_packet_l3_offset(pkt);
l4_off = odp_packet_l4_offset(pkt);
@@ -330,7 +347,7 @@ static void _verify_tailroom_shift(odp_packet_t pkt,
tail = odp_packet_pull_tail(pkt, -shift);
}
- CU_ASSERT(tail != NULL);
+ CU_ASSERT_PTR_NOT_NULL(tail);
CU_ASSERT(odp_packet_seg_data_len(pkt, seg) == seg_data_len + shift);
CU_ASSERT(odp_packet_len(pkt) == pkt_data_len + shift);
CU_ASSERT(odp_packet_tailroom(pkt) == room - shift);
@@ -345,7 +362,7 @@ static void _verify_tailroom_shift(odp_packet_t pkt,
}
}
-static void packet_tailroom(void)
+static void packet_test_tailroom(void)
{
odp_packet_t pkt = test_packet;
odp_packet_seg_t segment;
@@ -372,12 +389,13 @@ static void packet_tailroom(void)
_verify_tailroom_shift(pkt, 0);
}
-static void packet_segments(void)
+static void packet_test_segments(void)
{
int num_segs, seg_index;
uint32_t data_len, buf_len;
odp_packet_seg_t seg;
odp_packet_t pkt = test_packet;
+ odp_packet_t seg_pkt = segmented_test_packet;
CU_ASSERT(odp_packet_is_valid(pkt) == 1);
@@ -390,6 +408,8 @@ static void packet_segments(void)
CU_ASSERT(num_segs == 1);
}
+ CU_ASSERT(odp_packet_is_segmented(pkt) == 0);
+ CU_ASSERT(odp_packet_is_segmented(seg_pkt) == 1);
seg = odp_packet_first_seg(pkt);
buf_len = 0;
@@ -407,8 +427,8 @@ static void packet_segments(void)
CU_ASSERT(seg_buf_len > 0);
CU_ASSERT(seg_data_len > 0);
CU_ASSERT(seg_buf_len >= seg_data_len);
- CU_ASSERT(seg_data != NULL);
- CU_ASSERT(seg_buf_addr != NULL);
+ CU_ASSERT_PTR_NOT_NULL(seg_data);
+ CU_ASSERT_PTR_NOT_NULL(seg_buf_addr);
CU_ASSERT(seg_data >= seg_buf_addr);
CU_ASSERT(odp_packet_seg_to_u64(seg) !=
odp_packet_seg_to_u64(ODP_PACKET_SEG_INVALID));
@@ -427,9 +447,49 @@ static void packet_segments(void)
if (seg_index == num_segs)
CU_ASSERT(seg == ODP_PACKET_SEG_INVALID);
+
+ seg = odp_packet_first_seg(seg_pkt);
+ num_segs = odp_packet_num_segs(seg_pkt);
+
+ buf_len = 0;
+ data_len = 0;
+ seg_index = 0;
+
+ while (seg_index < num_segs && seg != ODP_PACKET_SEG_INVALID) {
+ uint32_t seg_data_len, seg_buf_len;
+ void *seg_buf_addr, *seg_data;
+
+ seg_buf_addr = odp_packet_seg_buf_addr(seg_pkt, seg);
+ seg_buf_len = odp_packet_seg_buf_len(seg_pkt, seg);
+ seg_data_len = odp_packet_seg_data_len(seg_pkt, seg);
+ seg_data = odp_packet_seg_data(seg_pkt, seg);
+
+ CU_ASSERT(seg_buf_len > 0);
+ CU_ASSERT(seg_data_len > 0);
+ CU_ASSERT(seg_buf_len >= seg_data_len);
+ CU_ASSERT(seg_data != NULL);
+ CU_ASSERT(seg_buf_addr != NULL);
+ CU_ASSERT(seg_data >= seg_buf_addr);
+ CU_ASSERT(odp_packet_seg_to_u64(seg) !=
+ odp_packet_seg_to_u64(ODP_PACKET_SEG_INVALID));
+
+ buf_len += seg_buf_len;
+ data_len += seg_data_len;
+
+ /** @todo: touch memory in a segment */
+ seg_index++;
+ seg = odp_packet_next_seg(seg_pkt, seg);
+ }
+
+ CU_ASSERT(seg_index == num_segs);
+ CU_ASSERT(buf_len == odp_packet_buf_len(seg_pkt));
+ CU_ASSERT(data_len == odp_packet_len(seg_pkt));
+
+ if (seg_index == num_segs)
+ CU_ASSERT(seg == ODP_PACKET_SEG_INVALID);
}
-static void packet_segment_last(void)
+static void packet_test_segment_last(void)
{
odp_packet_t pkt = test_packet;
odp_packet_seg_t seg;
@@ -449,7 +509,7 @@ do { \
CU_ASSERT(odp_packet_has_##flag(packet) != 0); \
} while (0)
-static void packet_in_flags(void)
+static void packet_test_in_flags(void)
{
odp_packet_t pkt = test_packet;
@@ -472,7 +532,7 @@ static void packet_in_flags(void)
TEST_INFLAG(pkt, icmp);
}
-static void packet_error_flags(void)
+static void packet_test_error_flags(void)
{
odp_packet_t pkt = test_packet;
int err;
@@ -494,7 +554,7 @@ struct packet_metadata {
uint64_t usr_u64;
};
-static void packet_add_rem_data(void)
+static void packet_test_add_rem_data(void)
{
odp_packet_t pkt, new_pkt;
uint32_t pkt_len, offset, add_len;
@@ -525,7 +585,7 @@ static void packet_add_rem_data(void)
/* Verify that user metadata has been preserved */
new_udat = odp_packet_user_area(new_pkt);
- CU_ASSERT(new_udat != NULL);
+ CU_ASSERT_PTR_NOT_NULL(new_udat);
CU_ASSERT(odp_packet_user_area_size(new_pkt) ==
sizeof(struct udata_struct));
CU_ASSERT(memcmp(new_udat, &test_packet_udata,
@@ -544,7 +604,7 @@ static void packet_add_rem_data(void)
/* Verify that user metadata has been preserved */
new_udat = odp_packet_user_area(new_pkt);
- CU_ASSERT(new_udat != NULL);
+ CU_ASSERT_PTR_NOT_NULL(new_udat);
CU_ASSERT(odp_packet_user_area_size(new_pkt) ==
sizeof(struct udata_struct));
CU_ASSERT(memcmp(new_udat, &test_packet_udata,
@@ -556,7 +616,6 @@ free_packet:
odp_packet_free(pkt);
}
-
#define COMPARE_INFLAG(p1, p2, flag) \
CU_ASSERT(odp_packet_has_##flag(p1) == odp_packet_has_##flag(p2))
@@ -594,8 +653,8 @@ static void _packet_compare_data(odp_packet_t pkt1, odp_packet_t pkt2)
void *pkt1map = odp_packet_offset(pkt1, offset, &seglen1, NULL);
void *pkt2map = odp_packet_offset(pkt2, offset, &seglen2, NULL);
- CU_ASSERT_FATAL(pkt1map != NULL);
- CU_ASSERT_FATAL(pkt2map != NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(pkt1map);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(pkt2map);
cmplen = seglen1 < seglen2 ? seglen1 : seglen2;
CU_ASSERT(!memcmp(pkt1map, pkt2map, cmplen));
@@ -604,7 +663,7 @@ static void _packet_compare_data(odp_packet_t pkt1, odp_packet_t pkt2)
}
}
-static void packet_copy(void)
+static void packet_test_copy(void)
{
odp_packet_t pkt = test_packet;
odp_packet_t pkt_copy;
@@ -623,7 +682,7 @@ static void packet_copy(void)
odp_packet_free(pkt_copy);
}
-static void packet_copydata(void)
+static void packet_test_copydata(void)
{
odp_packet_t pkt = test_packet;
uint32_t pkt_len = odp_packet_len(pkt);
@@ -634,7 +693,7 @@ static void packet_copydata(void)
CU_ASSERT_FATAL(pkt_len > 0);
data_buf = malloc(pkt_len);
- CU_ASSERT_FATAL(data_buf != NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(data_buf);
for (i = 0; i < pkt_len; i++)
data_buf[i] = (uint8_t)i;
@@ -654,7 +713,7 @@ static void packet_copydata(void)
free(data_buf);
}
-static void packet_offset(void)
+static void packet_test_offset(void)
{
odp_packet_t pkt = test_packet;
uint32_t seg_len, full_seg_len;
@@ -667,7 +726,7 @@ static void packet_offset(void)
CU_ASSERT(seg_len > 1);
CU_ASSERT(seg_len == odp_packet_seg_len(pkt));
CU_ASSERT(seg_len == odp_packet_seg_data_len(pkt, seg));
- CU_ASSERT(ptr != NULL);
+ CU_ASSERT_PTR_NOT_NULL(ptr);
CU_ASSERT(ptr == odp_packet_data(pkt));
CU_ASSERT(ptr == odp_packet_seg_data(pkt, seg));
@@ -677,7 +736,7 @@ static void packet_offset(void)
offset = 1;
ptr = odp_packet_offset(pkt, offset, &seg_len, NULL);
- CU_ASSERT(ptr != NULL);
+ CU_ASSERT_PTR_NOT_NULL(ptr);
CU_ASSERT(ptr == start_ptr + offset);
CU_ASSERT(seg_len == full_seg_len - offset);
@@ -685,48 +744,53 @@ static void packet_offset(void)
offset = full_seg_len - 1;
ptr = odp_packet_offset(pkt, offset, &seg_len, NULL);
- CU_ASSERT(ptr != NULL);
+ CU_ASSERT_PTR_NOT_NULL(ptr);
CU_ASSERT(ptr == start_ptr + offset);
CU_ASSERT(seg_len == full_seg_len - offset);
/* Query the last byte in a packet */
offset = odp_packet_len(pkt) - 1;
ptr = odp_packet_offset(pkt, offset, &seg_len, NULL);
- CU_ASSERT(ptr != NULL);
+ CU_ASSERT_PTR_NOT_NULL(ptr);
CU_ASSERT(seg_len == 1);
/* Pass NULL to [out] arguments */
ptr = odp_packet_offset(pkt, 0, NULL, NULL);
- CU_ASSERT(ptr != NULL);
+ CU_ASSERT_PTR_NOT_NULL(ptr);
}
-CU_TestInfo packet_tests[] = {
- _CU_TEST_INFO(packet_alloc_free),
- _CU_TEST_INFO(packet_alloc_segmented),
- _CU_TEST_INFO(packet_basic_metadata),
- _CU_TEST_INFO(packet_debug),
- _CU_TEST_INFO(packet_length),
- _CU_TEST_INFO(packet_headroom),
- _CU_TEST_INFO(packet_tailroom),
- _CU_TEST_INFO(packet_context),
- _CU_TEST_INFO(packet_event_conversion),
- _CU_TEST_INFO(packet_layer_offsets),
- _CU_TEST_INFO(packet_segments),
- _CU_TEST_INFO(packet_segment_last),
- _CU_TEST_INFO(packet_in_flags),
- _CU_TEST_INFO(packet_error_flags),
- _CU_TEST_INFO(packet_add_rem_data),
- _CU_TEST_INFO(packet_copy),
- _CU_TEST_INFO(packet_copydata),
- _CU_TEST_INFO(packet_offset),
+static CU_TestInfo packet_suite[] = {
+ _CU_TEST_INFO(packet_test_alloc_free),
+ _CU_TEST_INFO(packet_test_alloc_segmented),
+ _CU_TEST_INFO(packet_test_basic_metadata),
+ _CU_TEST_INFO(packet_test_debug),
+ _CU_TEST_INFO(packet_test_length),
+ _CU_TEST_INFO(packet_test_headroom),
+ _CU_TEST_INFO(packet_test_tailroom),
+ _CU_TEST_INFO(packet_test_context),
+ _CU_TEST_INFO(packet_test_event_conversion),
+ _CU_TEST_INFO(packet_test_layer_offsets),
+ _CU_TEST_INFO(packet_test_segments),
+ _CU_TEST_INFO(packet_test_segment_last),
+ _CU_TEST_INFO(packet_test_in_flags),
+ _CU_TEST_INFO(packet_test_error_flags),
+ _CU_TEST_INFO(packet_test_add_rem_data),
+ _CU_TEST_INFO(packet_test_copy),
+ _CU_TEST_INFO(packet_test_copydata),
+ _CU_TEST_INFO(packet_test_offset),
CU_TEST_INFO_NULL,
};
-CU_SuiteInfo odp_testsuites[] = {
+static CU_SuiteInfo packet_suites[] = {
{ .pName = "packet tests",
- .pTests = packet_tests,
- .pInitFunc = packet_testsuite_init,
- .pCleanupFunc = packet_testsuite_finalize,
+ .pTests = packet_suite,
+ .pInitFunc = packet_suite_init,
+ .pCleanupFunc = packet_suite_term,
},
CU_SUITE_INFO_NULL,
};
+
+int packet_main(void)
+{
+ return odp_cunit_run(packet_suites);
+}
diff --git a/test/validation/packet/packet.h b/test/validation/packet/packet.h
new file mode 100644
index 0000000..421bc25
--- /dev/null
+++ b/test/validation/packet/packet.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+int packet_main(void);
diff --git a/test/validation/packet/packet_main.c b/test/validation/packet/packet_main.c
new file mode 100644
index 0000000..90972fd
--- /dev/null
+++ b/test/validation/packet/packet_main.c
@@ -0,0 +1,12 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "packet.h"
+
+int main(void)
+{
+ return packet_main();
+}
diff --git a/test/validation/pktio/Makefile.am b/test/validation/pktio/Makefile.am
index 1d1a0d9..0ba9b0b 100644
--- a/test/validation/pktio/Makefile.am
+++ b/test/validation/pktio/Makefile.am
@@ -3,6 +3,6 @@ include ../Makefile.inc
noinst_LIBRARIES = libpktio.a
libpktio_a_SOURCES = pktio.c
-bin_PROGRAMS = pktio_main
+bin_PROGRAMS = pktio_main$(EXEEXT)
dist_pktio_main_SOURCES = pktio_main.c
pktio_main_LDADD = libpktio.a $(LIBCUNIT_COMMON) $(LIBODP)
diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index 8e5e27d..69847d4 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -154,8 +154,8 @@ static uint32_t pktio_init_packet(odp_packet_t pkt)
/* IP */
odp_packet_l3_offset_set(pkt, ODPH_ETHHDR_LEN);
ip = (odph_ipv4hdr_t *)(buf + ODPH_ETHHDR_LEN);
- ip->dst_addr = odp_cpu_to_be_32(0);
- ip->src_addr = odp_cpu_to_be_32(0);
+ ip->dst_addr = odp_cpu_to_be_32(0x0a000064);
+ ip->src_addr = odp_cpu_to_be_32(0x0a000001);
ip->ver_ihl = ODPH_IPV4 << 4 | ODPH_IPV4HDR_IHL_MIN;
ip->tot_len = odp_cpu_to_be_16(pkt_len - ODPH_ETHHDR_LEN);
ip->ttl = 128;
@@ -168,8 +168,8 @@ static uint32_t pktio_init_packet(odp_packet_t pkt)
/* UDP */
odp_packet_l4_offset_set(pkt, ODPH_ETHHDR_LEN + ODPH_IPV4HDR_LEN);
udp = (odph_udphdr_t *)(buf + ODPH_ETHHDR_LEN + ODPH_IPV4HDR_LEN);
- udp->src_port = odp_cpu_to_be_16(0);
- udp->dst_port = odp_cpu_to_be_16(0);
+ udp->src_port = odp_cpu_to_be_16(12049);
+ udp->dst_port = odp_cpu_to_be_16(12050);
udp->length = odp_cpu_to_be_16(pkt_len -
ODPH_ETHHDR_LEN - ODPH_IPV4HDR_LEN);
udp->chksum = 0;
diff --git a/test/validation/pool/.gitignore b/test/validation/pool/.gitignore
new file mode 100644
index 0000000..2c67c9f
--- /dev/null
+++ b/test/validation/pool/.gitignore
@@ -0,0 +1,2 @@
+libpool.a
+pool_main
diff --git a/test/validation/pool/Makefile.am b/test/validation/pool/Makefile.am
new file mode 100644
index 0000000..dbd7963
--- /dev/null
+++ b/test/validation/pool/Makefile.am
@@ -0,0 +1,8 @@
+include ../Makefile.inc
+
+noinst_LIBRARIES = libpool.a
+libpool_a_SOURCES = pool.c
+
+bin_PROGRAMS = pool_main$(EXEEXT)
+dist_pool_main_SOURCES = pool_main.c
+pool_main_LDADD = libpool.a $(LIBCUNIT_COMMON) $(LIBODP)
diff --git a/test/validation/odp_pool.c b/test/validation/pool/pool.c
index b670e2e..a888b68 100644
--- a/test/validation/odp_pool.c
+++ b/test/validation/pool/pool.c
@@ -6,6 +6,7 @@
#include <odp.h>
#include "odp_cunit_common.h"
+#include "pool.h"
static int pool_name_number = 1;
static const int default_buffer_size = 1500;
@@ -26,7 +27,7 @@ static void pool_create_destroy(odp_pool_param_t *params)
CU_ASSERT(odp_pool_destroy(pool) == 0);
}
-static void pool_create_destroy_buffer(void)
+static void pool_test_create_destroy_buffer(void)
{
odp_pool_param_t params = {
.buf = {
@@ -40,7 +41,7 @@ static void pool_create_destroy_buffer(void)
pool_create_destroy(&params);
}
-static void pool_create_destroy_packet(void)
+static void pool_test_create_destroy_packet(void)
{
odp_pool_param_t params = {
.pkt = {
@@ -54,7 +55,7 @@ static void pool_create_destroy_packet(void)
pool_create_destroy(&params);
}
-static void pool_create_destroy_timeout(void)
+static void pool_test_create_destroy_timeout(void)
{
odp_pool_param_t params = {
.tmo = {
@@ -66,7 +67,7 @@ static void pool_create_destroy_timeout(void)
pool_create_destroy(&params);
}
-static void pool_lookup_info_print(void)
+static void pool_test_lookup_info_print(void)
{
odp_pool_t pool;
const char pool_name[] = "pool_for_lookup_test";
@@ -100,17 +101,22 @@ static void pool_lookup_info_print(void)
#define _CU_TEST_INFO(test_func) {#test_func, test_func}
-CU_TestInfo pool_tests[] = {
- _CU_TEST_INFO(pool_create_destroy_buffer),
- _CU_TEST_INFO(pool_create_destroy_packet),
- _CU_TEST_INFO(pool_create_destroy_timeout),
- _CU_TEST_INFO(pool_lookup_info_print),
+static CU_TestInfo pool_suite[] = {
+ _CU_TEST_INFO(pool_test_create_destroy_buffer),
+ _CU_TEST_INFO(pool_test_create_destroy_packet),
+ _CU_TEST_INFO(pool_test_create_destroy_timeout),
+ _CU_TEST_INFO(pool_test_lookup_info_print),
CU_TEST_INFO_NULL,
};
-CU_SuiteInfo odp_testsuites[] = {
+static CU_SuiteInfo pool_suites[] = {
{ .pName = "Pool tests",
- .pTests = pool_tests,
+ .pTests = pool_suite,
},
CU_SUITE_INFO_NULL,
};
+
+int pool_main(void)
+{
+ return odp_cunit_run(pool_suites);
+}
diff --git a/test/validation/pool/pool.h b/test/validation/pool/pool.h
new file mode 100644
index 0000000..53cd4d1
--- /dev/null
+++ b/test/validation/pool/pool.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+int pool_main(void);
diff --git a/test/validation/pool/pool_main.c b/test/validation/pool/pool_main.c
new file mode 100644
index 0000000..5ef739e
--- /dev/null
+++ b/test/validation/pool/pool_main.c
@@ -0,0 +1,12 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "pool.h"
+
+int main(void)
+{
+ return pool_main();
+}
diff --git a/test/validation/queue/.gitignore b/test/validation/queue/.gitignore
new file mode 100644
index 0000000..c9e4029
--- /dev/null
+++ b/test/validation/queue/.gitignore
@@ -0,0 +1,2 @@
+libqueue.a
+queue_main
diff --git a/test/validation/queue/Makefile.am b/test/validation/queue/Makefile.am
new file mode 100644
index 0000000..3220f8c
--- /dev/null
+++ b/test/validation/queue/Makefile.am
@@ -0,0 +1,8 @@
+include ../Makefile.inc
+
+noinst_LIBRARIES = libqueue.a
+libqueue_a_SOURCES = queue.c
+
+bin_PROGRAMS = queue_main$(EXEEXT)
+dist_queue_main_SOURCES = queue_main.c
+queue_main_LDADD = libqueue.a $(LIBCUNIT_COMMON) $(LIBODP)
diff --git a/test/validation/odp_queue.c b/test/validation/queue/queue.c
index b35e127..ea8cc5c 100644
--- a/test/validation/odp_queue.c
+++ b/test/validation/queue/queue.c
@@ -6,15 +6,16 @@
#include <odp.h>
#include <odp_cunit_common.h>
+#include "queue.h"
#define MAX_BUFFER_QUEUE (8)
-#define MSG_POOL_SIZE (4*1024*1024)
+#define MSG_POOL_SIZE (4 * 1024 * 1024)
#define CONFIG_MAX_ITERATION (100)
static int queue_contest = 0xff;
static odp_pool_t pool;
-static int init_queue_suite(void)
+static int queue_suite_init(void)
{
odp_pool_param_t params;
@@ -32,12 +33,12 @@ static int init_queue_suite(void)
return 0;
}
-static int init_queue_finalize(void)
+static int queue_suite_term(void)
{
return odp_pool_destroy(pool);
}
-static void test_odp_queue_sunnyday(void)
+static void queue_test_sunnydays(void)
{
odp_queue_t queue_creat_id, queue_id;
odp_event_t enev[MAX_BUFFER_QUEUE];
@@ -104,16 +105,20 @@ static void test_odp_queue_sunnyday(void)
}
CU_ASSERT(odp_queue_destroy(queue_id) == 0);
- return;
}
-CU_TestInfo test_odp_queue[] = {
- {"queue sunnyday", test_odp_queue_sunnyday},
+static CU_TestInfo queue_suite[] = {
+ {"queue sunnyday", queue_test_sunnydays},
CU_TEST_INFO_NULL,
};
-CU_SuiteInfo odp_testsuites[] = {
- {"Queue", init_queue_suite, init_queue_finalize,
- NULL, NULL, test_odp_queue},
+static CU_SuiteInfo queue_suites[] = {
+ {"Queue", queue_suite_init, queue_suite_term,
+ NULL, NULL, queue_suite},
CU_SUITE_INFO_NULL,
};
+
+int queue_main(void)
+{
+ return odp_cunit_run(queue_suites);
+}
diff --git a/test/validation/queue/queue.h b/test/validation/queue/queue.h
new file mode 100644
index 0000000..3e9a9f1
--- /dev/null
+++ b/test/validation/queue/queue.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+int queue_main(void);
diff --git a/test/validation/queue/queue_main.c b/test/validation/queue/queue_main.c
new file mode 100644
index 0000000..326f131
--- /dev/null
+++ b/test/validation/queue/queue_main.c
@@ -0,0 +1,12 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "queue.h"
+
+int main(void)
+{
+ return queue_main();
+}
diff --git a/test/validation/random/.gitignore b/test/validation/random/.gitignore
new file mode 100644
index 0000000..5ae7ebf
--- /dev/null
+++ b/test/validation/random/.gitignore
@@ -0,0 +1,2 @@
+random_main
+librandom.a
diff --git a/test/validation/random/Makefile.am b/test/validation/random/Makefile.am
new file mode 100644
index 0000000..2f39547
--- /dev/null
+++ b/test/validation/random/Makefile.am
@@ -0,0 +1,8 @@
+include ../Makefile.inc
+
+noinst_LIBRARIES = librandom.a
+librandom_a_SOURCES = random.c
+
+bin_PROGRAMS = random_main$(EXEEXT)
+dist_random_main_SOURCES = random_main.c
+random_main_LDADD = librandom.a $(LIBCUNIT_COMMON) $(LIBODP)
diff --git a/test/validation/odp_random.c b/test/validation/random/random.c
index ebc9705..a42523f 100644
--- a/test/validation/odp_random.c
+++ b/test/validation/random/random.c
@@ -6,11 +6,12 @@
#include <odp.h>
#include <odp_cunit_common.h>
+#include "random.h"
/* Helper macro for CU_TestInfo initialization */
#define _CU_TEST_INFO(test_func) {#test_func, test_func}
-static void random_get_size(void)
+static void random_test_get_size(void)
{
int32_t ret;
uint8_t buf[32];
@@ -19,12 +20,17 @@ static void random_get_size(void)
CU_ASSERT(ret == sizeof(buf));
}
-CU_TestInfo test_odp_random[] = {
- _CU_TEST_INFO(random_get_size),
+static CU_TestInfo random_suite[] = {
+ _CU_TEST_INFO(random_test_get_size),
CU_TEST_INFO_NULL,
};
-CU_SuiteInfo odp_testsuites[] = {
- {"Random", NULL, NULL, NULL, NULL, test_odp_random},
+static CU_SuiteInfo random_suites[] = {
+ {"Random", NULL, NULL, NULL, NULL, random_suite},
CU_SUITE_INFO_NULL,
};
+
+int random_main(void)
+{
+ return odp_cunit_run(random_suites);
+}
diff --git a/test/validation/random/random.h b/test/validation/random/random.h
new file mode 100644
index 0000000..c40ee1f
--- /dev/null
+++ b/test/validation/random/random.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+int random_main(void);
diff --git a/test/validation/random/random_main.c b/test/validation/random/random_main.c
new file mode 100644
index 0000000..36b32f7
--- /dev/null
+++ b/test/validation/random/random_main.c
@@ -0,0 +1,12 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "random.h"
+
+int main(void)
+{
+ return random_main();
+}
diff --git a/test/validation/scheduler/.gitignore b/test/validation/scheduler/.gitignore
new file mode 100644
index 0000000..03a6f39
--- /dev/null
+++ b/test/validation/scheduler/.gitignore
@@ -0,0 +1,2 @@
+libscheduler.a
+scheduler_main
diff --git a/test/validation/scheduler/Makefile.am b/test/validation/scheduler/Makefile.am
new file mode 100644
index 0000000..8224a66
--- /dev/null
+++ b/test/validation/scheduler/Makefile.am
@@ -0,0 +1,8 @@
+include ../Makefile.inc
+
+noinst_LIBRARIES = libscheduler.a
+libscheduler_a_SOURCES = scheduler.c
+
+bin_PROGRAMS = scheduler_main$(EXEEXT)
+dist_scheduler_main_SOURCES = scheduler_main.c
+scheduler_main_LDADD = libscheduler.a $(LIBCUNIT_COMMON) $(LIBODP)
diff --git a/test/validation/odp_scheduler.c b/test/validation/scheduler/scheduler.c
index b668fbb..0440093 100644
--- a/test/validation/odp_scheduler.c
+++ b/test/validation/scheduler/scheduler.c
@@ -6,9 +6,10 @@
#include <odp.h>
#include "odp_cunit_common.h"
+#include "scheduler.h"
#define MAX_WORKERS_THREADS 32
-#define MSG_POOL_SIZE (4*1024*1024)
+#define MSG_POOL_SIZE (4 * 1024 * 1024)
#define QUEUES_PER_PRIO 16
#define BUF_SIZE 64
#define TEST_NUM_BUFS 100
@@ -77,7 +78,7 @@ static int exit_schedule_loop(void)
return ret;
}
-static void test_schedule_wait_time(void)
+static void scheduler_test_wait_time(void)
{
uint64_t wait_time;
@@ -90,7 +91,7 @@ static void test_schedule_wait_time(void)
CU_ASSERT(wait_time > 0);
}
-static void test_schedule_num_prio(void)
+static void scheduler_test_num_prio(void)
{
int prio;
@@ -100,7 +101,7 @@ static void test_schedule_num_prio(void)
CU_ASSERT(prio == odp_schedule_num_prio());
}
-static void test_schedule_queue_destroy(void)
+static void scheduler_test_queue_destroy(void)
{
odp_pool_t p;
odp_pool_param_t params;
@@ -312,7 +313,7 @@ static void schedule_common(odp_schedule_sync_t sync, int num_queues,
shm = odp_shm_lookup(GLOBALS_SHM_NAME);
CU_ASSERT_FATAL(shm != ODP_SHM_INVALID);
globals = odp_shm_addr(shm);
- CU_ASSERT_FATAL(globals != NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(globals);
args.globals = globals;
args.sync = sync;
@@ -339,12 +340,12 @@ static void parallel_execute(odp_schedule_sync_t sync, int num_queues,
shm = odp_shm_lookup(GLOBALS_SHM_NAME);
CU_ASSERT_FATAL(shm != ODP_SHM_INVALID);
globals = odp_shm_addr(shm);
- CU_ASSERT_FATAL(globals != NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(globals);
shm = odp_shm_lookup(SHM_THR_ARGS_NAME);
CU_ASSERT_FATAL(shm != ODP_SHM_INVALID);
args = odp_shm_addr(shm);
- CU_ASSERT_FATAL(args != NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(args);
args->globals = globals;
args->sync = sync;
@@ -369,25 +370,25 @@ static void parallel_execute(odp_schedule_sync_t sync, int num_queues,
}
/* 1 queue 1 thread ODP_SCHED_SYNC_NONE */
-static void test_schedule_1q_1t_n(void)
+static void scheduler_test_1q_1t_n(void)
{
schedule_common(ODP_SCHED_SYNC_NONE, ONE_Q, ONE_PRIO, SCHD_ONE);
}
/* 1 queue 1 thread ODP_SCHED_SYNC_ATOMIC */
-static void test_schedule_1q_1t_a(void)
+static void scheduler_test_1q_1t_a(void)
{
schedule_common(ODP_SCHED_SYNC_ATOMIC, ONE_Q, ONE_PRIO, SCHD_ONE);
}
/* 1 queue 1 thread ODP_SCHED_SYNC_ORDERED */
-static void test_schedule_1q_1t_o(void)
+static void scheduler_test_1q_1t_o(void)
{
schedule_common(ODP_SCHED_SYNC_ORDERED, ONE_Q, ONE_PRIO, SCHD_ONE);
}
/* Many queues 1 thread ODP_SCHED_SYNC_NONE */
-static void test_schedule_mq_1t_n(void)
+static void scheduler_test_mq_1t_n(void)
{
/* Only one priority involved in these tests, but use
the same number of queues the more general case uses */
@@ -395,89 +396,95 @@ static void test_schedule_mq_1t_n(void)
}
/* Many queues 1 thread ODP_SCHED_SYNC_ATOMIC */
-static void test_schedule_mq_1t_a(void)
+static void scheduler_test_mq_1t_a(void)
{
schedule_common(ODP_SCHED_SYNC_ATOMIC, MANY_QS, ONE_PRIO, SCHD_ONE);
}
/* Many queues 1 thread ODP_SCHED_SYNC_ORDERED */
-static void test_schedule_mq_1t_o(void)
+static void scheduler_test_mq_1t_o(void)
{
schedule_common(ODP_SCHED_SYNC_ORDERED, MANY_QS, ONE_PRIO, SCHD_ONE);
}
/* Many queues 1 thread check priority ODP_SCHED_SYNC_NONE */
-static void test_schedule_mq_1t_prio_n(void)
+static void scheduler_test_mq_1t_prio_n(void)
{
int prio = odp_schedule_num_prio();
+
schedule_common(ODP_SCHED_SYNC_NONE, MANY_QS, prio, SCHD_ONE);
}
/* Many queues 1 thread check priority ODP_SCHED_SYNC_ATOMIC */
-static void test_schedule_mq_1t_prio_a(void)
+static void scheduler_test_mq_1t_prio_a(void)
{
int prio = odp_schedule_num_prio();
+
schedule_common(ODP_SCHED_SYNC_ATOMIC, MANY_QS, prio, SCHD_ONE);
}
/* Many queues 1 thread check priority ODP_SCHED_SYNC_ORDERED */
-static void test_schedule_mq_1t_prio_o(void)
+static void scheduler_test_mq_1t_prio_o(void)
{
int prio = odp_schedule_num_prio();
+
schedule_common(ODP_SCHED_SYNC_ORDERED, MANY_QS, prio, SCHD_ONE);
}
/* Many queues many threads check priority ODP_SCHED_SYNC_NONE */
-static void test_schedule_mq_mt_prio_n(void)
+static void scheduler_test_mq_mt_prio_n(void)
{
int prio = odp_schedule_num_prio();
+
parallel_execute(ODP_SCHED_SYNC_NONE, MANY_QS, prio, SCHD_ONE,
DISABLE_EXCL_ATOMIC);
}
/* Many queues many threads check priority ODP_SCHED_SYNC_ATOMIC */
-static void test_schedule_mq_mt_prio_a(void)
+static void scheduler_test_mq_mt_prio_a(void)
{
int prio = odp_schedule_num_prio();
+
parallel_execute(ODP_SCHED_SYNC_ATOMIC, MANY_QS, prio, SCHD_ONE,
DISABLE_EXCL_ATOMIC);
}
/* Many queues many threads check priority ODP_SCHED_SYNC_ORDERED */
-static void test_schedule_mq_mt_prio_o(void)
+static void scheduler_test_mq_mt_prio_o(void)
{
int prio = odp_schedule_num_prio();
+
parallel_execute(ODP_SCHED_SYNC_ORDERED, MANY_QS, prio, SCHD_ONE,
DISABLE_EXCL_ATOMIC);
}
/* 1 queue many threads check exclusive access on ATOMIC queues */
-static void test_schedule_1q_mt_a_excl(void)
+static void scheduler_test_1q_mt_a_excl(void)
{
parallel_execute(ODP_SCHED_SYNC_ATOMIC, ONE_Q, ONE_PRIO, SCHD_ONE,
ENABLE_EXCL_ATOMIC);
}
/* 1 queue 1 thread ODP_SCHED_SYNC_NONE multi */
-static void test_schedule_multi_1q_1t_n(void)
+static void scheduler_test_multi_1q_1t_n(void)
{
schedule_common(ODP_SCHED_SYNC_NONE, ONE_Q, ONE_PRIO, SCHD_MULTI);
}
/* 1 queue 1 thread ODP_SCHED_SYNC_ATOMIC multi */
-static void test_schedule_multi_1q_1t_a(void)
+static void scheduler_test_multi_1q_1t_a(void)
{
schedule_common(ODP_SCHED_SYNC_ATOMIC, ONE_Q, ONE_PRIO, SCHD_MULTI);
}
/* 1 queue 1 thread ODP_SCHED_SYNC_ORDERED multi */
-static void test_schedule_multi_1q_1t_o(void)
+static void scheduler_test_multi_1q_1t_o(void)
{
schedule_common(ODP_SCHED_SYNC_ORDERED, ONE_Q, ONE_PRIO, SCHD_MULTI);
}
/* Many queues 1 thread ODP_SCHED_SYNC_NONE multi */
-static void test_schedule_multi_mq_1t_n(void)
+static void scheduler_test_multi_mq_1t_n(void)
{
/* Only one priority involved in these tests, but use
the same number of queues the more general case uses */
@@ -485,67 +492,73 @@ static void test_schedule_multi_mq_1t_n(void)
}
/* Many queues 1 thread ODP_SCHED_SYNC_ATOMIC multi */
-static void test_schedule_multi_mq_1t_a(void)
+static void scheduler_test_multi_mq_1t_a(void)
{
schedule_common(ODP_SCHED_SYNC_ATOMIC, MANY_QS, ONE_PRIO, SCHD_MULTI);
}
/* Many queues 1 thread ODP_SCHED_SYNC_ORDERED multi */
-static void test_schedule_multi_mq_1t_o(void)
+static void scheduler_test_multi_mq_1t_o(void)
{
schedule_common(ODP_SCHED_SYNC_ORDERED, MANY_QS, ONE_PRIO, SCHD_MULTI);
}
/* Many queues 1 thread check priority ODP_SCHED_SYNC_NONE multi */
-static void test_schedule_multi_mq_1t_prio_n(void)
+static void scheduler_test_multi_mq_1t_prio_n(void)
{
int prio = odp_schedule_num_prio();
+
schedule_common(ODP_SCHED_SYNC_NONE, MANY_QS, prio, SCHD_MULTI);
}
/* Many queues 1 thread check priority ODP_SCHED_SYNC_ATOMIC multi */
-static void test_schedule_multi_mq_1t_prio_a(void)
+static void scheduler_test_multi_mq_1t_prio_a(void)
{
int prio = odp_schedule_num_prio();
+
schedule_common(ODP_SCHED_SYNC_ATOMIC, MANY_QS, prio, SCHD_MULTI);
}
/* Many queues 1 thread check priority ODP_SCHED_SYNC_ORDERED multi */
-static void test_schedule_multi_mq_1t_prio_o(void)
+static void scheduler_test_multi_mq_1t_prio_o(void)
{
int prio = odp_schedule_num_prio();
+
schedule_common(ODP_SCHED_SYNC_ORDERED, MANY_QS, prio, SCHD_MULTI);
}
/* Many queues many threads check priority ODP_SCHED_SYNC_NONE multi */
-static void test_schedule_multi_mq_mt_prio_n(void)
+static void scheduler_test_multi_mq_mt_prio_n(void)
{
int prio = odp_schedule_num_prio();
+
parallel_execute(ODP_SCHED_SYNC_NONE, MANY_QS, prio, SCHD_MULTI, 0);
}
/* Many queues many threads check priority ODP_SCHED_SYNC_ATOMIC multi */
-static void test_schedule_multi_mq_mt_prio_a(void)
+static void scheduler_test_multi_mq_mt_prio_a(void)
{
int prio = odp_schedule_num_prio();
+
parallel_execute(ODP_SCHED_SYNC_ATOMIC, MANY_QS, prio, SCHD_MULTI, 0);
}
/* Many queues many threads check priority ODP_SCHED_SYNC_ORDERED multi */
-static void test_schedule_multi_mq_mt_prio_o(void)
+static void scheduler_test_multi_mq_mt_prio_o(void)
{
int prio = odp_schedule_num_prio();
+
parallel_execute(ODP_SCHED_SYNC_ORDERED, MANY_QS, prio, SCHD_MULTI, 0);
}
/* 1 queue many threads check exclusive access on ATOMIC queues multi */
-static void test_schedule_multi_1q_mt_a_excl(void)
+static void scheduler_test_multi_1q_mt_a_excl(void)
{
parallel_execute(ODP_SCHED_SYNC_ATOMIC, ONE_Q, ONE_PRIO, SCHD_MULTI,
ENABLE_EXCL_ATOMIC);
}
-static void test_schedule_pause_resume(void)
+static void scheduler_test_pause_resume(void)
{
odp_queue_t queue;
odp_buffer_t buf;
@@ -560,7 +573,6 @@ static void test_schedule_pause_resume(void)
pool = odp_pool_lookup(MSG_POOL_NAME);
CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
-
for (i = 0; i < NUM_BUFS_PAUSE; i++) {
buf = odp_buffer_alloc(pool);
CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID);
@@ -651,7 +663,7 @@ static int create_queues(void)
return 0;
}
-static int schd_suite_init(void)
+static int scheduler_suite_init(void)
{
odp_shm_t shm;
odp_pool_t pool;
@@ -661,7 +673,7 @@ static int schd_suite_init(void)
params.buf.size = BUF_SIZE;
params.buf.align = 0;
- params.buf.num = MSG_POOL_SIZE/BUF_SIZE;
+ params.buf.num = MSG_POOL_SIZE / BUF_SIZE;
params.type = ODP_POOL_BUFFER;
pool = odp_pool_create(MSG_POOL_NAME, &params);
@@ -676,7 +688,7 @@ static int schd_suite_init(void)
globals = odp_shm_addr(shm);
- if (globals == NULL) {
+ if (!globals) {
printf("Shared memory reserve failed (globals).\n");
return -1;
}
@@ -691,7 +703,7 @@ static int schd_suite_init(void)
ODP_CACHE_LINE_SIZE, 0);
args = odp_shm_addr(shm);
- if (args == NULL) {
+ if (!args) {
printf("Shared memory reserve failed (args).\n");
return -1;
}
@@ -748,7 +760,7 @@ static int destroy_queues(void)
return 0;
}
-static int schd_suite_term(void)
+static int scheduler_suite_term(void)
{
odp_pool_t pool;
@@ -764,42 +776,48 @@ static int schd_suite_term(void)
return 0;
}
-struct CU_TestInfo schd_tests[] = {
- {"schedule_wait_time", test_schedule_wait_time},
- {"schedule_num_prio", test_schedule_num_prio},
- {"schedule_queue_destroy", test_schedule_queue_destroy},
- {"schedule_1q_1t_n", test_schedule_1q_1t_n},
- {"schedule_1q_1t_a", test_schedule_1q_1t_a},
- {"schedule_1q_1t_o", test_schedule_1q_1t_o},
- {"schedule_mq_1t_n", test_schedule_mq_1t_n},
- {"schedule_mq_1t_a", test_schedule_mq_1t_a},
- {"schedule_mq_1t_o", test_schedule_mq_1t_o},
- {"schedule_mq_1t_prio_n", test_schedule_mq_1t_prio_n},
- {"schedule_mq_1t_prio_a", test_schedule_mq_1t_prio_a},
- {"schedule_mq_1t_prio_o", test_schedule_mq_1t_prio_o},
- {"schedule_mq_mt_prio_n", test_schedule_mq_mt_prio_n},
- {"schedule_mq_mt_prio_a", test_schedule_mq_mt_prio_a},
- {"schedule_mq_mt_prio_o", test_schedule_mq_mt_prio_o},
- {"schedule_1q_mt_a_excl", test_schedule_1q_mt_a_excl},
- {"schedule_multi_1q_1t_n", test_schedule_multi_1q_1t_n},
- {"schedule_multi_1q_1t_a", test_schedule_multi_1q_1t_a},
- {"schedule_multi_1q_1t_o", test_schedule_multi_1q_1t_o},
- {"schedule_multi_mq_1t_n", test_schedule_multi_mq_1t_n},
- {"schedule_multi_mq_1t_a", test_schedule_multi_mq_1t_a},
- {"schedule_multi_mq_1t_o", test_schedule_multi_mq_1t_o},
- {"schedule_multi_mq_1t_prio_n", test_schedule_multi_mq_1t_prio_n},
- {"schedule_multi_mq_1t_prio_a", test_schedule_multi_mq_1t_prio_a},
- {"schedule_multi_mq_1t_prio_o", test_schedule_multi_mq_1t_prio_o},
- {"schedule_multi_mq_mt_prio_n", test_schedule_multi_mq_mt_prio_n},
- {"schedule_multi_mq_mt_prio_a", test_schedule_multi_mq_mt_prio_a},
- {"schedule_multi_mq_mt_prio_o", test_schedule_multi_mq_mt_prio_o},
- {"schedule_multi_1q_mt_a_excl", test_schedule_multi_1q_mt_a_excl},
- {"schedule_pause_resume", test_schedule_pause_resume},
+static struct CU_TestInfo scheduler_suite[] = {
+ {"schedule_wait_time", scheduler_test_wait_time},
+ {"schedule_num_prio", scheduler_test_num_prio},
+ {"schedule_queue_destroy", scheduler_test_queue_destroy},
+ {"schedule_1q_1t_n", scheduler_test_1q_1t_n},
+ {"schedule_1q_1t_a", scheduler_test_1q_1t_a},
+ {"schedule_1q_1t_o", scheduler_test_1q_1t_o},
+ {"schedule_mq_1t_n", scheduler_test_mq_1t_n},
+ {"schedule_mq_1t_a", scheduler_test_mq_1t_a},
+ {"schedule_mq_1t_o", scheduler_test_mq_1t_o},
+ {"schedule_mq_1t_prio_n", scheduler_test_mq_1t_prio_n},
+ {"schedule_mq_1t_prio_a", scheduler_test_mq_1t_prio_a},
+ {"schedule_mq_1t_prio_o", scheduler_test_mq_1t_prio_o},
+ {"schedule_mq_mt_prio_n", scheduler_test_mq_mt_prio_n},
+ {"schedule_mq_mt_prio_a", scheduler_test_mq_mt_prio_a},
+ {"schedule_mq_mt_prio_o", scheduler_test_mq_mt_prio_o},
+ {"schedule_1q_mt_a_excl", scheduler_test_1q_mt_a_excl},
+ {"schedule_multi_1q_1t_n", scheduler_test_multi_1q_1t_n},
+ {"schedule_multi_1q_1t_a", scheduler_test_multi_1q_1t_a},
+ {"schedule_multi_1q_1t_o", scheduler_test_multi_1q_1t_o},
+ {"schedule_multi_mq_1t_n", scheduler_test_multi_mq_1t_n},
+ {"schedule_multi_mq_1t_a", scheduler_test_multi_mq_1t_a},
+ {"schedule_multi_mq_1t_o", scheduler_test_multi_mq_1t_o},
+ {"schedule_multi_mq_1t_prio_n", scheduler_test_multi_mq_1t_prio_n},
+ {"schedule_multi_mq_1t_prio_a", scheduler_test_multi_mq_1t_prio_a},
+ {"schedule_multi_mq_1t_prio_o", scheduler_test_multi_mq_1t_prio_o},
+ {"schedule_multi_mq_mt_prio_n", scheduler_test_multi_mq_mt_prio_n},
+ {"schedule_multi_mq_mt_prio_a", scheduler_test_multi_mq_mt_prio_a},
+ {"schedule_multi_mq_mt_prio_o", scheduler_test_multi_mq_mt_prio_o},
+ {"schedule_multi_1q_mt_a_excl", scheduler_test_multi_1q_mt_a_excl},
+ {"schedule_pause_resume", scheduler_test_pause_resume},
CU_TEST_INFO_NULL,
};
-CU_SuiteInfo odp_testsuites[] = {
+static CU_SuiteInfo scheduler_suites[] = {
{"Scheduler",
- schd_suite_init, schd_suite_term, NULL, NULL, schd_tests},
+ scheduler_suite_init, scheduler_suite_term, NULL, NULL, scheduler_suite
+ },
CU_SUITE_INFO_NULL,
};
+
+int scheduler_main(void)
+{
+ return odp_cunit_run(scheduler_suites);
+}
diff --git a/test/validation/scheduler/scheduler.h b/test/validation/scheduler/scheduler.h
new file mode 100644
index 0000000..f2d5795
--- /dev/null
+++ b/test/validation/scheduler/scheduler.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+int scheduler_main(void);
diff --git a/test/validation/scheduler/scheduler_main.c b/test/validation/scheduler/scheduler_main.c
new file mode 100644
index 0000000..1f6f32f
--- /dev/null
+++ b/test/validation/scheduler/scheduler_main.c
@@ -0,0 +1,12 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "scheduler.h"
+
+int main(void)
+{
+ return scheduler_main();
+}
diff --git a/test/validation/synchronizers/.gitignore b/test/validation/synchronizers/.gitignore
new file mode 100644
index 0000000..3e0ff4a
--- /dev/null
+++ b/test/validation/synchronizers/.gitignore
@@ -0,0 +1,2 @@
+synchronizers_main
+libsynchronizers.a
diff --git a/test/validation/synchronizers/Makefile.am b/test/validation/synchronizers/Makefile.am
new file mode 100644
index 0000000..ca412bb
--- /dev/null
+++ b/test/validation/synchronizers/Makefile.am
@@ -0,0 +1,8 @@
+include ../Makefile.inc
+
+noinst_LIBRARIES = libsynchronizers.a
+libsynchronizers_a_SOURCES = synchronizers.c
+
+bin_PROGRAMS = synchronizers_main$(EXEEXT)
+dist_synchronizers_main_SOURCES = synchronizers_main.c
+synchronizers_main_LDADD = libsynchronizers.a $(LIBCUNIT_COMMON) $(LIBODP)
diff --git a/test/validation/odp_synchronizers.c b/test/validation/synchronizers/synchronizers.c
index 8839dce..4f89366 100644
--- a/test/validation/odp_synchronizers.c
+++ b/test/validation/synchronizers/synchronizers.c
@@ -9,6 +9,8 @@
#include <CUnit/Basic.h>
#include <odp_cunit_common.h>
#include <unistd.h>
+#include "synchronizers.h"
+
#define VERBOSE 0
#define MAX_ITERATIONS 1000
#define BARRIER_ITERATIONS 64
@@ -123,7 +125,7 @@ static per_thread_mem_t *thread_init(void)
global_shm = odp_shm_lookup(GLOBAL_SHM_NAME);
global_mem = odp_shm_addr(global_shm);
- CU_ASSERT(global_mem != NULL);
+ CU_ASSERT_PTR_NOT_NULL(global_mem);
per_thread_mem->global_mem = global_mem;
@@ -181,8 +183,8 @@ static uint32_t barrier_test(per_thread_mem_t *per_thread_mem,
barrier_cnt2 = global_mem->barrier_cnt2;
if ((barrier_cnt1 != cnt) || (barrier_cnt2 != cnt)) {
- printf("thread_num=%"PRIu32" barrier_cnts of %"PRIu32
- " %"PRIu32" cnt=%"PRIu32"\n",
+ printf("thread_num=%" PRIu32 " barrier_cnts of %" PRIu32
+ " %" PRIu32 " cnt=%" PRIu32 "\n",
thread_num, barrier_cnt1, barrier_cnt2, cnt);
barrier_errs++;
}
@@ -231,10 +233,10 @@ static uint32_t barrier_test(per_thread_mem_t *per_thread_mem,
}
if ((global_mem->g_verbose) && (barrier_errs != 0))
- printf("\nThread %"PRIu32" (id=%d core=%d) had %"PRIu32
- " barrier_errs in %"PRIu32" iterations\n", thread_num,
- per_thread_mem->thread_id,
- per_thread_mem->thread_core, barrier_errs, iterations);
+ printf("\nThread %" PRIu32 " (id=%d core=%d) had %" PRIu32
+ " barrier_errs in %" PRIu32 " iterations\n", thread_num,
+ per_thread_mem->thread_id,
+ per_thread_mem->thread_core, barrier_errs, iterations);
return barrier_errs;
}
@@ -435,8 +437,9 @@ static void *no_lock_functional_test(void *arg UNUSED)
}
if (global_mem->g_verbose)
- printf("\nThread %"PRIu32" (id=%d core=%d) had %"PRIu32" sync_failures"
- " in %"PRIu32" iterations\n", thread_num,
+ printf("\nThread %" PRIu32 " (id=%d core=%d) had %" PRIu32
+ " sync_failures in %" PRIu32 " iterations\n",
+ thread_num,
per_thread_mem->thread_id,
per_thread_mem->thread_core,
sync_failures, iterations);
@@ -523,8 +526,10 @@ static void *spinlock_functional_test(void *arg UNUSED)
if ((global_mem->g_verbose) &&
((sync_failures != 0) || (is_locked_errs != 0)))
- printf("\nThread %"PRIu32" (id=%d core=%d) had %"PRIu32" sync_failures"
- " and %"PRIu32" is_locked_errs in %"PRIu32" iterations\n", thread_num,
+ printf("\nThread %" PRIu32 " (id=%d core=%d) had %" PRIu32
+ " sync_failures and %" PRIu32
+ " is_locked_errs in %" PRIu32
+ " iterations\n", thread_num,
per_thread_mem->thread_id, per_thread_mem->thread_core,
sync_failures, is_locked_errs, iterations);
@@ -608,8 +613,10 @@ static void *ticketlock_functional_test(void *arg UNUSED)
if ((global_mem->g_verbose) &&
((sync_failures != 0) || (is_locked_errs != 0)))
- printf("\nThread %"PRIu32" (id=%d core=%d) had %"PRIu32" sync_failures"
- " and %"PRIu32" is_locked_errs in %"PRIu32" iterations\n", thread_num,
+ printf("\nThread %" PRIu32 " (id=%d core=%d) had %" PRIu32
+ " sync_failures and %" PRIu32
+ " is_locked_errs in %" PRIu32 " iterations\n",
+ thread_num,
per_thread_mem->thread_id, per_thread_mem->thread_core,
sync_failures, is_locked_errs, iterations);
@@ -686,8 +693,8 @@ static void *rwlock_functional_test(void *arg UNUSED)
}
if ((global_mem->g_verbose) && (sync_failures != 0))
- printf("\nThread %"PRIu32" (id=%d core=%d) had %"PRIu32" sync_failures"
- " in %"PRIu32" iterations\n", thread_num,
+ printf("\nThread %" PRIu32 " (id=%d core=%d) had %" PRIu32
+ " sync_failures in %" PRIu32 " iterations\n", thread_num,
per_thread_mem->thread_id,
per_thread_mem->thread_core,
sync_failures, iterations);
@@ -876,7 +883,6 @@ static void test_atomic_add_sub_32(void)
test_atomic_sub_32();
}
-
static void test_atomic_add_sub_64(void)
{
test_atomic_add_64();
@@ -914,86 +920,87 @@ static void test_atomic_validate(void)
}
/* Barrier tests */
-static void test_no_barrier_functional(void)
+static void synchronizers_test_no_barrier_functional(void)
{
pthrd_arg arg;
- arg.numthrds = global_mem->g_num_threads;
+ arg.numthrds = global_mem->g_num_threads;
barrier_test_init();
odp_cunit_thread_create(no_barrier_functional_test, &arg);
odp_cunit_thread_exit(&arg);
}
-static void test_barrier_functional(void)
+static void synchronizers_test_barrier_functional(void)
{
pthrd_arg arg;
- arg.numthrds = global_mem->g_num_threads;
+ arg.numthrds = global_mem->g_num_threads;
barrier_test_init();
odp_cunit_thread_create(barrier_functional_test, &arg);
odp_cunit_thread_exit(&arg);
}
-static CU_TestInfo test_odp_barrier[] = {
- {"no_barrier_functional", test_no_barrier_functional},
- {"barrier_functional", test_barrier_functional},
+static CU_TestInfo synchronizers_suite_barrier[] = {
+ {"no_barrier_functional", synchronizers_test_no_barrier_functional},
+ {"barrier_functional", synchronizers_test_barrier_functional},
CU_TEST_INFO_NULL
};
/* Thread-unsafe tests */
-static void test_no_lock_functional(void)
+static void synchronizers_test_no_lock_functional(void)
{
pthrd_arg arg;
- arg.numthrds = global_mem->g_num_threads;
+ arg.numthrds = global_mem->g_num_threads;
odp_cunit_thread_create(no_lock_functional_test, &arg);
odp_cunit_thread_exit(&arg);
}
-static CU_TestInfo test_no_locking[] = {
- {"no_lock_functional", test_no_lock_functional},
+static CU_TestInfo synchronizers_suite_no_locking[] = {
+ {"no_lock_functional", synchronizers_test_no_lock_functional},
CU_TEST_INFO_NULL
};
/* Spin lock tests */
-static void test_spinlock_api(void)
+static void synchronizers_test_spinlock_api(void)
{
pthrd_arg arg;
- arg.numthrds = global_mem->g_num_threads;
+ arg.numthrds = global_mem->g_num_threads;
odp_cunit_thread_create(spinlock_api_tests, &arg);
odp_cunit_thread_exit(&arg);
}
-static void test_spinlock_functional(void)
+static void synchronizers_test_spinlock_functional(void)
{
pthrd_arg arg;
- arg.numthrds = global_mem->g_num_threads;
+ arg.numthrds = global_mem->g_num_threads;
odp_spinlock_init(&global_mem->global_spinlock);
odp_cunit_thread_create(spinlock_functional_test, &arg);
odp_cunit_thread_exit(&arg);
}
-static CU_TestInfo test_odp_spinlock[] = {
- {"spinlock_api", test_spinlock_api},
- {"spinlock_functional", test_spinlock_functional},
+static CU_TestInfo synchronizers_suite_spinlock[] = {
+ {"spinlock_api", synchronizers_test_spinlock_api},
+ {"spinlock_functional", synchronizers_test_spinlock_functional},
CU_TEST_INFO_NULL
};
/* Ticket lock tests */
-static void test_ticketlock_api(void)
+static void synchronizers_test_ticketlock_api(void)
{
pthrd_arg arg;
- arg.numthrds = global_mem->g_num_threads;
+ arg.numthrds = global_mem->g_num_threads;
odp_cunit_thread_create(ticketlock_api_tests, &arg);
odp_cunit_thread_exit(&arg);
}
-static void test_ticketlock_functional(void)
+static void synchronizers_test_ticketlock_functional(void)
{
pthrd_arg arg;
+
arg.numthrds = global_mem->g_num_threads;
odp_ticketlock_init(&global_mem->global_ticketlock);
@@ -1001,40 +1008,39 @@ static void test_ticketlock_functional(void)
odp_cunit_thread_exit(&arg);
}
-static CU_TestInfo test_odp_ticketlock[] = {
- {"ticketlock_api", test_ticketlock_api},
- {"ticketlock_functional", test_ticketlock_functional},
+static CU_TestInfo synchronizers_suite_ticketlock[] = {
+ {"ticketlock_api", synchronizers_test_ticketlock_api},
+ {"ticketlock_functional", synchronizers_test_ticketlock_functional},
CU_TEST_INFO_NULL
};
/* RW lock tests */
-static void test_rwlock_api(void)
+static void synchronizers_test_rwlock_api(void)
{
pthrd_arg arg;
- arg.numthrds = global_mem->g_num_threads;
+ arg.numthrds = global_mem->g_num_threads;
odp_cunit_thread_create(rwlock_api_tests, &arg);
odp_cunit_thread_exit(&arg);
}
-static void test_rwlock_functional(void)
+static void synchronizers_test_rwlock_functional(void)
{
pthrd_arg arg;
- arg.numthrds = global_mem->g_num_threads;
+ arg.numthrds = global_mem->g_num_threads;
odp_rwlock_init(&global_mem->global_rwlock);
odp_cunit_thread_create(rwlock_functional_test, &arg);
odp_cunit_thread_exit(&arg);
}
-static CU_TestInfo test_odp_rwlock[] = {
- {"rwlock_api", test_rwlock_api},
- {"rwlock_functional", test_rwlock_functional},
+static CU_TestInfo synchronizers_suite_rwlock[] = {
+ {"rwlock_api", synchronizers_test_rwlock_api},
+ {"rwlock_functional", synchronizers_test_rwlock_functional},
CU_TEST_INFO_NULL
};
-
-static int init_locks(void)
+static int synchronizers_suite_init(void)
{
uint32_t num_threads, idx;
@@ -1081,12 +1087,14 @@ int tests_global_init(void)
if (max_threads < global_mem->g_num_threads) {
printf("Requested num of threads is too large\n");
- printf("reducing from %"PRIu32" to %"PRIu32"\n", global_mem->g_num_threads,
+ printf("reducing from %" PRIu32 " to %" PRIu32 "\n",
+ global_mem->g_num_threads,
max_threads);
global_mem->g_num_threads = max_threads;
}
- printf("Num of threads used = %"PRIu32"\n", global_mem->g_num_threads);
+ printf("Num of threads used = %" PRIu32 "\n",
+ global_mem->g_num_threads);
return ret;
}
@@ -1147,8 +1155,8 @@ static void *test_atomic_fetch_add_sub_thread(void *arg UNUSED)
static void test_atomic_functional(void *func_ptr(void *))
{
pthrd_arg arg;
- arg.numthrds = global_mem->g_num_threads;
+ arg.numthrds = global_mem->g_num_threads;
test_atomic_init();
test_atomic_store();
odp_cunit_thread_create(func_ptr, &arg);
@@ -1156,40 +1164,51 @@ static void test_atomic_functional(void *func_ptr(void *))
test_atomic_validate();
}
-static void test_atomic_inc_dec(void)
+static void synchronizers_test_atomic_inc_dec(void)
{
test_atomic_functional(test_atomic_inc_dec_thread);
}
-static void test_atomic_add_sub(void)
+static void synchronizers_test_atomic_add_sub(void)
{
test_atomic_functional(test_atomic_add_sub_thread);
}
-static void test_atomic_fetch_inc_dec(void)
+static void synchronizers_test_atomic_fetch_inc_dec(void)
{
test_atomic_functional(test_atomic_fetch_inc_dec_thread);
}
-static void test_atomic_fetch_add_sub(void)
+static void synchronizers_test_atomic_fetch_add_sub(void)
{
test_atomic_functional(test_atomic_fetch_add_sub_thread);
}
-CU_TestInfo test_odp_atomic[] = {
- {"atomic_inc_dec", test_atomic_inc_dec},
- {"atomic_add_sub", test_atomic_add_sub},
- {"atomic_fetch_inc_dec", test_atomic_fetch_inc_dec},
- {"atomic_fetch_add_sub", test_atomic_fetch_add_sub},
+static CU_TestInfo synchronizers_suite_atomic[] = {
+ {"atomic_inc_dec", synchronizers_test_atomic_inc_dec},
+ {"atomic_add_sub", synchronizers_test_atomic_add_sub},
+ {"atomic_fetch_inc_dec", synchronizers_test_atomic_fetch_inc_dec},
+ {"atomic_fetch_add_sub", synchronizers_test_atomic_fetch_add_sub},
CU_TEST_INFO_NULL,
};
-CU_SuiteInfo odp_testsuites[] = {
- {"barrier", NULL, NULL, NULL, NULL, test_odp_barrier},
- {"nolocking", init_locks, NULL, NULL, NULL, test_no_locking},
- {"spinlock", init_locks, NULL, NULL, NULL, test_odp_spinlock},
- {"ticketlock", init_locks, NULL, NULL, NULL, test_odp_ticketlock},
- {"rwlock", init_locks, NULL, NULL, NULL, test_odp_rwlock},
- {"atomic", NULL, NULL, NULL, NULL, test_odp_atomic},
+static CU_SuiteInfo synchronizers_suites[] = {
+ {"barrier", NULL,
+ NULL, NULL, NULL, synchronizers_suite_barrier},
+ {"nolocking", synchronizers_suite_init,
+ NULL, NULL, NULL, synchronizers_suite_no_locking},
+ {"spinlock", synchronizers_suite_init,
+ NULL, NULL, NULL, synchronizers_suite_spinlock},
+ {"ticketlock", synchronizers_suite_init,
+ NULL, NULL, NULL, synchronizers_suite_ticketlock},
+ {"rwlock", synchronizers_suite_init,
+ NULL, NULL, NULL, synchronizers_suite_rwlock},
+ {"atomic", NULL, NULL, NULL, NULL,
+ synchronizers_suite_atomic},
CU_SUITE_INFO_NULL
};
+
+int synchronizers_main(void)
+{
+ return odp_cunit_run(synchronizers_suites);
+}
diff --git a/test/validation/synchronizers/synchronizers.h b/test/validation/synchronizers/synchronizers.h
new file mode 100644
index 0000000..8890c3d
--- /dev/null
+++ b/test/validation/synchronizers/synchronizers.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+int synchronizers_main(void);
diff --git a/test/validation/synchronizers/synchronizers_main.c b/test/validation/synchronizers/synchronizers_main.c
new file mode 100644
index 0000000..659d315
--- /dev/null
+++ b/test/validation/synchronizers/synchronizers_main.c
@@ -0,0 +1,12 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "synchronizers.h"
+
+int main(void)
+{
+ return synchronizers_main();
+}
diff --git a/test/validation/system/.gitignore b/test/validation/system/.gitignore
new file mode 100644
index 0000000..3646b59
--- /dev/null
+++ b/test/validation/system/.gitignore
@@ -0,0 +1,2 @@
+system_main
+libsystem.a
diff --git a/test/validation/system/Makefile.am b/test/validation/system/Makefile.am
new file mode 100644
index 0000000..f68fe77
--- /dev/null
+++ b/test/validation/system/Makefile.am
@@ -0,0 +1,8 @@
+include ../Makefile.inc
+
+noinst_LIBRARIES = libsystem.a
+libsystem_a_SOURCES = system.c
+
+bin_PROGRAMS = system_main$(EXEEXT)
+dist_system_main_SOURCES = system_main.c
+system_main_LDADD = libsystem.a $(LIBCUNIT_COMMON) $(LIBODP)
diff --git a/test/validation/odp_time.c b/test/validation/system/system.c
index 8db9894..5e2d050 100644
--- a/test/validation/odp_time.c
+++ b/test/validation/system/system.c
@@ -6,12 +6,13 @@
#include <odp.h>
#include "odp_cunit_common.h"
+#include "system.h"
#define TOLERANCE 1
#define BUSY_LOOP_CNT 100
/* check that a cycles difference gives a reasonable result */
-static void test_odp_cycles_diff(void)
+static void system_test_odp_cycles_diff(void)
{
/* volatile to stop optimization of busy loop */
volatile int count = 0;
@@ -31,9 +32,10 @@ static void test_odp_cycles_diff(void)
}
/* check that a negative cycles difference gives a reasonable result */
-static void test_odp_cycles_negative_diff(void)
+static void system_test_odp_cycles_negative_diff(void)
{
uint64_t diff, cycles1, cycles2;
+
cycles1 = 10;
cycles2 = 5;
diff = odp_time_diff_cycles(cycles1, cycles2);
@@ -41,10 +43,11 @@ static void test_odp_cycles_negative_diff(void)
}
/* check that related conversions come back to the same value */
-static void test_odp_time_conversion(void)
+static void system_test_odp_time_conversion(void)
{
uint64_t ns1, ns2, cycles;
uint64_t upper_limit, lower_limit;
+
ns1 = 100;
cycles = odp_time_ns_to_cycles(ns1);
CU_ASSERT(cycles > 0);
@@ -58,14 +61,19 @@ static void test_odp_time_conversion(void)
CU_ASSERT((ns2 <= upper_limit) && (ns2 >= lower_limit));
}
-CU_TestInfo test_odp_time[] = {
- {"cycles diff", test_odp_cycles_diff},
- {"negative diff", test_odp_cycles_negative_diff},
- {"conversion", test_odp_time_conversion},
+CU_TestInfo system_suite_time[] = {
+ {"cycles diff", system_test_odp_cycles_diff},
+ {"negative diff", system_test_odp_cycles_negative_diff},
+ {"conversion", system_test_odp_time_conversion},
CU_TEST_INFO_NULL
};
-CU_SuiteInfo odp_testsuites[] = {
- {"Time", NULL, NULL, NULL, NULL, test_odp_time},
+static CU_SuiteInfo system_suites[] = {
+ {"Time", NULL, NULL, NULL, NULL, system_suite_time},
CU_SUITE_INFO_NULL
};
+
+int system_main(void)
+{
+ return odp_cunit_run(system_suites);
+}
diff --git a/test/validation/system/system.h b/test/validation/system/system.h
new file mode 100644
index 0000000..59fd468
--- /dev/null
+++ b/test/validation/system/system.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+int system_main(void);
diff --git a/test/validation/system/system_main.c b/test/validation/system/system_main.c
new file mode 100644
index 0000000..460b635
--- /dev/null
+++ b/test/validation/system/system_main.c
@@ -0,0 +1,12 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "system.h"
+
+int main(void)
+{
+ return system_main();
+}
diff --git a/test/validation/thread/.gitignore b/test/validation/thread/.gitignore
new file mode 100644
index 0000000..3b80ec1
--- /dev/null
+++ b/test/validation/thread/.gitignore
@@ -0,0 +1,2 @@
+libthread.a
+thread_main
diff --git a/test/validation/thread/Makefile.am b/test/validation/thread/Makefile.am
new file mode 100644
index 0000000..218a810
--- /dev/null
+++ b/test/validation/thread/Makefile.am
@@ -0,0 +1,8 @@
+include ../Makefile.inc
+
+noinst_LIBRARIES = libthread.a
+libthread_a_SOURCES = thread.c
+
+bin_PROGRAMS = thread_main$(EXEEXT)
+dist_thread_main_SOURCES = thread_main.c
+thread_main_LDADD = libthread.a $(LIBCUNIT_COMMON) $(LIBODP)
diff --git a/test/validation/thread/thread.c b/test/validation/thread/thread.c
new file mode 100644
index 0000000..d0bd75e
--- /dev/null
+++ b/test/validation/thread/thread.c
@@ -0,0 +1,47 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp.h>
+#include <odp_cunit_common.h>
+#include "thread.h"
+
+/* Helper macro for CU_TestInfo initialization */
+#define _CU_TEST_INFO(test_func) {#test_func, test_func}
+
+static void thread_test_odp_cpu_id(void)
+{
+ (void)odp_cpu_id();
+ CU_PASS();
+}
+
+static void thread_test_odp_thread_id(void)
+{
+ (void)odp_thread_id();
+ CU_PASS();
+}
+
+static void thread_test_odp_thread_count(void)
+{
+ (void)odp_thread_count();
+ CU_PASS();
+}
+
+static CU_TestInfo thread_suite[] = {
+ _CU_TEST_INFO(thread_test_odp_cpu_id),
+ _CU_TEST_INFO(thread_test_odp_thread_id),
+ _CU_TEST_INFO(thread_test_odp_thread_count),
+ CU_TEST_INFO_NULL,
+};
+
+static CU_SuiteInfo thread_suites[] = {
+ {"thread", NULL, NULL, NULL, NULL, thread_suite},
+ CU_SUITE_INFO_NULL,
+};
+
+int thread_main(void)
+{
+ return odp_cunit_run(thread_suites);
+}
diff --git a/test/validation/thread/thread.h b/test/validation/thread/thread.h
new file mode 100644
index 0000000..94c288e
--- /dev/null
+++ b/test/validation/thread/thread.h
@@ -0,0 +1,7 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+int thread_main(void);
diff --git a/test/validation/thread/thread_main.c b/test/validation/thread/thread_main.c
new file mode 100644
index 0000000..1751b01
--- /dev/null
+++ b/test/validation/thread/thread_main.c
@@ -0,0 +1,12 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "thread.h"
+
+int main(void)
+{
+ return thread_main();
+}