aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/implementers-guide/implementers-guide.adoc108
-rw-r--r--example/classifier/odp_classifier.c23
-rw-r--r--include/odp/api/config.h5
-rw-r--r--platform/linux-generic/Makefile.am4
-rw-r--r--platform/linux-generic/include/odp_internal.h1
-rw-r--r--platform/linux-generic/include/odp_packet_internal.h61
-rw-r--r--platform/linux-generic/include/odp_packet_io_internal.h25
-rw-r--r--platform/linux-generic/include/odp_pool_internal.h13
-rw-r--r--platform/linux-generic/m4/configure.m41
-rw-r--r--platform/linux-generic/m4/odp_pcap.m415
-rw-r--r--platform/linux-generic/odp_classification.c4
-rw-r--r--platform/linux-generic/odp_init.c5
-rw-r--r--platform/linux-generic/odp_packet.c222
-rw-r--r--platform/linux-generic/odp_packet_flags.c24
-rw-r--r--platform/linux-generic/odp_packet_io.c20
-rw-r--r--platform/linux-generic/odp_pool.c28
-rw-r--r--platform/linux-generic/pktio/io_ops.c3
-rw-r--r--platform/linux-generic/pktio/loop.c5
-rw-r--r--platform/linux-generic/pktio/netmap.c7
-rw-r--r--platform/linux-generic/pktio/pcap.c381
-rw-r--r--platform/linux-generic/pktio/socket.c9
-rw-r--r--platform/linux-generic/pktio/socket_mmap.c10
-rw-r--r--platform/linux-generic/test/Makefile.am5
-rw-r--r--platform/linux-generic/test/pktio/Makefile.am4
-rw-r--r--platform/linux-generic/test/pktio/pktio_env8
-rwxr-xr-xplatform/linux-generic/test/pktio/pktio_run_pcap33
-rwxr-xr-xscripts/checkpatch.pl8
-rwxr-xr-xscripts/git_hash.sh4
-rw-r--r--test/performance/odp_l2fwd.c234
-rw-r--r--test/validation/README55
-rw-r--r--test/validation/buffer/buffer.c27
-rw-r--r--test/validation/buffer/buffer.h6
-rw-r--r--test/validation/classification/classification.c11
-rw-r--r--test/validation/classification/classification.h8
-rw-r--r--test/validation/classification/odp_classification_basic.c20
-rw-r--r--test/validation/classification/odp_classification_test_pmr.c14
-rw-r--r--test/validation/classification/odp_classification_tests.c16
-rw-r--r--test/validation/classification/odp_classification_testsuites.h9
-rw-r--r--test/validation/common/odp_cunit_common.c234
-rw-r--r--test/validation/common/odp_cunit_common.h50
-rw-r--r--test/validation/config/config.c24
-rw-r--r--test/validation/config/config.h6
-rw-r--r--test/validation/cpumask/cpumask.c53
-rw-r--r--test/validation/cpumask/cpumask.h6
-rw-r--r--test/validation/crypto/crypto.c22
-rw-r--r--test/validation/crypto/crypto.h6
-rw-r--r--test/validation/crypto/odp_crypto_test_inp.c14
-rw-r--r--test/validation/crypto/odp_crypto_test_inp.h4
-rw-r--r--test/validation/errno/errno.c19
-rw-r--r--test/validation/errno/errno.h6
-rw-r--r--test/validation/hash/hash.c20
-rw-r--r--test/validation/hash/hash.h6
-rwxr-xr-xtest/validation/hash/hash_mainbin0 -> 439772 bytes
-rw-r--r--test/validation/init/init.c66
-rw-r--r--test/validation/init/init.h14
-rw-r--r--test/validation/packet/packet.c53
-rw-r--r--test/validation/packet/packet.h6
-rw-r--r--test/validation/pktio/pktio.c75
-rw-r--r--test/validation/pktio/pktio.h6
-rw-r--r--test/validation/pool/pool.c23
-rw-r--r--test/validation/pool/pool.h6
-rw-r--r--test/validation/queue/queue.c20
-rw-r--r--test/validation/queue/queue.h6
-rw-r--r--test/validation/random/random.c19
-rw-r--r--test/validation/random/random.h6
-rw-r--r--test/validation/scheduler/scheduler.c79
-rw-r--r--test/validation/scheduler/scheduler.h6
-rw-r--r--test/validation/shmem/shmem.c19
-rw-r--r--test/validation/shmem/shmem.h6
-rw-r--r--test/validation/synchronizers/synchronizers.c88
-rw-r--r--test/validation/synchronizers/synchronizers.h16
-rw-r--r--test/validation/system/system.c39
-rw-r--r--test/validation/system/system.h6
-rw-r--r--test/validation/thread/thread.c55
-rw-r--r--test/validation/thread/thread.h6
-rw-r--r--test/validation/time/time.c23
-rw-r--r--test/validation/time/time.h6
-rw-r--r--test/validation/timer/timer.c25
-rw-r--r--test/validation/timer/timer.h6
79 files changed, 1793 insertions, 793 deletions
diff --git a/doc/implementers-guide/implementers-guide.adoc b/doc/implementers-guide/implementers-guide.adoc
index 32dbfea39..0033ba31c 100644
--- a/doc/implementers-guide/implementers-guide.adoc
+++ b/doc/implementers-guide/implementers-guide.adoc
@@ -1,4 +1,4 @@
-OpenDataPlane (ODP) Implementers-Guide
+OpenDataPlane (ODP) Implementers Guide
=======================================
:toc:
@@ -70,14 +70,14 @@ This grouping defines tests that are expected to be executable and succeed on an
They are written in plain C code, and may only use functions defined in the standard libC library (besides the ODP functions being tested, of course).
No other languages (like scripting) are allowed as their usage would make assumptions on the platform capability.
-This area is located at: '<ODP_ROOT>/test/validation/'
+This area is located at: 'test/validation/'
The ODP API itself is ordered by module, where each module groups the set of ODP API functions related to the same "topic".
Examples of modules includes "classification" (API functions dealing with ingres packets classification), time (functions dealing with time, excluding timers which have their own module), timer,...
The complete module list can be seen at: http://docs.opendataplane.org/linux-generic-doxygen-html/modules.html[ODP Modules] +
-Within the platform agnostic area, the tests are also grouped by modules, matching the ODP API modules: '<ODP_ROOT>/test/validation/' mainly contains a list of directories matching each module name (as defined by the doxygen "@defgroup" or "@ingroup" statement present in each API ".h" file).
+Within the platform agnostic area, the tests are also grouped by modules, matching the ODP API modules: 'test/validation/' mainly contains a list of directories matching each module name (as defined by the doxygen "@defgroup" or "@ingroup" statement present in each API ".h" file).
-Within each of these directories, a library (called "lib<module>.la") and its associated ".h" file (called "<module>.h") defines all the test functions for this module as well as few other functions to initialize, terminate, and group the tests.
+Within each of these directories, a library (called "libtest<module>.la") and its associated ".h" file (called "<module>.h") defines all the test functions for this module as well as few other functions to initialize, terminate, and group the tests.
An executable called "<module>_main*", is also built. It is permissible to generate more than one executable to cover the functionality in the test library for the module.
These executable(s) shall call all the tests for this module. +
See <<anchor-1, Module test and naming convention>> for more details.
@@ -87,38 +87,36 @@ The obvious illustration of this is for module "init" whose functions are requir
There is a "Makefile.am" located at the top of the platform agnostic area. Its role is limited to the construction of the different test libraries and the "<module>_main*" executables. No tests are run from this area when "make check" is performed.
-A convenience library '.../test/validation/libodptests.la' (and its associated .h file, '.../test/validation/odptest.h') regrouping all tests symbols of all modules may be built in the future. (The superlib)
-
-C_UNIT
+CUnit
^^^^^^
-Within a given test executable C_UNIT is used to run the different tests. The usage of C_UNIT implies the following structure:
+Within a given test executable CUnit is used to run the different tests. The usage of CUnit implies the following structure:
* Tests are simple C functions.
-* Tests are grouped in arrays called test suites. Each test suite can be associated with a suite initialization/termination function(s), called by C_UNIT before and after the whole suite is ran.
-* An array of test suites (and associated init/term functions) defines the test registry ran by the test executable.
+* Tests are grouped in arrays called test suites. Each test suite can be associated with a suite initialization/termination function(s), called by CUnit before and after the whole suite is run.
+* An array of test suites (and associated init/term functions) defines the test registry run by the test executable.
-Moreover, two extra functions can be used to initialize/terminate the test executable (these are not part of C_UNIT). +
-A test executable return success (0) if every tests of each suite succeed.
+Moreover, two extra functions can be used to initialize/terminate the test executable (these are not part of CUnit). +
+A test executable return success (0) if every test of each suite succeed.
-More details about http://cunit.sourceforge.net/doc/index.html[C_Unit users guide]
+More details about http://cunit.sourceforge.net/doc/index.html[CUnit users guide]
[[anchor-1]]
Module test and naming convention
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-* Tests, i.e. C functions which are used in CUNIT test suites are named:
+* Tests, i.e. C functions which are used in CUnit test suites are named:
*<Module>_test_+++*+++* +
where the suffix idendify the test.
-* Test arrays, i.e. arrays of CU_TestInfo, listing the test functions belonging to a suite, are called:
+* Test arrays, i.e. arrays of odp_testinfo_t, listing the test functions belonging to a suite, are called:
*<Module>_suite+++[_*]+++* +
where the possible suffix can be used if many suites are declared.
-* CUNIT suite init and termination functions are called:
+* CUnit suite init and termination functions are called:
*<Module>+++_suite[_*]_init()+++* and *<Module>+++_suite[_*]_term()+++* respectively. +
where the possible extra middle pattern can be used if many suites are declared.
-* Suite arrays, i.e. arrays of CU_SuiteInfo used in executables (C_UNIT registry) are called:
+* Suite arrays, i.e. arrays of odp_suiteinfo_t used in executables (CUnit registry) are called:
*<Module>+++_suites[_*]+++* +
where the possible suffix identifies the executable using it, if many.
@@ -130,18 +128,18 @@ Module test and naming convention
*<Module>_init*
*<Module>_term*
-All the above symbols are part of the generated lib<Module>.la libraries. The generated main executable(s) (named <module>_+++main[_*]+++, where the optional suffix is used to distinguish the executables belonging to the same module, if many) simply call(s) the related <Module>_main+++[_*]+++ from the library.
+All the above symbols are part of the generated libtest<Module>.la libraries. The generated main executable(s) (named <module>_+++main[_*]+++, where the optional suffix is used to distinguish the executables belonging to the same module, if many) simply call(s) the related <Module>_main+++[_*]+++ from the library.
Platform specific
~~~~~~~~~~~~~~~~~
-These tests are located under '<ODP_ROOT>/platform/<platform>/test'. There is one such area for each platform implementing ODP.
+These tests are located under 'platform/<platform>/test'. There is one such area for each platform implementing ODP.
This location will be referred as <PLATFORM_SPECIFIC> in the rest of this document.
The normal case
^^^^^^^^^^^^^^^
-If the considered platform needs nothing specific to be tested this directory will contain a single "Makefile.am".
-This "Makefile.am" then only lists the executables to be run on "make check" (in the automake TEST variable): when the platform has nothing specific to it, this just list the "<module>_main+++[_*]+++" executables, picked from the platform agnostic area.
-For the linux-generic platform, most tested modules fall into this category: currently, the '<ODP_ROOT>/platform/linux-generic/test/Makefile.am' looks as follows:
+If the considered platform needs no platform specific tests, this directory simply needs to contain a single Makefile.am listing each of the executables (named <module>_main) built from the platform agnostic area. The executables are listed in the automake TEST variable and will therefore be run on "make check".
+
+For the linux-generic platform, most tested modules fall into this category: currently, the 'platform/linux-generic/test/Makefile.am' looks as follows:
[source,am]
----
@@ -179,13 +177,11 @@ endif
With the exception for module pktio, all other modules testing just involves calling the platform agnostic <module>_main executables (in test/validation).
-When no platform specific testing is required, the '<PLATFORM_SPECIFIC>/Makefile.am' is used to list the tests executables to be run only, as these tests are actually built from the platform agnostic side by the 'test/validation/Makefile.am' (and subdirectories). '<PLATFORM_SPECIFIC>/Makefile.am' is involved in building only when platform specific tests exists, as discussed below.
-
Using other languages
^^^^^^^^^^^^^^^^^^^^^
-The pktio module, above, is actually tested using a bash script. This script is needed to set up the interfaces used by the tests. The pktio_run script actually eventually calls the platform agnostic 'test/validation/pktio/pktio_main' after setting up the interfaces needed by the tests.
-Notice that the path to the script is '<PLATFORM_SPECIFIC>/pktio/pktio_run', i.e. it is private to this platform. Any languages supported by the tested platform can be used there, as it will not impact other platforms.
-The platform "private" executables (such as this script), of course, must also return one of the return code expected by the automake test harness (0 for success, 77 for inconclusive, other values for errors).
+The pktio module, above, is actually tested using a bash script. This script is needed to set up the interfaces used by the tests. The pktio_run script eventually calls the platform agnostic 'test/validation/pktio/pktio_main' after setting up the interfaces needed by the tests.
+Notice that the path to the script, 'pktio/pktio_run', is pointing to a file within the <PLATFORM_SPECIFIC> tree so is private to this platform. Any languages supported by the tested platform can be used there, as it will not impact other platforms.
+The platform "private" executables (such as this script), of course, must also return one of the return code expected by the automake test harness (0 for success, 77 for skipped, other values for errors).
Defining test wrappers
^^^^^^^^^^^^^^^^^^^^^^
@@ -232,14 +228,56 @@ Defining platform specific tests
Sometimes, it may be necessary to call platform specific system calls to check some functionality: For instance, testing odp_cpumask_* could involve checking the underlying system CPU mask. On linux, such a test would require using the CPU_ISSET macro, which is linux specific. Such a test would be written in '<PLATFORM_SPECIFIC>/cpumask/...' The contents of this directory would be very similar to the contents of the platform agnostic side cpu_mask tests (including a Makefile.am...), but platform specific test would be written there.
'<PLATFORM_SPECIFIC>/Makefile.am' would then trigger the building of the platform specific tests (by listing their module name in SUBDIRS and therefore calling the appropriate Makefile.am) and then it would call both the platform agnostic executable(s) and the platform specific test executable.
-Skipping tests during development
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-During ODP development, it may be useful to skip some test. This can be achieved by creating a new test executable (still on the platform side), picking up the required tests from the platform agnostic lib<module>.la.
+Marking tests as inactive
+^^^^^^^^^^^^^^^^^^^^^^^^^
+The general policy is that a full run of the validation suite (a "make check") must pass at all times. However a particular platform may have one or more test cases that are known to be unimplemented either during development or permanently, so to avoid these test cases being reported as failures it's useful to be able to skip them. This can be achieved by creating a new test executable (still on the platform side), giving the platform specific initialisation code the opportunity to modify the registered tests in order to mark unwanted tests as inactive while leaving the remaining tests active. It's important that the unwanted tests are still registered with the test framework to allow the fact that they're not being tested to be recorded.
+
+The odp_cunit_update() function is intended for this purpose, it is used to modify the properties of previously registered tests, for example to mark them as inactive. Inactive tests are registered with the test framework but aren't executed and will be recorded as inactive in test reports.
+
+In 'test/validation/foo/foo.c', define all tests for the 'foo' module:
+
+[source,c]
+------------------
+odp_testinfo_t foo_tests[] = {
+ ODP_TEST_INFO(foo_test_a),
+ ODP_TEST_INFO(foo_test_b),
+ ODP_TEST_INFO_NULL
+};
+
+odp_suiteinfo_t foo_suites[] = {
+ {"Foo", foo_suite_init, foo_suite_term, foo_tests},
+ ODP_SUITE_INFO_NULL
+};
+------------------
+
+In 'platform/<platform>/test/foo/foo_main.c', register all the tests defined in the 'foo' module, then mark a single specific test case as inactive:
+
+[source,c]
+------------------
+static odp_testinfo_t foo_tests_updates[] = {
+ ODP_TEST_INFO_INACTIVE(foo_test_b),
+ ODP_TEST_INFO_NULL
+};
+
+static odp_suiteinfo_t foo_suites_updates[] = {
+ {"Foo", foo_suite_init, foo_suite_term, foo_tests_updates},
+ ODP_SUITE_INFO_NULL
+};
+
+int foo_main(void)
+{
+ int ret = odp_cunit_register(foo_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_update(foo_suites_updates);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
-The top Makefile would then call only the platform specific executable, hence skipping the tests which have been omitted.
+ return ret;
+}
+------------------
-TIP: You probably want to copy the platform-agnostic module main function and prune it from the undesired tests when writing your own platform specific main, for a given module.
+So 'foo_test_a' will be executed and 'foo_test_b' is inactive.
-Permanently skipping test
-^^^^^^^^^^^^^^^^^^^^^^^^^^
-If a platform wants to permanently skip a test (i.e. a part of the ODP API is and will not be supported on that platform), it is recommended to use the function odp_cunit_TBD() to removed the tests or suite from the list of tests. This gives a chance to the test environment to trace this removal.
+It's expected that early in the development cycle of a new implementation the inactive list will be quite long, but it should shrink over time as more parts of the API are implemented.
diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c
index 18cd3bb93..d2cc7e33a 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -346,19 +346,24 @@ static void configure_default_queue(odp_pktio_t pktio, appl_args_t *args)
odp_queue_param_t qparam;
odp_cos_t cos_default;
char cos_name[ODP_COS_NAME_LEN];
- char queue_name[ODP_QUEUE_NAME_LEN];
+ const char *queue_name = "DefaultQueue";
odp_queue_t queue_default;
global_statistics *stats = args->stats;
- sprintf(cos_name, "Default%s", args->if_name);
+
+ snprintf(cos_name, sizeof(cos_name), "Default%s", args->if_name);
cos_default = odp_cos_create(cos_name);
odp_queue_param_init(&qparam);
qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT;
qparam.sched.sync = ODP_SCHED_SYNC_NONE;
qparam.sched.group = ODP_SCHED_GROUP_ALL;
- sprintf(queue_name, "%s", "DefaultQueue");
queue_default = odp_queue_create(queue_name,
- ODP_QUEUE_TYPE_SCHED, &qparam);
+ ODP_QUEUE_TYPE_SCHED, &qparam);
+
+ if (0 > odp_cos_queue_set(cos_default, queue_default)) {
+ EXAMPLE_ERR("odp_cos_queue_set failed");
+ exit(EXIT_FAILURE);
+ }
if (0 > odp_cos_queue_set(cos_default, queue_default)) {
EXAMPLE_ERR("odp_cos_queue_set failed");
@@ -372,7 +377,9 @@ static void configure_default_queue(odp_pktio_t pktio, appl_args_t *args)
stats[args->policy_count].cos = cos_default;
/* add default queue to global stats */
stats[args->policy_count].queue = queue_default;
- strcpy(stats[args->policy_count].queue_name, "DefaultQueue");
+ snprintf(stats[args->policy_count].queue_name,
+ sizeof(stats[args->policy_count].queue_name),
+ "%s", queue_name);
odp_atomic_init_u64(&stats[args->policy_count].packet_count, 0);
args->policy_count++;
}
@@ -387,7 +394,8 @@ static void configure_cos_queue(odp_pktio_t pktio, appl_args_t *args)
for (i = 0; i < args->policy_count; i++) {
stats = &args->stats[i];
- sprintf(cos_name, "CoS%s", stats->queue_name);
+ snprintf(cos_name, sizeof(cos_name), "CoS%s",
+ stats->queue_name);
stats->cos = odp_cos_create(cos_name);
const odp_pmr_match_t match = {
@@ -403,7 +411,8 @@ static void configure_cos_queue(odp_pktio_t pktio, appl_args_t *args)
qparam.sched.sync = ODP_SCHED_SYNC_NONE;
qparam.sched.group = ODP_SCHED_GROUP_ALL;
- sprintf(queue_name, "%s%d", args->stats[i].queue_name, i);
+ snprintf(queue_name, sizeof(queue_name), "%s%d",
+ args->stats[i].queue_name, i);
stats->queue = odp_queue_create(queue_name,
ODP_QUEUE_TYPE_SCHED,
&qparam);
diff --git a/include/odp/api/config.h b/include/odp/api/config.h
index 9cdeb0e23..ed27ed5ad 100644
--- a/include/odp/api/config.h
+++ b/include/odp/api/config.h
@@ -43,6 +43,11 @@ int odp_config_queues(void);
int odp_config_max_ordered_locks_per_queue(void);
/**
+ * Maximum number of ordered locks per queue
+ */
+#define ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE 2
+
+/**
* Number of scheduling priorities
* @return The number of scheduling priorities supported by this platform
*/
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index 8da6c6bf5..9269a73c0 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -189,3 +189,7 @@ EXTRA_DIST = \
arch/linux/odp_cpu_cycles.c \
arch/mips64/odp_cpu_cycles.c \
arch/x86/odp_cpu_cycles.c
+
+if HAVE_PCAP
+__LIB__libodp_la_SOURCES += pktio/pcap.c
+endif
diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h
index 8a1a21976..14ba15900 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -54,6 +54,7 @@ int odp_shm_term_global(void);
int odp_shm_init_local(void);
int odp_pool_init_global(void);
+int odp_pool_init_local(void);
int odp_pool_term_global(void);
int odp_pool_term_local(void);
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index ba2cd7e1a..6f1521ca3 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -36,7 +36,8 @@ typedef union {
uint32_t all;
struct {
- uint32_t unparsed:1; /**< Set to inticate parse needed */
+ uint32_t parsed_l2:1; /**< L2 parsed */
+ uint32_t parsed_all:1;/**< Parsing complete */
uint32_t l2:1; /**< known L2 protocol present */
uint32_t l3:1; /**< known L3 protocol present */
@@ -155,43 +156,6 @@ static inline odp_packet_hdr_t *odp_packet_hdr(odp_packet_t pkt)
return (odp_packet_hdr_t *)odp_buf_to_hdr((odp_buffer_t)pkt);
}
-/**
- * Initialize packet buffer
- */
-static inline void packet_init(pool_entry_t *pool,
- odp_packet_hdr_t *pkt_hdr,
- size_t size)
-{
- /*
- * Reset parser metadata. Note that we clear via memset to make
- * this routine indepenent of any additional adds to packet metadata.
- */
- const size_t start_offset = ODP_FIELD_SIZEOF(odp_packet_hdr_t, buf_hdr);
- uint8_t *start;
- size_t len;
-
- start = (uint8_t *)pkt_hdr + start_offset;
- len = sizeof(odp_packet_hdr_t) - start_offset;
- memset(start, 0, len);
-
- /* Set metadata items that initialize to non-zero values */
- pkt_hdr->l2_offset = ODP_PACKET_OFFSET_INVALID;
- pkt_hdr->l3_offset = ODP_PACKET_OFFSET_INVALID;
- pkt_hdr->l4_offset = ODP_PACKET_OFFSET_INVALID;
- pkt_hdr->payload_offset = ODP_PACKET_OFFSET_INVALID;
-
- /*
- * Packet headroom is set from the pool's headroom
- * Packet tailroom is rounded up to fill the last
- * segment occupied by the allocated length.
- */
- pkt_hdr->frame_len = size;
- pkt_hdr->headroom = pool->s.headroom;
- pkt_hdr->tailroom =
- (pool->s.seg_size * pkt_hdr->buf_hdr.segcount) -
- (pool->s.headroom + size);
-}
-
static inline void copy_packet_parser_metadata(odp_packet_hdr_t *src_hdr,
odp_packet_hdr_t *dst_hdr)
{
@@ -253,12 +217,14 @@ static inline void packet_set_len(odp_packet_t pkt, uint32_t len)
odp_packet_hdr(pkt)->frame_len = len;
}
-#define ODP_PACKET_UNPARSED ~0
+static inline int packet_parse_l2_not_done(odp_packet_hdr_t *pkt_hdr)
+{
+ return !pkt_hdr->input_flags.parsed_l2;
+}
-static inline void _odp_packet_reset_parse(odp_packet_t pkt)
+static inline int packet_parse_not_complete(odp_packet_hdr_t *pkt_hdr)
{
- odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
- pkt_hdr->input_flags.all = ODP_PACKET_UNPARSED;
+ return !pkt_hdr->input_flags.parsed_all;
}
/* Forward declarations */
@@ -268,9 +234,16 @@ int _odp_packet_copy_to_packet(odp_packet_t srcpkt, uint32_t srcoffset,
void _odp_packet_copy_md_to_packet(odp_packet_t srcpkt, odp_packet_t dstpkt);
-odp_packet_t _odp_packet_alloc(odp_pool_t pool_hdl);
+odp_packet_t packet_alloc(odp_pool_t pool_hdl, uint32_t len, int parse);
+
+/* Fill in parser metadata for L2 */
+void packet_parse_l2(odp_packet_hdr_t *pkt_hdr);
+
+/* Perform full packet parse */
+int packet_parse_full(odp_packet_hdr_t *pkt_hdr);
-int _odp_packet_parse(odp_packet_hdr_t *pkt_hdr);
+/* Reset parser metadata for a new parse */
+void packet_parse_reset(odp_packet_t pkt);
/* Convert a packet handle to a buffer handle */
odp_buffer_t _odp_packet_to_buffer(odp_packet_t pkt);
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h
index 353b40d94..4745bd5c0 100644
--- a/platform/linux-generic/include/odp_packet_io_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_internal.h
@@ -30,6 +30,8 @@ extern "C" {
#include <odp/hints.h>
#include <net/if.h>
+#define PKTIO_NAME_LEN 256
+
/* Forward declaration */
struct pktio_if_ops;
@@ -38,6 +40,21 @@ typedef struct {
odp_bool_t promisc; /**< promiscuous mode state */
} pkt_loop_t;
+#ifdef HAVE_PCAP
+typedef struct {
+ char *fname_rx; /**< name of pcap file for rx */
+ char *fname_tx; /**< name of pcap file for tx */
+ void *rx; /**< rx pcap handle */
+ void *tx; /**< tx pcap handle */
+ void *tx_dump; /**< tx pcap dumper handle */
+ odp_pool_t pool; /**< rx pool */
+ unsigned char *buf; /**< per-pktio temp buffer */
+ int loops; /**< number of times to loop rx pcap */
+ int loop_cnt; /**< number of loops completed */
+ odp_bool_t promisc; /**< promiscuous mode state */
+} pkt_pcap_t;
+#endif
+
struct pktio_entry {
const struct pktio_if_ops *ops; /**< Implementation specific methods */
odp_ticketlock_t lock; /**< entry ticketlock */
@@ -52,13 +69,16 @@ struct pktio_entry {
pkt_sock_mmap_t pkt_sock_mmap; /**< using socket mmap
* API for IO */
pkt_netmap_t pkt_nm; /**< using netmap API for IO */
+#ifdef HAVE_PCAP
+ pkt_pcap_t pkt_pcap; /**< Using pcap for IO */
+#endif
};
enum {
STATE_START = 0,
STATE_STOP
} state;
classifier_t cls; /**< classifier linked with this pktio*/
- char name[IF_NAMESIZE]; /**< name of pktio provided to
+ char name[PKTIO_NAME_LEN]; /**< name of pktio provided to
pktio_open() */
odp_pktio_param_t param;
};
@@ -128,6 +148,9 @@ extern const pktio_if_ops_t netmap_pktio_ops;
extern const pktio_if_ops_t sock_mmsg_pktio_ops;
extern const pktio_if_ops_t sock_mmap_pktio_ops;
extern const pktio_if_ops_t loopback_pktio_ops;
+#ifdef HAVE_PCAP
+extern const pktio_if_ops_t pcap_pktio_ops;
+#endif
extern const pktio_if_ops_t * const pktio_if_ops[];
#ifdef __cplusplus
diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h
index 136db2c21..94bf1faee 100644
--- a/platform/linux-generic/include/odp_pool_internal.h
+++ b/platform/linux-generic/include/odp_pool_internal.h
@@ -53,9 +53,14 @@ typedef struct _odp_buffer_pool_init_t {
/* Local cache for buffer alloc/free acceleration */
typedef struct local_cache_t {
- odp_buffer_hdr_t *buf_freelist; /* The local cache */
- uint64_t bufallocs; /* Local buffer alloc count */
- uint64_t buffrees; /* Local buffer free count */
+ union {
+ struct {
+ odp_buffer_hdr_t *buf_freelist; /* The local cache */
+ uint64_t bufallocs; /* Local buffer alloc count */
+ uint64_t buffrees; /* Local buffer free count */
+ };
+ uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(uint64_t))];
+ };
} local_cache_t;
/* Use ticketlock instead of spinlock */
@@ -133,6 +138,8 @@ struct pool_entry_s {
uint32_t low_wm;
uint32_t headroom;
uint32_t tailroom;
+
+ local_cache_t local_cache[_ODP_INTERNAL_MAX_THREADS] ODP_ALIGNED_CACHE;
};
typedef union pool_entry_u {
diff --git a/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4
index f2d42f109..df6dc640b 100644
--- a/platform/linux-generic/m4/configure.m4
+++ b/platform/linux-generic/m4/configure.m4
@@ -19,6 +19,7 @@ AC_LINK_IFELSE(
m4_include([platform/linux-generic/m4/odp_pthread.m4])
m4_include([platform/linux-generic/m4/odp_openssl.m4])
m4_include([platform/linux-generic/m4/odp_netmap.m4])
+m4_include([platform/linux-generic/m4/odp_pcap.m4])
AC_CONFIG_FILES([platform/linux-generic/Makefile
platform/linux-generic/test/Makefile
diff --git a/platform/linux-generic/m4/odp_pcap.m4 b/platform/linux-generic/m4/odp_pcap.m4
new file mode 100644
index 000000000..734b79005
--- /dev/null
+++ b/platform/linux-generic/m4/odp_pcap.m4
@@ -0,0 +1,15 @@
+#########################################################################
+# Check for libpcap availability
+#########################################################################
+have_pcap=no
+AC_CHECK_HEADER(pcap/pcap.h,
+ [AC_CHECK_HEADER(pcap/bpf.h,
+ [AC_CHECK_LIB(pcap, pcap_open_offline, have_pcap=yes, [])],
+ [])],
+[])
+
+AM_CONDITIONAL([HAVE_PCAP], [test $have_pcap = yes])
+if test $have_pcap == yes; then
+ AM_CFLAGS="$AM_CFLAGS -DHAVE_PCAP"
+ LIBS="$LIBS -lpcap"
+fi
diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c
index d5ca13fd4..1b6d5931a 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -860,8 +860,8 @@ cos_t *pktio_select_cos(pktio_entry_t *entry, uint8_t *pkt_addr,
cls = &entry->s.cls;
/* Check for lazy parse needed */
- if (pkt_hdr->input_flags.unparsed)
- _odp_packet_parse(pkt_hdr);
+ if (packet_parse_not_complete(pkt_hdr))
+ packet_parse_full(pkt_hdr);
/* Return error cos for error packet */
if (pkt_hdr->error_flags.all)
diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
index 48d9b2036..5e19d86c6 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -138,6 +138,11 @@ int odp_init_local(odp_thread_type_t thr_type)
return -1;
}
+ if (odp_pool_init_local()) {
+ ODP_ERR("ODP pool local init failed.\n");
+ return -1;
+ }
+
if (odp_schedule_init_local()) {
ODP_ERR("ODP schedule local init failed.\n");
return -1;
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 209a6e6a0..1b496247f 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -25,8 +25,73 @@
*
*/
-odp_packet_t odp_packet_alloc(odp_pool_t pool_hdl, uint32_t len)
+static inline void packet_parse_disable(odp_packet_hdr_t *pkt_hdr)
+{
+ pkt_hdr->input_flags.parsed_l2 = 1;
+ pkt_hdr->input_flags.parsed_all = 1;
+}
+
+void packet_parse_reset(odp_packet_t pkt)
+{
+ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+ /* Reset parser metadata before new parse */
+ pkt_hdr->error_flags.all = 0;
+ pkt_hdr->input_flags.all = 0;
+ pkt_hdr->output_flags.all = 0;
+ pkt_hdr->l2_offset = 0;
+ pkt_hdr->l3_offset = ODP_PACKET_OFFSET_INVALID;
+ pkt_hdr->l4_offset = ODP_PACKET_OFFSET_INVALID;
+ pkt_hdr->payload_offset = ODP_PACKET_OFFSET_INVALID;
+ pkt_hdr->vlan_s_tag = 0;
+ pkt_hdr->vlan_c_tag = 0;
+ pkt_hdr->l3_protocol = 0;
+ pkt_hdr->l4_protocol = 0;
+}
+
+/**
+ * Initialize packet
+ */
+static void packet_init(pool_entry_t *pool, odp_packet_hdr_t *pkt_hdr,
+ size_t size, int parse)
{
+ /*
+ * Reset parser metadata. Note that we clear via memset to make
+ * this routine indepenent of any additional adds to packet metadata.
+ */
+ const size_t start_offset = ODP_FIELD_SIZEOF(odp_packet_hdr_t, buf_hdr);
+ uint8_t *start;
+ size_t len;
+
+ start = (uint8_t *)pkt_hdr + start_offset;
+ len = sizeof(odp_packet_hdr_t) - start_offset;
+ memset(start, 0, len);
+
+ /* Set metadata items that initialize to non-zero values */
+ pkt_hdr->l3_offset = ODP_PACKET_OFFSET_INVALID;
+ pkt_hdr->l4_offset = ODP_PACKET_OFFSET_INVALID;
+ pkt_hdr->payload_offset = ODP_PACKET_OFFSET_INVALID;
+
+ /* Disable lazy parsing on user allocated packets */
+ if (!parse)
+ packet_parse_disable(pkt_hdr);
+
+ /*
+ * Packet headroom is set from the pool's headroom
+ * Packet tailroom is rounded up to fill the last
+ * segment occupied by the allocated length.
+ */
+ pkt_hdr->frame_len = size;
+ pkt_hdr->headroom = pool->s.headroom;
+ pkt_hdr->tailroom =
+ (pool->s.seg_size * pkt_hdr->buf_hdr.segcount) -
+ (pool->s.headroom + size);
+}
+
+odp_packet_t packet_alloc(odp_pool_t pool_hdl, uint32_t len, int parse)
+{
+ odp_packet_t pkt;
+ odp_packet_hdr_t *pkt_hdr;
pool_entry_t *pool = odp_pool_to_entry(pool_hdl);
if (pool->s.params.type != ODP_POOL_PACKET)
@@ -34,17 +99,32 @@ odp_packet_t odp_packet_alloc(odp_pool_t pool_hdl, uint32_t len)
/* Handle special case for zero-length packets */
if (len == 0) {
- odp_packet_t pkt =
- (odp_packet_t)buffer_alloc(pool_hdl,
- pool->s.params.buf.size);
- if (pkt != ODP_PACKET_INVALID)
- pull_tail(odp_packet_hdr(pkt),
- pool->s.params.buf.size);
-
- return pkt;
+ len = pool->s.params.buf.size;
+
+ pkt = (odp_packet_t)buffer_alloc(pool_hdl, len);
+
+ if (pkt == ODP_PACKET_INVALID)
+ return ODP_PACKET_INVALID;
+
+ pull_tail(odp_packet_hdr(pkt), len);
+
+ } else {
+ pkt = (odp_packet_t)buffer_alloc(pool_hdl, len);
+
+ if (pkt == ODP_PACKET_INVALID)
+ return ODP_PACKET_INVALID;
}
- return (odp_packet_t)buffer_alloc(pool_hdl, len);
+ pkt_hdr = odp_packet_hdr(pkt);
+
+ packet_init(pool, pkt_hdr, len, parse);
+
+ return pkt;
+}
+
+odp_packet_t odp_packet_alloc(odp_pool_t pool_hdl, uint32_t len)
+{
+ return packet_alloc(pool_hdl, len, 0);
}
void odp_packet_free(odp_packet_t pkt)
@@ -61,7 +141,8 @@ int odp_packet_reset(odp_packet_t pkt, uint32_t len)
if (totsize > pkt_hdr->buf_hdr.size)
return -1;
- packet_init(pool, pkt_hdr, len);
+ packet_init(pool, pkt_hdr, len, 0);
+
return 0;
}
@@ -242,16 +323,12 @@ uint32_t odp_packet_user_area_size(odp_packet_t pkt)
void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len)
{
odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
- if (pkt_hdr->input_flags.unparsed)
- _odp_packet_parse(pkt_hdr);
return packet_map(pkt_hdr, pkt_hdr->l2_offset, len);
}
uint32_t odp_packet_l2_offset(odp_packet_t pkt)
{
odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
- if (pkt_hdr->input_flags.unparsed)
- _odp_packet_parse(pkt_hdr);
return pkt_hdr->l2_offset;
}
@@ -262,8 +339,6 @@ int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset)
if (offset >= pkt_hdr->frame_len)
return -1;
- if (pkt_hdr->input_flags.unparsed)
- _odp_packet_parse(pkt_hdr);
pkt_hdr->l2_offset = offset;
return 0;
}
@@ -271,16 +346,16 @@ int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset)
void *odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len)
{
odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
- if (pkt_hdr->input_flags.unparsed)
- _odp_packet_parse(pkt_hdr);
+ if (packet_parse_not_complete(pkt_hdr))
+ packet_parse_full(pkt_hdr);
return packet_map(pkt_hdr, pkt_hdr->l3_offset, len);
}
uint32_t odp_packet_l3_offset(odp_packet_t pkt)
{
odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
- if (pkt_hdr->input_flags.unparsed)
- _odp_packet_parse(pkt_hdr);
+ if (packet_parse_not_complete(pkt_hdr))
+ packet_parse_full(pkt_hdr);
return pkt_hdr->l3_offset;
}
@@ -291,8 +366,8 @@ int odp_packet_l3_offset_set(odp_packet_t pkt, uint32_t offset)
if (offset >= pkt_hdr->frame_len)
return -1;
- if (pkt_hdr->input_flags.unparsed)
- _odp_packet_parse(pkt_hdr);
+ if (packet_parse_not_complete(pkt_hdr))
+ packet_parse_full(pkt_hdr);
pkt_hdr->l3_offset = offset;
return 0;
}
@@ -300,16 +375,16 @@ int odp_packet_l3_offset_set(odp_packet_t pkt, uint32_t offset)
void *odp_packet_l4_ptr(odp_packet_t pkt, uint32_t *len)
{
odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
- if (pkt_hdr->input_flags.unparsed)
- _odp_packet_parse(pkt_hdr);
+ if (packet_parse_not_complete(pkt_hdr))
+ packet_parse_full(pkt_hdr);
return packet_map(pkt_hdr, pkt_hdr->l4_offset, len);
}
uint32_t odp_packet_l4_offset(odp_packet_t pkt)
{
odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
- if (pkt_hdr->input_flags.unparsed)
- _odp_packet_parse(pkt_hdr);
+ if (packet_parse_not_complete(pkt_hdr))
+ packet_parse_full(pkt_hdr);
return pkt_hdr->l4_offset;
}
@@ -320,8 +395,8 @@ int odp_packet_l4_offset_set(odp_packet_t pkt, uint32_t offset)
if (offset >= pkt_hdr->frame_len)
return -1;
- if (pkt_hdr->input_flags.unparsed)
- _odp_packet_parse(pkt_hdr);
+ if (packet_parse_not_complete(pkt_hdr))
+ packet_parse_full(pkt_hdr);
pkt_hdr->l4_offset = offset;
return 0;
}
@@ -442,22 +517,7 @@ odp_packet_t odp_packet_add_data(odp_packet_t pkt, uint32_t offset,
odp_packet_free(newpkt);
newpkt = ODP_PACKET_INVALID;
} else {
- odp_packet_hdr_t *new_hdr = odp_packet_hdr(newpkt);
- new_hdr->input = pkt_hdr->input;
- new_hdr->buf_hdr.buf_u64 = pkt_hdr->buf_hdr.buf_u64;
- if (new_hdr->buf_hdr.uarea_addr != NULL &&
- pkt_hdr->buf_hdr.uarea_addr != NULL)
- memcpy(new_hdr->buf_hdr.uarea_addr,
- pkt_hdr->buf_hdr.uarea_addr,
- new_hdr->buf_hdr.uarea_size <=
- pkt_hdr->buf_hdr.uarea_size ?
- new_hdr->buf_hdr.uarea_size :
- pkt_hdr->buf_hdr.uarea_size);
- odp_atomic_store_u32(
- &new_hdr->buf_hdr.ref_count,
- odp_atomic_load_u32(
- &pkt_hdr->buf_hdr.ref_count));
- copy_packet_parser_metadata(pkt_hdr, new_hdr);
+ _odp_packet_copy_md_to_packet(pkt, newpkt);
odp_packet_free(pkt);
}
}
@@ -486,22 +546,7 @@ odp_packet_t odp_packet_rem_data(odp_packet_t pkt, uint32_t offset,
odp_packet_free(newpkt);
newpkt = ODP_PACKET_INVALID;
} else {
- odp_packet_hdr_t *new_hdr = odp_packet_hdr(newpkt);
- new_hdr->input = pkt_hdr->input;
- new_hdr->buf_hdr.buf_u64 = pkt_hdr->buf_hdr.buf_u64;
- if (new_hdr->buf_hdr.uarea_addr != NULL &&
- pkt_hdr->buf_hdr.uarea_addr != NULL)
- memcpy(new_hdr->buf_hdr.uarea_addr,
- pkt_hdr->buf_hdr.uarea_addr,
- new_hdr->buf_hdr.uarea_size <=
- pkt_hdr->buf_hdr.uarea_size ?
- new_hdr->buf_hdr.uarea_size :
- pkt_hdr->buf_hdr.uarea_size);
- odp_atomic_store_u32(
- &new_hdr->buf_hdr.ref_count,
- odp_atomic_load_u32(
- &pkt_hdr->buf_hdr.ref_count));
- copy_packet_parser_metadata(pkt_hdr, new_hdr);
+ _odp_packet_copy_md_to_packet(pkt, newpkt);
odp_packet_free(pkt);
}
}
@@ -699,17 +744,6 @@ int _odp_packet_copy_to_packet(odp_packet_t srcpkt, uint32_t srcoffset,
return 0;
}
-odp_packet_t _odp_packet_alloc(odp_pool_t pool_hdl)
-{
- pool_entry_t *pool = odp_pool_to_entry(pool_hdl);
-
- if (pool->s.params.type != ODP_POOL_PACKET)
- return ODP_PACKET_INVALID;
-
- return (odp_packet_t)buffer_alloc(pool_hdl,
- pool->s.params.buf.size);
-}
-
/**
* Parser helper function for IPv4
*/
@@ -847,30 +881,11 @@ static inline void parse_udp(odp_packet_hdr_t *pkt_hdr,
}
/**
- * Simple packet parser
+ * Initialize L2 related parser flags and metadata
*/
-
-int _odp_packet_parse(odp_packet_hdr_t *pkt_hdr)
+void packet_parse_l2(odp_packet_hdr_t *pkt_hdr)
{
- odph_ethhdr_t *eth;
- odph_vlanhdr_t *vlan;
- uint16_t ethtype;
- uint8_t *parseptr;
- uint32_t offset, seglen;
- uint8_t ip_proto = 0;
-
- /* Reset parser metadata for new parse */
- pkt_hdr->error_flags.all = 0;
- pkt_hdr->input_flags.all = 0;
- pkt_hdr->output_flags.all = 0;
- pkt_hdr->l2_offset = 0;
- pkt_hdr->l3_offset = ODP_PACKET_OFFSET_INVALID;
- pkt_hdr->l4_offset = ODP_PACKET_OFFSET_INVALID;
- pkt_hdr->payload_offset = ODP_PACKET_OFFSET_INVALID;
- pkt_hdr->vlan_s_tag = 0;
- pkt_hdr->vlan_c_tag = 0;
- pkt_hdr->l3_protocol = 0;
- pkt_hdr->l4_protocol = 0;
+ /* Packet alloc or reset have already init other offsets and flags */
/* We only support Ethernet for now */
pkt_hdr->input_flags.eth = 1;
@@ -882,6 +897,24 @@ int _odp_packet_parse(odp_packet_hdr_t *pkt_hdr)
/* Assume valid L2 header, no CRC/FCS check in SW */
pkt_hdr->input_flags.l2 = 1;
+ pkt_hdr->input_flags.parsed_l2 = 1;
+}
+
+/**
+ * Simple packet parser
+ */
+int packet_parse_full(odp_packet_hdr_t *pkt_hdr)
+{
+ odph_ethhdr_t *eth;
+ odph_vlanhdr_t *vlan;
+ uint16_t ethtype;
+ uint8_t *parseptr;
+ uint32_t offset, seglen;
+ uint8_t ip_proto = 0;
+
+ if (packet_parse_l2_not_done(pkt_hdr))
+ packet_parse_l2(pkt_hdr);
+
eth = (odph_ethhdr_t *)packet_map(pkt_hdr, 0, &seglen);
offset = sizeof(odph_ethhdr_t);
parseptr = (uint8_t *)&eth->type;
@@ -993,5 +1026,6 @@ int _odp_packet_parse(odp_packet_hdr_t *pkt_hdr)
pkt_hdr->payload_offset = offset;
parse_exit:
+ pkt_hdr->input_flags.parsed_all = 1;
return pkt_hdr->error_flags.all != 0;
}
diff --git a/platform/linux-generic/odp_packet_flags.c b/platform/linux-generic/odp_packet_flags.c
index ea308f711..dbc313748 100644
--- a/platform/linux-generic/odp_packet_flags.c
+++ b/platform/linux-generic/odp_packet_flags.c
@@ -9,23 +9,23 @@
#define retflag(p, x) do { \
odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(p); \
- if (pkt_hdr->input_flags.unparsed) \
- _odp_packet_parse(pkt_hdr); \
+ if (packet_parse_not_complete(pkt_hdr)) \
+ packet_parse_full(pkt_hdr); \
return pkt_hdr->x; \
} while (0)
#define setflag(p, x, v) do { \
odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(p); \
- if (pkt_hdr->input_flags.unparsed) \
- _odp_packet_parse(pkt_hdr); \
+ if (packet_parse_not_complete(pkt_hdr)) \
+ packet_parse_full(pkt_hdr); \
pkt_hdr->x = v & 1; \
} while (0)
int odp_packet_has_error(odp_packet_t pkt)
{
odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
- if (pkt_hdr->input_flags.unparsed)
- _odp_packet_parse(pkt_hdr);
+ if (packet_parse_not_complete(pkt_hdr))
+ packet_parse_full(pkt_hdr);
return odp_packet_hdr(pkt)->error_flags.all != 0;
}
@@ -33,7 +33,9 @@ int odp_packet_has_error(odp_packet_t pkt)
int odp_packet_has_l2(odp_packet_t pkt)
{
- retflag(pkt, input_flags.l2);
+ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+ return pkt_hdr->input_flags.l2;
}
int odp_packet_has_l3(odp_packet_t pkt)
@@ -48,12 +50,16 @@ int odp_packet_has_l4(odp_packet_t pkt)
int odp_packet_has_eth(odp_packet_t pkt)
{
- retflag(pkt, input_flags.eth);
+ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+ return pkt_hdr->input_flags.eth;
}
int odp_packet_has_jumbo(odp_packet_t pkt)
{
- retflag(pkt, input_flags.jumbo);
+ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+ return pkt_hdr->input_flags.jumbo;
}
int odp_packet_has_vlan(odp_packet_t pkt)
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index b3ca4c818..1246bff71 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -91,6 +91,12 @@ int odp_pktio_term_global(void)
int id;
int pktio_if;
+ for (id = 1; id <= ODP_CONFIG_PKTIO_ENTRIES; ++id) {
+ pktio_entry = &pktio_tbl->entries[id - 1];
+ odp_pktio_close(pktio_entry->s.handle);
+ odp_queue_destroy(pktio_entry->s.outq_default);
+ }
+
for (pktio_if = 0; pktio_if_ops[pktio_if]; ++pktio_if) {
if (pktio_if_ops[pktio_if]->term)
if (pktio_if_ops[pktio_if]->term())
@@ -98,11 +104,6 @@ int odp_pktio_term_global(void)
pktio_if);
}
- for (id = 1; id <= ODP_CONFIG_PKTIO_ENTRIES; ++id) {
- pktio_entry = &pktio_tbl->entries[id - 1];
- odp_queue_destroy(pktio_entry->s.outq_default);
- }
-
ret = odp_shm_free(odp_shm_lookup("odp_pktio_entries"));
if (ret < 0)
ODP_ERR("shm free failed for odp_pktio_entries");
@@ -203,10 +204,10 @@ static odp_pktio_t setup_pktio_entry(const char *dev, odp_pool_t pool,
int ret = -1;
int pktio_if;
- if (strlen(dev) >= IF_NAMESIZE) {
+ if (strlen(dev) >= PKTIO_NAME_LEN - 1) {
/* ioctl names limitation */
ODP_ERR("pktio name %s is too big, limit is %d bytes\n",
- dev, IF_NAMESIZE);
+ dev, PKTIO_NAME_LEN - 1);
return ODP_PKTIO_INVALID;
}
@@ -238,7 +239,8 @@ static odp_pktio_t setup_pktio_entry(const char *dev, odp_pool_t pool,
id = ODP_PKTIO_INVALID;
ODP_ERR("Unable to init any I/O type.\n");
} else {
- snprintf(pktio_entry->s.name, IF_NAMESIZE, "%s", dev);
+ snprintf(pktio_entry->s.name,
+ sizeof(pktio_entry->s.name), "%s", dev);
pktio_entry->s.state = STATE_STOP;
unlock_entry_classifier(pktio_entry);
}
@@ -358,7 +360,7 @@ odp_pktio_t odp_pktio_lookup(const char *dev)
lock_entry(entry);
if (!is_free(entry) &&
- strncmp(entry->s.name, dev, IF_NAMESIZE) == 0)
+ strncmp(entry->s.name, dev, sizeof(entry->s.name)) == 0)
id = _odp_cast_scalar(odp_pktio_t, i);
unlock_entry(entry);
diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c
index 30d4b2b65..76a4aa585 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -57,8 +57,8 @@ static const char SHM_DEFAULT_NAME[] = "odp_buffer_pools";
/* Pool entry pointers (for inlining) */
void *pool_entry_ptr[ODP_CONFIG_POOLS];
-/* Local cache for buffer alloc/free acceleration */
-static __thread local_cache_t local_cache[ODP_CONFIG_POOLS];
+/* Cache thread id locally for local cache performance */
+static __thread int local_id;
int odp_pool_init_global(void)
{
@@ -107,6 +107,12 @@ int odp_pool_init_global(void)
return 0;
}
+int odp_pool_init_local(void)
+{
+ local_id = odp_thread_id();
+ return 0;
+}
+
int odp_pool_term_global(void)
{
int i;
@@ -442,6 +448,7 @@ int odp_pool_destroy(odp_pool_t pool_hdl)
{
uint32_t pool_id = pool_handle_to_index(pool_hdl);
pool_entry_t *pool = get_pool_entry(pool_id);
+ int i;
if (pool == NULL)
return -1;
@@ -455,8 +462,9 @@ int odp_pool_destroy(odp_pool_t pool_hdl)
return -1;
}
- /* Make sure local cache is empty */
- flush_cache(&local_cache[pool_id], &pool->s);
+ /* Make sure local caches are empty */
+ for (i = 0; i < _ODP_INTERNAL_MAX_THREADS; i++)
+ flush_cache(&pool->s.local_cache[i], &pool->s);
/* Call fails if pool has allocated buffers */
if (odp_atomic_load_u32(&pool->s.bufcount) < pool->s.buf_num) {
@@ -485,8 +493,9 @@ odp_buffer_t buffer_alloc(odp_pool_t pool_hdl, size_t size)
return ODP_BUFFER_INVALID;
/* Try to satisfy request from the local cache */
- buf = (odp_anybuf_t *)(void *)get_local_buf(&local_cache[pool_id],
- &pool->s, totsize);
+ buf = (odp_anybuf_t *)
+ (void *)get_local_buf(&pool->s.local_cache[local_id],
+ &pool->s, totsize);
/* If cache is empty, satisfy request from the pool */
if (odp_unlikely(buf == NULL)) {
@@ -517,9 +526,6 @@ odp_buffer_t buffer_alloc(odp_pool_t pool_hdl, size_t size)
/* By default, buffers are not associated with an ordered queue */
buf->buf.origin_qe = NULL;
- if (buf->buf.type == ODP_EVENT_PACKET)
- packet_init(pool, &buf->pkt, size);
-
return odp_hdr_to_buf(&buf->buf);
}
@@ -537,7 +543,7 @@ void odp_buffer_free(odp_buffer_t buf)
if (odp_unlikely(pool->s.low_wm_assert))
ret_buf(&pool->s, buf_hdr);
else
- ret_local_buf(&local_cache[pool->s.pool_id], buf_hdr);
+ ret_local_buf(&pool->s.local_cache[local_id], buf_hdr);
}
void _odp_flush_caches(void)
@@ -546,7 +552,7 @@ void _odp_flush_caches(void)
for (i = 0; i < ODP_CONFIG_POOLS; i++) {
pool_entry_t *pool = get_pool_entry(i);
- flush_cache(&local_cache[i], &pool->s);
+ flush_cache(&pool->s.local_cache[local_id], &pool->s);
}
}
diff --git a/platform/linux-generic/pktio/io_ops.c b/platform/linux-generic/pktio/io_ops.c
index bd4cc4839..3b344e6ad 100644
--- a/platform/linux-generic/pktio/io_ops.c
+++ b/platform/linux-generic/pktio/io_ops.c
@@ -15,6 +15,9 @@ const pktio_if_ops_t * const pktio_if_ops[] = {
#ifdef ODP_NETMAP
&netmap_pktio_ops,
#endif
+#ifdef HAVE_PCAP
+ &pcap_pktio_ops,
+#endif
&sock_mmap_pktio_ops,
&sock_mmsg_pktio_ops,
NULL
diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c
index 22f04758f..0d8dadd0f 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -55,13 +55,16 @@ static int loopback_recv(pktio_entry_t *pktio_entry, odp_packet_t pkts[],
int nbr, i;
odp_buffer_hdr_t *hdr_tbl[QUEUE_MULTI_MAX];
queue_entry_t *qentry;
+ odp_packet_hdr_t *pkt_hdr;
qentry = queue_to_qentry(pktio_entry->s.pkt_loop.loopq);
nbr = queue_deq_multi(qentry, hdr_tbl, len);
for (i = 0; i < nbr; ++i) {
pkts[i] = _odp_packet_from_buffer(odp_hdr_to_buf(hdr_tbl[i]));
- _odp_packet_reset_parse(pkts[i]);
+ pkt_hdr = odp_packet_hdr(pkts[i]);
+ packet_parse_reset(pkts[i]);
+ packet_parse_l2(pkt_hdr);
}
return nbr;
diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c
index ab4667e9c..ecda9c58a 100644
--- a/platform/linux-generic/pktio/netmap.c
+++ b/platform/linux-generic/pktio/netmap.c
@@ -168,6 +168,7 @@ static void netmap_recv_cb(u_char *arg, const struct nm_pkthdr *hdr,
struct dispatch_args *args = (struct dispatch_args *)arg;
pkt_netmap_t *pkt_nm = &args->pktio_entry->s.pkt_nm;
odp_packet_t pkt;
+ odp_packet_hdr_t *pkt_hdr;
size_t frame_len = (size_t)hdr->len;
if (odp_unlikely(frame_len > pkt_nm->max_frame_len)) {
@@ -181,10 +182,12 @@ static void netmap_recv_cb(u_char *arg, const struct nm_pkthdr *hdr,
return;
}
- pkt = odp_packet_alloc(pkt_nm->pool, frame_len);
+ pkt = packet_alloc(pkt_nm->pool, frame_len, 1);
if (pkt == ODP_PACKET_INVALID)
return;
+ pkt_hdr = odp_packet_hdr(pkt);
+
/* For now copy the data in the mbuf,
worry about zero-copy later */
if (odp_packet_copydata_in(pkt, 0, frame_len, buf) != 0) {
@@ -192,7 +195,7 @@ static void netmap_recv_cb(u_char *arg, const struct nm_pkthdr *hdr,
return;
}
- _odp_packet_reset_parse(pkt);
+ packet_parse_l2(pkt_hdr);
args->pkt_table[args->nb_rx++] = pkt;
}
diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c
new file mode 100644
index 000000000..0817bf595
--- /dev/null
+++ b/platform/linux-generic/pktio/pcap.c
@@ -0,0 +1,381 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * PCAP pktio type
+ *
+ * This file provides a pktio interface that allows for reading from
+ * and writing to pcap capture files. It is intended to be used as
+ * simple way of injecting test packets into an application for the
+ * purpose of functional testing.
+ *
+ * To use this interface the name passed to odp_pktio_open() must begin
+ * with "pcap:" and be in the format;
+ *
+ * pcap:in=test.pcap:out=test_out.pcap:loops=10
+ *
+ * in the name of the input pcap file. If no input file is given
+ * attempts to receive from the pktio will just return no
+ * packets. If an input file is specified it must exist and be
+ * a readable pcap file with a link type of DLT_EN10MB.
+ * out the name of the output pcap file. If no output file is
+ * given any packets transmitted over the interface will just
+ * be freed. If an output file is specified and the file
+ * doesn't exist it will be created, if it does exist it will
+ * be overwritten.
+ * loops the number of times to iterate through the input file, set
+ * to 0 to loop indefinitely. The default value is 1.
+ *
+ * The total length of the string is limited by PKTIO_NAME_LEN.
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <odp.h>
+#include <odp_packet_internal.h>
+#include <odp_packet_io_internal.h>
+
+#include <odp/helper/eth.h>
+
+#include <errno.h>
+#include <pcap/pcap.h>
+#include <pcap/bpf.h>
+
+#define PKTIO_PCAP_MTU (64 * 1024)
+static const char pcap_mac[] = {0x02, 0xe9, 0x34, 0x80, 0x73, 0x04};
+
+static int _pcapif_parse_devname(pkt_pcap_t *pcap, const char *devname)
+{
+ char *tok;
+ char in[PKTIO_NAME_LEN];
+
+ if (strncmp(devname, "pcap:", 5) != 0)
+ return -1;
+
+ snprintf(in, sizeof(in), "%s", devname);
+
+ for (tok = strtok(in + 5, ":"); tok; tok = strtok(NULL, ":")) {
+ if (strncmp(tok, "in=", 3) == 0 && !pcap->fname_rx) {
+ tok += 3;
+ pcap->fname_rx = strdup(tok);
+ } else if (strncmp(tok, "out=", 4) == 0 && !pcap->fname_tx) {
+ tok += 4;
+ pcap->fname_tx = strdup(tok);
+ } else if (strncmp(tok, "loops=", 6) == 0) {
+ pcap->loops = atoi(tok + 6);
+ if (pcap->loops < 0) {
+ ODP_ERR("invalid loop count\n");
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+static int _pcapif_init_rx(pkt_pcap_t *pcap)
+{
+ char errbuf[PCAP_ERRBUF_SIZE];
+ int linktype;
+
+ pcap->rx = pcap_open_offline(pcap->fname_rx, errbuf);
+ if (!pcap->rx) {
+ ODP_ERR("failed to open pcap file %s (%s)\n",
+ pcap->fname_rx, errbuf);
+ return -1;
+ }
+
+ linktype = pcap_datalink(pcap->rx);
+ if (linktype != DLT_EN10MB) {
+ ODP_ERR("unsupported datalink type: %d\n", linktype);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int _pcapif_init_tx(pkt_pcap_t *pcap)
+{
+ pcap_t *tx = pcap->rx;
+
+ if (!tx) {
+ /* if there is no rx pcap_t already open for rx, a dummy
+ * one needs to be opened for writing the dump */
+ tx = pcap_open_dead(DLT_EN10MB, PKTIO_PCAP_MTU);
+ if (!tx) {
+ ODP_ERR("failed to open TX dump\n");
+ return -1;
+ }
+
+ pcap->tx = tx;
+ }
+
+ pcap->buf = malloc(PKTIO_PCAP_MTU);
+ if (!pcap->buf) {
+ ODP_ERR("failed to malloc temp buffer\n");
+ return -1;
+ }
+
+ pcap->tx_dump = pcap_dump_open(tx, pcap->fname_tx);
+ if (!pcap->tx_dump) {
+ ODP_ERR("failed to open dump file %s (%s)\n",
+ pcap->fname_tx, pcap_geterr(tx));
+ return -1;
+ }
+
+ return pcap_dump_flush(pcap->tx_dump);
+}
+
+static int pcapif_init(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry,
+ const char *devname, odp_pool_t pool)
+{
+ pkt_pcap_t *pcap = &pktio_entry->s.pkt_pcap;
+ int ret;
+
+ memset(pcap, 0, sizeof(pkt_pcap_t));
+ pcap->loop_cnt = 1;
+ pcap->loops = 1;
+ pcap->pool = pool;
+ pcap->promisc = 1;
+
+ ret = _pcapif_parse_devname(pcap, devname);
+
+ if (ret == 0 && pcap->fname_rx)
+ ret = _pcapif_init_rx(pcap);
+
+ if (ret == 0 && pcap->fname_tx)
+ ret = _pcapif_init_tx(pcap);
+
+ if (ret == 0 && (!pcap->rx && !pcap->tx_dump))
+ ret = -1;
+
+ return ret;
+}
+
+static int pcapif_close(pktio_entry_t *pktio_entry)
+{
+ pkt_pcap_t *pcap = &pktio_entry->s.pkt_pcap;
+
+ if (pcap->tx_dump)
+ pcap_dump_close(pcap->tx_dump);
+
+ if (pcap->tx)
+ pcap_close(pcap->tx);
+
+ if (pcap->rx)
+ pcap_close(pcap->rx);
+
+ free(pcap->buf);
+ free(pcap->fname_rx);
+ free(pcap->fname_tx);
+
+ return 0;
+}
+
+static int _pcapif_reopen(pkt_pcap_t *pcap)
+{
+ char errbuf[PCAP_ERRBUF_SIZE];
+
+ if (pcap->loops != 0 && ++pcap->loop_cnt >= pcap->loops)
+ return 1;
+
+ if (pcap->rx)
+ pcap_close(pcap->rx);
+
+ pcap->rx = pcap_open_offline(pcap->fname_rx, errbuf);
+ if (!pcap->rx) {
+ ODP_ERR("failed to reopen pcap file %s (%s)\n",
+ pcap->fname_rx, errbuf);
+ return 1;
+ }
+
+ return 0;
+}
+
+static int pcapif_recv_pkt(pktio_entry_t *pktio_entry, odp_packet_t pkts[],
+ unsigned len)
+{
+ unsigned i;
+ struct pcap_pkthdr *hdr;
+ const u_char *data;
+ odp_packet_t pkt;
+ odp_packet_hdr_t *pkt_hdr;
+ uint32_t pkt_len;
+ pkt_pcap_t *pcap = &pktio_entry->s.pkt_pcap;
+
+ ODP_ASSERT(pktio_entry->s.state == STATE_START);
+
+ if (!pcap->rx)
+ return 0;
+
+ pkt = ODP_PACKET_INVALID;
+ pkt_len = 0;
+
+ for (i = 0; i < len; ) {
+ int ret;
+
+ if (pkt == ODP_PACKET_INVALID) {
+ pkt = packet_alloc(pcap->pool, 0 /*default len*/, 1);
+ if (odp_unlikely(pkt == ODP_PACKET_INVALID))
+ break;
+ pkt_len = odp_packet_len(pkt);
+ }
+
+ ret = pcap_next_ex(pcap->rx, &hdr, &data);
+
+ /* end of file, attempt to reopen if within loop limit */
+ if (ret == -2 && _pcapif_reopen(pcap) == 0)
+ continue;
+
+ if (ret != 1)
+ break;
+
+ pkt_hdr = odp_packet_hdr(pkt);
+
+ if (!odp_packet_pull_tail(pkt, pkt_len - hdr->caplen)) {
+ ODP_ERR("failed to pull tail: pkt_len: %d caplen: %d\n",
+ pkt_len, hdr->caplen);
+ break;
+ }
+
+ if (odp_packet_copydata_in(pkt, 0, hdr->caplen, data) != 0) {
+ ODP_ERR("failed to copy packet data\n");
+ break;
+ }
+
+ packet_parse_l2(pkt_hdr);
+
+ pkts[i] = pkt;
+ pkt = ODP_PACKET_INVALID;
+
+ i++;
+ }
+
+ if (pkt != ODP_PACKET_INVALID)
+ odp_packet_free(pkt);
+
+ return i;
+}
+
+static int _pcapif_dump_pkt(pkt_pcap_t *pcap, odp_packet_t pkt)
+{
+ struct pcap_pkthdr hdr;
+
+ if (!pcap->tx_dump)
+ return 0;
+
+ hdr.caplen = odp_packet_len(pkt);
+ hdr.len = hdr.caplen;
+ (void)gettimeofday(&hdr.ts, NULL);
+
+ if (odp_packet_copydata_out(pkt, 0, hdr.len, pcap->buf) != 0)
+ return -1;
+
+ pcap_dump(pcap->tx_dump, &hdr, pcap->buf);
+ (void)pcap_dump_flush(pcap->tx_dump);
+
+ return 0;
+}
+
+static int pcapif_send_pkt(pktio_entry_t *pktio_entry, odp_packet_t pkts[],
+ unsigned len)
+{
+ pkt_pcap_t *pcap = &pktio_entry->s.pkt_pcap;
+ unsigned i;
+
+ ODP_ASSERT(pktio_entry->s.state == STATE_START);
+
+ for (i = 0; i < len; ++i) {
+ if (odp_packet_len(pkts[i]) > PKTIO_PCAP_MTU) {
+ if (i == 0)
+ return -1;
+ break;
+ }
+
+ if (_pcapif_dump_pkt(pcap, pkts[i]) != 0)
+ break;
+
+ odp_packet_free(pkts[i]);
+ }
+
+ return i;
+}
+
+static int pcapif_mtu_get(pktio_entry_t *pktio_entry ODP_UNUSED)
+{
+ return PKTIO_PCAP_MTU;
+}
+
+static int pcapif_mac_addr_get(pktio_entry_t *pktio_entry ODP_UNUSED,
+ void *mac_addr)
+{
+ memcpy(mac_addr, pcap_mac, ODPH_ETHADDR_LEN);
+
+ return ODPH_ETHADDR_LEN;
+}
+
+static int pcapif_promisc_mode_set(pktio_entry_t *pktio_entry,
+ odp_bool_t enable)
+{
+ char filter_exp[64] = {0};
+ struct bpf_program bpf;
+ pkt_pcap_t *pcap = &pktio_entry->s.pkt_pcap;
+
+ if (!pcap->rx) {
+ pcap->promisc = enable;
+ return 0;
+ }
+
+ if (!enable) {
+ char mac_str[18];
+
+ snprintf(mac_str, sizeof(mac_str),
+ "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
+ pcap_mac[0], pcap_mac[1], pcap_mac[2],
+ pcap_mac[3], pcap_mac[4], pcap_mac[5]);
+
+ snprintf(filter_exp, sizeof(filter_exp),
+ "ether dst %s or broadcast or multicast",
+ mac_str);
+ }
+
+ if (pcap_compile(pcap->rx, &bpf, filter_exp,
+ 0, PCAP_NETMASK_UNKNOWN) != 0) {
+ ODP_ERR("failed to compile promisc mode filter: %s\n",
+ pcap_geterr(pcap->rx));
+ return -1;
+ }
+
+ if (pcap_setfilter(pcap->rx, &bpf) != 0) {
+ ODP_ERR("failed to set promisc mode filter: %s\n",
+ pcap_geterr(pcap->rx));
+ return -1;
+ }
+
+ pcap->promisc = enable;
+
+ return 0;
+}
+
+static int pcapif_promisc_mode_get(pktio_entry_t *pktio_entry)
+{
+ return pktio_entry->s.pkt_pcap.promisc;
+}
+
+const pktio_if_ops_t pcap_pktio_ops = {
+ .open = pcapif_init,
+ .close = pcapif_close,
+ .recv = pcapif_recv_pkt,
+ .send = pcapif_send_pkt,
+ .mtu_get = pcapif_mtu_get,
+ .promisc_mode_set = pcapif_promisc_mode_set,
+ .promisc_mode_get = pcapif_promisc_mode_get,
+ .mac_get = pcapif_mac_addr_get
+};
diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c
index a95b9a80e..7e3002740 100644
--- a/platform/linux-generic/pktio/socket.c
+++ b/platform/linux-generic/pktio/socket.c
@@ -322,7 +322,7 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry,
memset(msgvec, 0, sizeof(msgvec));
for (i = 0; i < (int)len; i++) {
- pkt_table[i] = _odp_packet_alloc(pkt_sock->pool);
+ pkt_table[i] = packet_alloc(pkt_sock->pool, 0 /*default*/, 1);
if (odp_unlikely(pkt_table[i] == ODP_PACKET_INVALID))
break;
@@ -336,6 +336,7 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry,
recv_msgs = recvmmsg(sockfd, msgvec, msgvec_len, MSG_DONTWAIT, NULL);
for (i = 0; i < recv_msgs; i++) {
+ odp_packet_hdr_t *pkt_hdr;
void *base = msgvec[i].msg_hdr.msg_iov->iov_base;
struct ethhdr *eth_hdr = base;
@@ -346,11 +347,13 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry,
continue;
}
- /* Parse and set packet header data */
+ pkt_hdr = odp_packet_hdr(pkt_table[i]);
+
odp_packet_pull_tail(pkt_table[i],
odp_packet_len(pkt_table[i]) -
msgvec[i].msg_len);
- _odp_packet_reset_parse(pkt_table[i]);
+
+ packet_parse_l2(pkt_hdr);
pkt_table[nb_rx] = pkt_table[i];
nb_rx++;
diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c
index ba773a3e6..35d24c693 100644
--- a/platform/linux-generic/pktio/socket_mmap.c
+++ b/platform/linux-generic/pktio/socket_mmap.c
@@ -118,6 +118,7 @@ static inline unsigned pkt_mmap_v2_rx(int sock, struct ring *ring,
uint8_t *pkt_buf;
int pkt_len;
struct ethhdr *eth_hdr;
+ odp_packet_hdr_t *pkt_hdr;
unsigned i = 0;
(void)sock;
@@ -142,20 +143,21 @@ static inline unsigned pkt_mmap_v2_rx(int sock, struct ring *ring,
continue;
}
- pkt_table[i] = odp_packet_alloc(pool, pkt_len);
+ pkt_table[i] = packet_alloc(pool, pkt_len, 1);
if (odp_unlikely(pkt_table[i] == ODP_PACKET_INVALID))
break;
+ pkt_hdr = odp_packet_hdr(pkt_table[i]);
+
if (odp_packet_copydata_in(pkt_table[i], 0,
pkt_len, pkt_buf) != 0) {
odp_packet_free(pkt_table[i]);
break;
}
- mmap_rx_user_ready(ppd.raw);
+ packet_parse_l2(pkt_hdr);
- /* Parse and set packet header data */
- _odp_packet_reset_parse(pkt_table[i]);
+ mmap_rx_user_ready(ppd.raw);
frame_num = next_frame_num;
i++;
diff --git a/platform/linux-generic/test/Makefile.am b/platform/linux-generic/test/Makefile.am
index 327d5bf2f..a657de9fc 100644
--- a/platform/linux-generic/test/Makefile.am
+++ b/platform/linux-generic/test/Makefile.am
@@ -27,6 +27,11 @@ TESTS = pktio/pktio_run \
${top_builddir}/test/validation/system/system_main$(EXEEXT)
SUBDIRS = $(ODP_MODULES)
+
+if HAVE_PCAP
+TESTS += pktio/pktio_run_pcap
+endif
+
endif
#performance tests refer to pktio_env
diff --git a/platform/linux-generic/test/pktio/Makefile.am b/platform/linux-generic/test/pktio/Makefile.am
index 93281dd1b..6fe20139c 100644
--- a/platform/linux-generic/test/pktio/Makefile.am
+++ b/platform/linux-generic/test/pktio/Makefile.am
@@ -1,2 +1,6 @@
dist_bin_SCRIPTS = pktio_env \
pktio_run
+
+if HAVE_PCAP
+dist_bin_SCRIPTS += pktio_run_pcap
+endif
diff --git a/platform/linux-generic/test/pktio/pktio_env b/platform/linux-generic/test/pktio/pktio_env
index 5e547e47b..345b5bd56 100644
--- a/platform/linux-generic/test/pktio/pktio_env
+++ b/platform/linux-generic/test/pktio/pktio_env
@@ -18,10 +18,10 @@
# Network set up
# IF0 <---> IF1
# IF2 <---> IF3
-IF0=pktio-p0-p1
-IF1=pktio-p1-p0
-IF2=pktio-p2-p3
-IF3=pktio-p3-p2
+IF0=pktiop0p1
+IF1=pktiop1p0
+IF2=pktiop2p3
+IF3=pktiop3p2
if [ "$0" = "$BASH_SOURCE" ]; then
echo "Error: Platform specific env file has to be sourced."
diff --git a/platform/linux-generic/test/pktio/pktio_run_pcap b/platform/linux-generic/test/pktio/pktio_run_pcap
new file mode 100755
index 000000000..c130417c5
--- /dev/null
+++ b/platform/linux-generic/test/pktio/pktio_run_pcap
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# Copyright (c) 2015, Linaro Limited
+# All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+# directories where pktio_main binary can be found:
+# -in the validation dir when running make check (intree or out of tree)
+# -in the script directory, when running after 'make install', or
+# -in the validation when running standalone intree.
+# -in the current directory.
+# running stand alone out of tree requires setting PATH
+PATH=${TEST_DIR}/pktio:$PATH
+PATH=$(dirname $0):$PATH
+PATH=$(dirname $0)/../../../../test/validation/pktio:$PATH
+PATH=.:$PATH
+
+pktio_main_path=$(which pktio_main${EXEEXT})
+if [ -x "$pktio_main_path" ] ; then
+ echo "running with $pktio_main_path"
+else
+ echo "cannot find pktio_main${EXEEXT}: please set you PATH for it."
+fi
+
+PCAP_FNAME=vald.pcap
+export ODP_PKTIO_IF0="pcap:out=${PCAP_FNAME}"
+export ODP_PKTIO_IF1="pcap:in=${PCAP_FNAME}"
+pktio_main${EXEEXT}
+ret=$?
+rm -f ${PCAP_FNAME}
+exit $ret
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4983a0cee..16316b928 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3411,7 +3411,7 @@ sub process {
# function brace can't be on same line, except for #defines of do while,
# or if closed on same line
if (($line=~/$Type\s*$Ident\(.*\).*\s*{/) and
- !($line=~/\#\s*define.*do\s{/) and !($line=~/}/)) {
+ !($line=~/\#\s*define.*do\s\{/) and !($line=~/}/)) {
if (ERROR("OPEN_BRACE",
"open brace '{' following function declarations go on the next line\n" . $herecurr) &&
$fix) {
@@ -3923,8 +3923,8 @@ sub process {
## }
#need space before brace following if, while, etc
- if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) ||
- $line =~ /do{/) {
+ if (($line =~ /\(.*\)\{/ && $line !~ /\($Type\){/) ||
+ $line =~ /do\{/) {
if (ERROR("SPACING",
"space required before the open brace '{'\n" . $herecurr) &&
$fix) {
@@ -4377,7 +4377,7 @@ sub process {
$dstat !~ /^for\s*$Constant$/ && # for (...)
$dstat !~ /^for\s*$Constant\s+(?:$Ident|-?$Constant)$/ && # for (...) bar()
$dstat !~ /^do\s*{/ && # do {...
- $dstat !~ /^\({/ && # ({...
+ $dstat !~ /^\(\{/ && # ({...
$ctx !~ /^.\s*#\s*define\s+TRACE_(?:SYSTEM|INCLUDE_FILE|INCLUDE_PATH)\b/)
{
$ctx =~ s/\n*$//;
diff --git a/scripts/git_hash.sh b/scripts/git_hash.sh
index 6cfec2f36..e15094e50 100755
--- a/scripts/git_hash.sh
+++ b/scripts/git_hash.sh
@@ -8,8 +8,8 @@ ROOTDIR=${1}
CUSTOM_STR=${CUSTOM_STR:-https://git.linaro.org/lng/odp.git}
if [ -d ${ROOTDIR}/.git ]; then
- hash=$(git describe | tr -d "\n")
- if git diff-index --name-only HEAD &>/dev/null ; then
+ hash=$(git --git-dir=${ROOTDIR}/.git describe | tr -d "\n")
+ if git --git-dir=${ROOTDIR}/.git diff-index --name-only HEAD &>/dev/null ; then
dirty=-dirty
fi
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
index 390af67e4..1a0c845cb 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -41,25 +41,19 @@
#define SHM_PKT_POOL_BUF_SIZE 1856
/** @def MAX_PKT_BURST
- * @brief Maximum number of packet bursts
+ * @brief Maximum number of packet in a burst
*/
#define MAX_PKT_BURST 16
-/** @def APPL_MODE_PKT_BURST
- * @brief The application will handle pakcets in bursts
- */
-#define APPL_MODE_PKT_BURST 0
-
-/** @def APPL_MODE_PKT_QUEUE
- * @brief The application will handle packets in queues
- */
-#define APPL_MODE_PKT_QUEUE 1
-
-/** @def PRINT_APPL_MODE(x)
- * @brief Macro to print the current status of how the application handles
- * packets.
+/**
+ * Packet input mode
*/
-#define PRINT_APPL_MODE(x) printf("%s(%i)\n", #x, (x))
+typedef enum pkt_in_mode_t {
+ DIRECT_RECV,
+ SCHED_NONE,
+ SCHED_ATOMIC,
+ SCHED_ORDERED,
+} pkt_in_mode_t;
/** Get rid of path in filename - only for unix-type paths using '/' */
#define NO_PATH(file_name) (strrchr((file_name), '/') ? \
@@ -71,10 +65,12 @@ typedef struct {
int cpu_count;
int if_count; /**< Number of interfaces to be used */
char **if_names; /**< Array of pointers to interface names */
- int mode; /**< Packet IO mode */
+ pkt_in_mode_t mode; /**< Packet input mode */
int time; /**< Time in seconds to run. */
int accuracy; /**< Number of seconds to get and print statistics */
char *if_str; /**< Storage for interface names */
+ int dst_change; /**< Change destination eth addresses > */
+ int src_change; /**< Change source eth addresses > */
} appl_args_t;
static int exit_threads; /**< Break workers loop if set to 1 */
@@ -107,8 +103,12 @@ typedef struct {
odp_pktio_t pktios[ODP_CONFIG_PKTIO_ENTRIES];
/** Table of port ethernet addresses */
odph_ethaddr_t port_eth_addr[ODP_CONFIG_PKTIO_ENTRIES];
+ /** Table of dst ethernet addresses */
+ odph_ethaddr_t dst_eth_addr[ODP_CONFIG_PKTIO_ENTRIES];
/** Table of port default output queues */
odp_queue_t outq_def[ODP_CONFIG_PKTIO_ENTRIES];
+ /** Table of dst ports */
+ int dst_port[ODP_CONFIG_PKTIO_ENTRIES];
} args_t;
/** Global pointer to args */
@@ -118,9 +118,10 @@ static odp_barrier_t barrier;
/* helper funcs */
static inline int lookup_dest_port(odp_packet_t pkt);
+static inline int find_dest_port(int port);
static int drop_err_pkts(odp_packet_t pkt_tbl[], unsigned len);
-static void fill_src_eth_addrs(odp_packet_t pkt_tbl[], unsigned num,
- int dst_port);
+static void fill_eth_addrs(odp_packet_t pkt_tbl[], unsigned num,
+ int dst_port);
static void parse_args(int argc, char *argv[], appl_args_t *appl_args);
static void print_info(char *progname, appl_args_t *appl_args);
static void usage(char *progname);
@@ -137,6 +138,7 @@ static void *pktio_queue_thread(void *arg)
odp_packet_t pkt;
odp_event_t ev;
thread_args_t *thr_args = arg;
+ uint64_t wait;
stats_t *stats = calloc(1, sizeof(stats_t));
*thr_args->stats = stats;
@@ -146,10 +148,14 @@ static void *pktio_queue_thread(void *arg)
printf("[%02i] QUEUE mode\n", thr);
odp_barrier_wait(&barrier);
+ wait = odp_schedule_wait_time(ODP_TIME_MSEC * 100);
+
/* Loop packets */
while (!exit_threads) {
/* Use schedule to get buf from any input queue */
- ev = odp_schedule(NULL, ODP_SCHED_WAIT);
+ ev = odp_schedule(NULL, wait);
+ if (ev == ODP_EVENT_INVALID)
+ continue;
pkt = odp_packet_from_event(ev);
/* Drop packets with errors */
@@ -160,7 +166,7 @@ static void *pktio_queue_thread(void *arg)
dst_port = lookup_dest_port(pkt);
- fill_src_eth_addrs(&pkt, 1, dst_port);
+ fill_eth_addrs(&pkt, 1, dst_port);
/* Enqueue the packet for output */
outq_def = gbl_args->outq_def[dst_port];
@@ -179,6 +185,8 @@ static void *pktio_queue_thread(void *arg)
/**
* Lookup the destination port for a given packet
+ *
+ * @param pkt ODP packet handle
*/
static inline int lookup_dest_port(odp_packet_t pkt)
{
@@ -194,15 +202,33 @@ static inline int lookup_dest_port(odp_packet_t pkt)
if (src_idx == -1)
LOG_ABORT("Failed to determine pktio input\n");
- return (src_idx % 2 == 0) ? src_idx + 1 : src_idx - 1;
+ return gbl_args->dst_port[src_idx];
}
/**
- * Packet IO worker thread using bursts from/to IO resources
+ * Find the destination port for a given input port
+ *
+ * @param port Input port index
+ */
+static inline int find_dest_port(int port)
+{
+ /* Even number of ports */
+ if (gbl_args->appl.if_count % 2 == 0)
+ return (port % 2 == 0) ? port + 1 : port - 1;
+
+ /* Odd number of ports */
+ if (port == gbl_args->appl.if_count - 1)
+ return 0;
+ else
+ return port + 1;
+}
+
+/**
+ * Packet IO worker thread accessing IO resources directly
*
* @param arg thread arguments of type 'thread_args_t *'
*/
-static void *pktio_ifburst_thread(void *arg)
+static void *pktio_direct_recv_thread(void *arg)
{
int thr;
thread_args_t *thr_args;
@@ -218,12 +244,12 @@ static void *pktio_ifburst_thread(void *arg)
*thr_args->stats = stats;
src_idx = thr_args->src_idx;
- dst_idx = (src_idx % 2 == 0) ? src_idx+1 : src_idx-1;
+ dst_idx = gbl_args->dst_port[src_idx];
pktio_src = gbl_args->pktios[src_idx];
pktio_dst = gbl_args->pktios[dst_idx];
printf("[%02i] srcif:%s dstif:%s spktio:%02" PRIu64
- " dpktio:%02" PRIu64 " BURST mode\n",
+ " dpktio:%02" PRIu64 " DIRECT RECV mode\n",
thr,
gbl_args->appl.if_names[src_idx],
gbl_args->appl.if_names[dst_idx],
@@ -239,7 +265,7 @@ static void *pktio_ifburst_thread(void *arg)
/* Drop packets with errors */
pkts_ok = drop_err_pkts(pkt_tbl, pkts);
if (pkts_ok > 0) {
- fill_src_eth_addrs(pkt_tbl, pkts_ok, dst_idx);
+ fill_eth_addrs(pkt_tbl, pkts_ok, dst_idx);
int sent = odp_pktio_send(pktio_dst, pkt_tbl, pkts_ok);
@@ -270,13 +296,11 @@ static void *pktio_ifburst_thread(void *arg)
*
* @param dev Name of device to open
* @param pool Pool to associate with device for packet RX/TX
- * @param mode Packet processing mode for this device (BURST or QUEUE)
*
* @return The handle of the created pktio object.
* @retval ODP_PKTIO_INVALID if the create fails.
*/
-static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool,
- int mode)
+static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool)
{
char inq_name[ODP_QUEUE_NAME_LEN];
odp_queue_param_t qparam;
@@ -284,10 +308,11 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool,
odp_pktio_t pktio;
int ret;
odp_pktio_param_t pktio_param;
+ odp_schedule_sync_t sync_mode;
odp_pktio_param_init(&pktio_param);
- if (mode == APPL_MODE_PKT_BURST)
+ if (gbl_args->appl.mode == DIRECT_RECV)
pktio_param.in_mode = ODP_PKTIN_MODE_RECV;
else
pktio_param.in_mode = ODP_PKTIN_MODE_SCHED;
@@ -301,13 +326,20 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool,
printf("created pktio %" PRIu64 " (%s)\n",
odp_pktio_to_u64(pktio), dev);
- /* no further setup needed for burst mode */
- if (mode == APPL_MODE_PKT_BURST)
+ /* no further setup needed for direct receive mode */
+ if (gbl_args->appl.mode == DIRECT_RECV)
return pktio;
+ if (gbl_args->appl.mode == SCHED_ATOMIC)
+ sync_mode = ODP_SCHED_SYNC_ATOMIC;
+ else if (gbl_args->appl.mode == SCHED_ORDERED)
+ sync_mode = ODP_SCHED_SYNC_ORDERED;
+ else
+ sync_mode = ODP_SCHED_SYNC_NONE;
+
odp_queue_param_init(&qparam);
qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT;
- qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC;
+ qparam.sched.sync = sync_mode;
qparam.sched.group = ODP_SCHED_GROUP_ALL;
snprintf(inq_name, sizeof(inq_name), "%" PRIu64 "-pktio_inq_def",
odp_pktio_to_u64(pktio));
@@ -338,12 +370,22 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool,
*
*/
static int print_speed_stats(int num_workers, stats_t **thr_stats,
- int duration, int timeout)
+ int duration, int timeout)
{
- uint64_t pkts, pkts_prev = 0, pps, drops, maximum_pps = 0;
- int i, elapsed = 0;
+ uint64_t pkts = 0;
+ uint64_t pkts_prev = 0;
+ uint64_t pps;
+ uint64_t drops;
+ uint64_t maximum_pps = 0;
+ int i;
+ int elapsed = 0;
+ int stats_enabled = 1;
int loop_forever = (duration == 0);
+ if (timeout <= 0)
+ stats_enabled = 0;
+ timeout = 1;
+
/* Wait for all threads to be ready*/
odp_barrier_wait(&barrier);
@@ -357,20 +399,23 @@ static int print_speed_stats(int num_workers, stats_t **thr_stats,
pkts += thr_stats[i]->packets;
drops += thr_stats[i]->drops;
}
- pps = (pkts - pkts_prev) / timeout;
- if (pps > maximum_pps)
- maximum_pps = pps;
- printf("%" PRIu64 " pps, %" PRIu64 " max pps, ", pps,
- maximum_pps);
+ if (stats_enabled) {
+ pps = (pkts - pkts_prev) / timeout;
+ if (pps > maximum_pps)
+ maximum_pps = pps;
+ printf("%" PRIu64 " pps, %" PRIu64 " max pps, ", pps,
+ maximum_pps);
- printf(" %" PRIu64 " total drops\n", drops);
+ printf(" %" PRIu64 " total drops\n", drops);
+ pkts_prev = pkts;
+ }
elapsed += timeout;
- pkts_prev = pkts;
} while (loop_forever || (elapsed < duration));
- printf("TEST RESULT: %" PRIu64 " maximum packets per second.\n",
- maximum_pps);
+ if (stats_enabled)
+ printf("TEST RESULT: %" PRIu64 " maximum packets per second.\n",
+ maximum_pps);
return pkts > 100 ? 0 : -1;
}
@@ -388,6 +433,7 @@ int main(int argc, char *argv[])
odp_shm_t shm;
odp_cpumask_t cpumask;
char cpumaskstr[ODP_CPUMASK_STR_SIZE];
+ odph_ethaddr_t new_addr;
odp_pktio_t pktio;
odp_pool_param_t params;
int ret;
@@ -439,11 +485,6 @@ int main(int argc, char *argv[])
num_workers);
exit(EXIT_FAILURE);
}
- if (gbl_args->appl.if_count % 2 != 0) {
- LOG_ERR("Error: interface count %d is odd in fwd appl.\n",
- gbl_args->appl.if_count);
- exit(EXIT_FAILURE);
- }
/* Create packet pool */
odp_pool_param_init(&params);
@@ -461,8 +502,7 @@ int main(int argc, char *argv[])
odp_pool_print(pool);
for (i = 0; i < gbl_args->appl.if_count; ++i) {
- pktio = create_pktio(gbl_args->appl.if_names[i],
- pool, gbl_args->appl.mode);
+ pktio = create_pktio(gbl_args->appl.if_names[i], pool);
if (pktio == ODP_PKTIO_INVALID)
exit(EXIT_FAILURE);
gbl_args->pktios[i] = pktio;
@@ -475,9 +515,21 @@ int main(int argc, char *argv[])
}
/* Save interface default output queue */
- if (gbl_args->appl.mode == APPL_MODE_PKT_QUEUE)
+ if (gbl_args->appl.mode != DIRECT_RECV)
gbl_args->outq_def[i] = odp_pktio_outq_getdef(pktio);
+ /* Save destination eth address */
+ if (gbl_args->appl.dst_change) {
+ /* 02:00:00:00:00:XX */
+ memset(&new_addr, 0, sizeof(odph_ethaddr_t));
+ new_addr.addr[0] = 0x02;
+ new_addr.addr[5] = i;
+ gbl_args->dst_eth_addr[i] = new_addr;
+ }
+
+ /* Save interface destination port */
+ gbl_args->dst_port[i] = find_dest_port(i);
+
ret = odp_pktio_start(pktio);
if (ret) {
LOG_ERR("Error: unable to start %s\n",
@@ -500,9 +552,9 @@ int main(int argc, char *argv[])
odp_cpumask_t thd_mask;
void *(*thr_run_func) (void *);
- if (gbl_args->appl.mode == APPL_MODE_PKT_BURST)
- thr_run_func = pktio_ifburst_thread;
- else /* APPL_MODE_PKT_QUEUE */
+ if (gbl_args->appl.mode == DIRECT_RECV)
+ thr_run_func = pktio_direct_recv_thread;
+ else /* SCHED_NONE / SCHED_ATOMIC / SCHED_ORDERED */
thr_run_func = pktio_queue_thread;
gbl_args->thread[i].src_idx = i % gbl_args->appl.if_count;
@@ -563,24 +615,31 @@ static int drop_err_pkts(odp_packet_t pkt_tbl[], unsigned len)
}
/**
- * Fill packets' eth src addresses according to the destination port
+ * Fill packets' eth addresses according to the destination port
*
* @param pkt_tbl Array of packets
* @param num Number of packets in the array
* @param dst_port Destination port
*/
-static void fill_src_eth_addrs(odp_packet_t pkt_tbl[], unsigned num,
- int dst_port)
+static void fill_eth_addrs(odp_packet_t pkt_tbl[], unsigned num, int dst_port)
{
odp_packet_t pkt;
odph_ethhdr_t *eth;
unsigned i;
+ if (!gbl_args->appl.dst_change && !gbl_args->appl.src_change)
+ return;
+
for (i = 0; i < num; ++i) {
pkt = pkt_tbl[i];
if (odp_packet_has_eth(pkt)) {
eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL);
- eth->src = gbl_args->port_eth_addr[dst_port];
+
+ if (gbl_args->appl.src_change)
+ eth->src = gbl_args->port_eth_addr[dst_port];
+
+ if (gbl_args->appl.dst_change)
+ eth->dst = gbl_args->dst_eth_addr[dst_port];
}
}
}
@@ -603,18 +662,20 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
{"count", required_argument, NULL, 'c'},
{"time", required_argument, NULL, 't'},
{"accuracy", required_argument, NULL, 'a'},
- {"interface", required_argument, NULL, 'i'}, /* return 'i' */
- {"mode", required_argument, NULL, 'm'}, /* return 'm' */
- {"help", no_argument, NULL, 'h'}, /* return 'h' */
+ {"interface", required_argument, NULL, 'i'},
+ {"mode", required_argument, NULL, 'm'},
+ {"dst_change", required_argument, NULL, 'd'},
+ {"src_change", required_argument, NULL, 's'},
+ {"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}
};
appl_args->time = 0; /* loop forever if time to run is 0 */
appl_args->accuracy = 1; /* get and print pps stats second */
- appl_args->mode = -1; /* Invalid, must be changed by parsing */
+ appl_args->src_change = 1; /* change eth src address by default */
while (1) {
- opt = getopt_long(argc, argv, "+c:+t:+a:i:m:h",
+ opt = getopt_long(argc, argv, "+c:+t:+a:i:m:d:s:h",
longopts, &long_index);
if (opt == -1)
@@ -670,26 +731,33 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
appl_args->if_names[i] = token;
}
break;
-
case 'm':
i = atoi(optarg);
- if (i == 0)
- appl_args->mode = APPL_MODE_PKT_BURST;
+ if (i == 1)
+ appl_args->mode = SCHED_NONE;
+ else if (i == 2)
+ appl_args->mode = SCHED_ATOMIC;
+ else if (i == 3)
+ appl_args->mode = SCHED_ORDERED;
else
- appl_args->mode = APPL_MODE_PKT_QUEUE;
+ appl_args->mode = DIRECT_RECV;
+ break;
+ case 'd':
+ appl_args->dst_change = atoi(optarg);
+ break;
+ case 's':
+ appl_args->src_change = atoi(optarg);
break;
-
case 'h':
usage(argv[0]);
exit(EXIT_SUCCESS);
break;
-
default:
break;
}
}
- if (appl_args->if_count == 0 || appl_args->mode == -1) {
+ if (appl_args->if_count == 0) {
usage(argv[0]);
exit(EXIT_FAILURE);
}
@@ -725,10 +793,14 @@ static void print_info(char *progname, appl_args_t *appl_args)
printf(" %s", appl_args->if_names[i]);
printf("\n"
"Mode: ");
- if (appl_args->mode == APPL_MODE_PKT_BURST)
- PRINT_APPL_MODE(APPL_MODE_PKT_BURST);
- else
- PRINT_APPL_MODE(APPL_MODE_PKT_QUEUE);
+ if (appl_args->mode == DIRECT_RECV)
+ printf("DIRECT_RECV");
+ else if (appl_args->mode == SCHED_NONE)
+ printf("SCHED_NONE");
+ else if (appl_args->mode == SCHED_ATOMIC)
+ printf("SCHED_ATOMIC");
+ else if (appl_args->mode == SCHED_ORDERED)
+ printf("SCHED_ORDERED");
printf("\n\n");
fflush(NULL);
}
@@ -749,14 +821,20 @@ static void usage(char *progname)
"\n"
"Mandatory OPTIONS:\n"
" -i, --interface Eth interfaces (comma-separated, no spaces)\n"
- " -m, --mode 0: Burst send&receive packets (no queues)\n"
- " 1: Send&receive packets through ODP queues.\n"
"\n"
"Optional OPTIONS\n"
+ " -m, --mode 0: Send&receive packets directly from NIC (default)\n"
+ " 1: Send&receive packets through scheduler sync none queues\n"
+ " 2: Send&receive packets through scheduler sync atomic queues\n"
+ " 3: Send&receive packets through scheduler sync ordered queues\n"
" -c, --count <number> CPU count.\n"
" -t, --time <number> Time in seconds to run.\n"
" -a, --accuracy <number> Time in seconds get print statistics\n"
" (default is 1 second).\n"
+ " -d, --dst_change 0: Don't change packets' dst eth addresses (default)\n"
+ " 1: Change packets' dst eth addresses\n"
+ " -s, --src_change 0: Don't change packets' src eth addresses\n"
+ " 1: Change packets' src eth addresses (default)\n"
" -h, --help Display help and exit.\n\n"
" environment variables: ODP_PKTIO_DISABLE_NETMAP\n"
" ODP_PKTIO_DISABLE_SOCKET_MMAP\n"
diff --git a/test/validation/README b/test/validation/README
index 2d0c258a1..1baebaafc 100644
--- a/test/validation/README
+++ b/test/validation/README
@@ -4,47 +4,32 @@ All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
-To add tests in here, please observe the following rules:
+To add tests in here, please observe the rules listed below. This list
+is a brief overview, for a more detailed explanation of the test
+framework refer to the ODP Implementers' Guide, which can built as
+follows:
-1. Tests should be placed in the directory of the module they belong to.
+ ./configure --enable-user-guides
+ make
+Output will be in doc/output/. If this fails, check the documentation
+section of the DEPENDENCIES file.
-2. Test under test/validation/... should be platform agnostic, i.e.
- -they should be written in plain C only
- -they may only used Clib functions, C_UNIT functions and of course ODP
- functions.
- -they should be expected to pass on all ODP implementation
-
- Tests that do not follow these rules should be placed in the platform
- specific test area (currently platform/<platform>/test*)
-
-
-3. If a new ODP API module is created, please update the Makefile.am and
- the odptest.h file
+Rules for all tests under this tree:
+1. Tests must be placed in the directory of the module they belong to.
-4. Respect the following name convention for the names exported in the library:
+2. Tests must be platform agnostic, i.e.
- * Tests, i.e. functions which are used in CUNIT test suites are named:
- *<Module>_test_*
+ - should be written in plain C only.
+ - may only use C standard library functions, CUnit functions and of
+ course ODP functions
+ - should be expected to pass on all ODP implementations
- * Test arrays, i.e. arrays of CU_TestInfo, listing the test functions
- belonging to a suite, are called:
- <Module>_suite[_*]
- where the possible suffix can be used if many suites are declared.
-
- * CUNIT suite init and termination functions are called:
- <Module>_suite[_*]_init() and <Module>_suite[_*]_term()
- respectively.
-
- * Suite arrays, i.e. arrays of CU_SuiteInfo used in executables are called:
- <Module>_suites[_*]
- where the possible suffix identifies the executable using it, if many.
+ Tests that do not follow these rules should be placed in the platform
+ specific test area (currently platform/<platform>/test/).
- * Main executable function(s), are called:
- <Module>_main[_*]*
- where the possible suffix identifies the executable using it
+3. If a new ODP API module is created, please update the Makefile.am.
- * Init/term function for the whole executable are called:
- <Module>_init
- <Module>_term
+4. Symbols exported from test libraries must respect the naming
+ convention detailed in the ODP Implementers' Guide.
diff --git a/test/validation/buffer/buffer.c b/test/validation/buffer/buffer.c
index c62938d0a..257e95cb3 100644
--- a/test/validation/buffer/buffer.c
+++ b/test/validation/buffer/buffer.c
@@ -139,23 +139,24 @@ void buffer_test_management_basic(void)
CU_ASSERT(odp_event_to_u64(ev) != odp_event_to_u64(ODP_EVENT_INVALID));
}
-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,
+odp_testinfo_t buffer_suite[] = {
+ ODP_TEST_INFO(buffer_test_pool_alloc),
+ ODP_TEST_INFO(buffer_test_pool_free),
+ ODP_TEST_INFO(buffer_test_management_basic),
+ ODP_TEST_INFO_NULL,
};
-CU_SuiteInfo buffer_suites[] = {
- { .pName = "buffer tests",
- .pTests = buffer_suite,
- .pInitFunc = buffer_suite_init,
- .pCleanupFunc = buffer_suite_term,
- },
- CU_SUITE_INFO_NULL,
+odp_suiteinfo_t buffer_suites[] = {
+ {"buffer tests", buffer_suite_init, buffer_suite_term, buffer_suite},
+ ODP_SUITE_INFO_NULL,
};
int buffer_main(void)
{
- return odp_cunit_run(buffer_suites);
+ int ret = odp_cunit_register(buffer_suites);
+
+ if (ret == 0)
+ odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/buffer/buffer.h b/test/validation/buffer/buffer.h
index 49166247f..8b61bf527 100644
--- a/test/validation/buffer/buffer.h
+++ b/test/validation/buffer/buffer.h
@@ -7,7 +7,7 @@
#ifndef _ODP_TEST_BUFFER_H_
#define _ODP_TEST_BUFFER_H_
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
void buffer_test_pool_alloc(void);
@@ -15,14 +15,14 @@ void buffer_test_pool_free(void);
void buffer_test_management_basic(void);
/* test arrays: */
-extern CU_TestInfo buffer_suite[];
+extern odp_testinfo_t buffer_suite[];
/* test array init/term functions: */
int buffer_suite_init(void);
int buffer_suite_term(void);
/* test registry: */
-extern CU_SuiteInfo buffer_suites[];
+extern odp_suiteinfo_t buffer_suites[];
/* main test program: */
int buffer_main(void);
diff --git a/test/validation/classification/classification.c b/test/validation/classification/classification.c
index 6641893d7..9c3dbbb69 100644
--- a/test/validation/classification/classification.c
+++ b/test/validation/classification/classification.c
@@ -9,7 +9,7 @@
#include "odp_classification_testsuites.h"
#include "classification.h"
-CU_SuiteInfo classification_suites[] = {
+odp_suiteinfo_t classification_suites[] = {
{ .pName = "classification basic",
.pTests = classification_suite_basic,
},
@@ -23,10 +23,15 @@ CU_SuiteInfo classification_suites[] = {
.pInitFunc = classification_suite_init,
.pCleanupFunc = classification_suite_term,
},
- CU_SUITE_INFO_NULL,
+ ODP_SUITE_INFO_NULL,
};
int classification_main(void)
{
- return odp_cunit_run(classification_suites);
+ int ret = odp_cunit_register(classification_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/classification/classification.h b/test/validation/classification/classification.h
index de9c37e13..6a7e8a5ab 100644
--- a/test/validation/classification/classification.h
+++ b/test/validation/classification/classification.h
@@ -7,7 +7,7 @@
#ifndef _ODP_TEST_CLASSIFICATION_H_
#define _ODP_TEST_CLASSIFICATION_H_
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
#define SHM_PKT_NUM_BUFS 32
#define SHM_PKT_BUF_SIZE 1024
@@ -71,15 +71,15 @@ void classification_test_pktio_configure(void);
void classification_test_pktio_test(void);
/* test arrays: */
-extern CU_TestInfo classification_suite_basic[];
-extern CU_TestInfo classification_suite[];
+extern odp_testinfo_t classification_suite_basic[];
+extern odp_testinfo_t classification_suite[];
/* test array init/term functions: */
int classification_suite_init(void);
int classification_suite_term(void);
/* test registry: */
-extern CU_SuiteInfo classification_suites[];
+extern odp_suiteinfo_t classification_suites[];
/* main test program: */
int classification_main(void);
diff --git a/test/validation/classification/odp_classification_basic.c b/test/validation/classification/odp_classification_basic.c
index f8b804d4e..20c157f4e 100644
--- a/test/validation/classification/odp_classification_basic.c
+++ b/test/validation/classification/odp_classification_basic.c
@@ -170,14 +170,14 @@ void classification_test_pmr_match_set_destroy(void)
CU_ASSERT(retval == 0);
}
-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,
+odp_testinfo_t classification_suite_basic[] = {
+ ODP_TEST_INFO(classification_test_create_cos),
+ ODP_TEST_INFO(classification_test_destroy_cos),
+ ODP_TEST_INFO(classification_test_create_pmr_match),
+ ODP_TEST_INFO(classification_test_destroy_pmr),
+ ODP_TEST_INFO(classification_test_cos_set_queue),
+ ODP_TEST_INFO(classification_test_cos_set_drop),
+ ODP_TEST_INFO(classification_test_pmr_match_set_create),
+ ODP_TEST_INFO(classification_test_pmr_match_set_destroy),
+ ODP_TEST_INFO_NULL,
};
diff --git a/test/validation/classification/odp_classification_test_pmr.c b/test/validation/classification/odp_classification_test_pmr.c
index 4bfe0cbfe..73ba6f5d5 100644
--- a/test/validation/classification/odp_classification_test_pmr.c
+++ b/test/validation/classification/odp_classification_test_pmr.c
@@ -533,11 +533,11 @@ static void classification_test_pmr_term_ipproto(void)
odp_pktio_close(pktio);
}
-CU_TestInfo classification_suite_pmr[] = {
- _CU_TEST_INFO(classification_test_pmr_term_tcp_dport),
- _CU_TEST_INFO(classification_test_pmr_term_tcp_sport),
- _CU_TEST_INFO(classification_test_pmr_term_udp_dport),
- _CU_TEST_INFO(classification_test_pmr_term_udp_sport),
- _CU_TEST_INFO(classification_test_pmr_term_ipproto),
- CU_TEST_INFO_NULL,
+odp_testinfo_t classification_suite_pmr[] = {
+ ODP_TEST_INFO(classification_test_pmr_term_tcp_dport),
+ ODP_TEST_INFO(classification_test_pmr_term_tcp_sport),
+ ODP_TEST_INFO(classification_test_pmr_term_udp_dport),
+ ODP_TEST_INFO(classification_test_pmr_term_udp_sport),
+ ODP_TEST_INFO(classification_test_pmr_term_ipproto),
+ ODP_TEST_INFO_NULL,
};
diff --git a/test/validation/classification/odp_classification_tests.c b/test/validation/classification/odp_classification_tests.c
index 03a855e5b..7dba8effb 100644
--- a/test/validation/classification/odp_classification_tests.c
+++ b/test/validation/classification/odp_classification_tests.c
@@ -643,12 +643,12 @@ void classification_test_pktio_test(void)
test_pktio_pmr_match_set_cos();
}
-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,
+odp_testinfo_t classification_suite[] = {
+ ODP_TEST_INFO(classification_test_pmr_terms_avail),
+ ODP_TEST_INFO(classification_test_pktio_set_skip),
+ ODP_TEST_INFO(classification_test_pktio_set_headroom),
+ ODP_TEST_INFO(classification_test_pmr_terms_cap),
+ ODP_TEST_INFO(classification_test_pktio_configure),
+ ODP_TEST_INFO(classification_test_pktio_test),
+ ODP_TEST_INFO_NULL,
};
diff --git a/test/validation/classification/odp_classification_testsuites.h b/test/validation/classification/odp_classification_testsuites.h
index a7a8baa83..7d27d95b5 100644
--- a/test/validation/classification/odp_classification_testsuites.h
+++ b/test/validation/classification/odp_classification_testsuites.h
@@ -8,12 +8,11 @@
#define ODP_CLASSIFICATION_TESTSUITES_H_
#include <odp.h>
-#include <CUnit/CUnit.h>
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
-extern CU_TestInfo classification_suite[];
-extern CU_TestInfo classification_suite_basic[];
-extern CU_TestInfo classification_suite_pmr[];
+extern odp_testinfo_t classification_suite[];
+extern odp_testinfo_t classification_suite_basic[];
+extern odp_testinfo_t classification_suite_pmr[];
int classification_suite_init(void);
int classification_suite_term(void);
diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c
index 0f79199ea..a98042d2d 100644
--- a/test/validation/common/odp_cunit_common.c
+++ b/test/validation/common/odp_cunit_common.c
@@ -22,6 +22,8 @@ static struct {
int (*global_term_ptr)(void);
} global_init_term = {tests_global_init, tests_global_term};
+static odp_suiteinfo_t *global_testsuites;
+
/** create test thread */
int odp_cunit_thread_create(void *func_ptr(void *), pthrd_arg *arg)
{
@@ -90,22 +92,196 @@ 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[])
+static odp_suiteinfo_t *cunit_get_suite_info(const char *suite_name)
{
- int ret;
+ odp_suiteinfo_t *sinfo;
- printf("\tODP API version: %s\n", odp_version_api_str());
- printf("\tODP implementation version: %s\n", odp_version_impl_str());
+ for (sinfo = global_testsuites; sinfo->pName; sinfo++)
+ if (strcmp(sinfo->pName, suite_name) == 0)
+ return sinfo;
- /* call test executable init hook, if any */
- if (global_init_term.global_init_ptr &&
- ((*global_init_term.global_init_ptr)() != 0))
+ return NULL;
+}
+
+static odp_testinfo_t *cunit_get_test_info(odp_suiteinfo_t *sinfo,
+ const char *test_name)
+{
+ odp_testinfo_t *tinfo;
+
+ for (tinfo = sinfo->pTests; tinfo->testinfo.pName; tinfo++)
+ if (strcmp(tinfo->testinfo.pName, test_name) == 0)
+ return tinfo;
+
+ return NULL;
+}
+
+/* A wrapper for the suite's init function. This is done to allow for a
+ * potential runtime check to determine whether each test in the suite
+ * is active (enabled by using ODP_TEST_INFO_CONDITIONAL()). If present,
+ * the conditional check is run after the suite's init function.
+ */
+static int _cunit_suite_init(void)
+{
+ int ret = 0;
+ CU_pSuite cur_suite = CU_get_current_suite();
+ odp_suiteinfo_t *sinfo;
+ odp_testinfo_t *tinfo;
+
+ /* find the suite currently being run */
+ cur_suite = CU_get_current_suite();
+ if (!cur_suite)
return -1;
- CU_set_error_action(CUEA_ABORT);
+ sinfo = cunit_get_suite_info(cur_suite->pName);
+ if (!sinfo)
+ return -1;
+
+ /* execute its init function */
+ if (sinfo->pInitFunc) {
+ ret = sinfo->pInitFunc();
+ if (ret)
+ return ret;
+ }
+
+ /* run any configured conditional checks and mark inactive tests */
+ for (tinfo = sinfo->pTests; tinfo->testinfo.pName; tinfo++) {
+ CU_pTest ptest;
+ CU_ErrorCode err;
+
+ if (!tinfo->check_active || tinfo->check_active())
+ continue;
+
+ /* test is inactive, mark it as such */
+ ptest = CU_get_test_by_name(tinfo->testinfo.pName, cur_suite);
+ if (ptest)
+ err = CU_set_test_active(ptest, CU_FALSE);
+ else
+ err = CUE_NOTEST;
+
+ if (err != CUE_SUCCESS) {
+ fprintf(stderr, "%s: failed to set test %s inactive\n",
+ __func__, tinfo->testinfo.pName);
+ return -1;
+ }
+ }
+
+ return ret;
+}
+
+/*
+ * Register suites and tests with CUnit.
+ *
+ * Similar to CU_register_suites() but using locally defined wrapper
+ * types.
+ */
+static int cunit_register_suites(odp_suiteinfo_t testsuites[])
+{
+ odp_suiteinfo_t *sinfo;
+ odp_testinfo_t *tinfo;
+ CU_pSuite suite;
+ CU_pTest test;
+
+ for (sinfo = testsuites; sinfo->pName; sinfo++) {
+ suite = CU_add_suite(sinfo->pName,
+ _cunit_suite_init, sinfo->pCleanupFunc);
+ if (!suite)
+ return CU_get_error();
+
+ for (tinfo = sinfo->pTests; tinfo->testinfo.pName; tinfo++) {
+ test = CU_add_test(suite, tinfo->testinfo.pName,
+ tinfo->testinfo.pTestFunc);
+ if (!test)
+ return CU_get_error();
+ }
+ }
+
+ return 0;
+}
+
+static int cunit_update_test(CU_pSuite suite,
+ odp_suiteinfo_t *sinfo,
+ odp_testinfo_t *updated_tinfo)
+{
+ CU_pTest test = NULL;
+ CU_ErrorCode err;
+ odp_testinfo_t *tinfo;
+ const char *test_name = updated_tinfo->testinfo.pName;
+
+ tinfo = cunit_get_test_info(sinfo, test_name);
+ if (tinfo)
+ test = CU_get_test(suite, test_name);
+
+ if (!tinfo || !test) {
+ fprintf(stderr, "%s: unable to find existing test named %s\n",
+ __func__, test_name);
+ return -1;
+ }
+
+ err = CU_set_test_func(test, updated_tinfo->testinfo.pTestFunc);
+ if (err != CUE_SUCCESS) {
+ fprintf(stderr, "%s: failed to update test func for %s\n",
+ __func__, test_name);
+ return -1;
+ }
+
+ tinfo->check_active = updated_tinfo->check_active;
+
+ return 0;
+}
+
+static int cunit_update_suite(odp_suiteinfo_t *updated_sinfo)
+{
+ CU_pSuite suite = NULL;
+ CU_ErrorCode err;
+ odp_suiteinfo_t *sinfo;
+ odp_testinfo_t *tinfo;
+
+ /* find previously registered suite with matching name */
+ sinfo = cunit_get_suite_info(updated_sinfo->pName);
+
+ if (sinfo) {
+ /* lookup the associated CUnit suite */
+ suite = CU_get_suite_by_name(updated_sinfo->pName,
+ CU_get_registry());
+ }
+
+ if (!sinfo || !suite) {
+ fprintf(stderr, "%s: unable to find existing suite named %s\n",
+ __func__, updated_sinfo->pName);
+ return -1;
+ }
+
+ sinfo->pInitFunc = updated_sinfo->pInitFunc;
+ sinfo->pCleanupFunc = updated_sinfo->pCleanupFunc;
+
+ err = CU_set_suite_cleanupfunc(suite, updated_sinfo->pCleanupFunc);
+ if (err != CUE_SUCCESS) {
+ fprintf(stderr, "%s: failed to update cleanup func for %s\n",
+ __func__, updated_sinfo->pName);
+ return -1;
+ }
+
+ for (tinfo = updated_sinfo->pTests; tinfo->testinfo.pName; tinfo++) {
+ int ret;
+
+ ret = cunit_update_test(suite, sinfo, tinfo);
+ if (ret != 0)
+ return ret;
+ }
+
+ return 0;
+}
+
+/*
+ * Run tests previously registered via odp_cunit_register()
+ */
+int odp_cunit_run(void)
+{
+ int ret;
+
+ printf("\tODP API version: %s\n", odp_version_api_str());
+ printf("\tODP implementation version: %s\n", odp_version_impl_str());
- CU_initialize_registry();
- CU_register_suites(testsuites);
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
@@ -120,3 +296,41 @@ int odp_cunit_run(CU_SuiteInfo testsuites[])
return (ret) ? -1 : 0;
}
+
+/*
+ * Update suites/tests previously registered via odp_cunit_register().
+ *
+ * Note that this is intended for modifying the properties of already
+ * registered suites/tests. New suites/tests can only be registered via
+ * odp_cunit_register().
+ */
+int odp_cunit_update(odp_suiteinfo_t testsuites[])
+{
+ int ret = 0;
+ odp_suiteinfo_t *sinfo;
+
+ for (sinfo = testsuites; sinfo->pName && ret == 0; sinfo++)
+ ret = cunit_update_suite(sinfo);
+
+ return ret;
+}
+
+/*
+ * Register test suites to be run via odp_cunit_run()
+ */
+int odp_cunit_register(odp_suiteinfo_t testsuites[])
+{
+ /* 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);
+
+ CU_initialize_registry();
+ global_testsuites = testsuites;
+ cunit_register_suites(testsuites);
+ CU_set_fail_on_inactive(CU_FALSE);
+
+ return 0;
+}
diff --git a/test/validation/common/odp_cunit_common.h b/test/validation/common/odp_cunit_common.h
index 6cafaaaa7..c68905466 100644
--- a/test/validation/common/odp_cunit_common.h
+++ b/test/validation/common/odp_cunit_common.h
@@ -15,14 +15,45 @@
#include <stdint.h>
#include "CUnit/Basic.h"
+#include "CUnit/TestDB.h"
#define MAX_WORKERS 32 /**< Maximum number of work threads */
-/* the function, called by module main(), to run the testsuites: */
-int odp_cunit_run(CU_SuiteInfo testsuites[]);
+typedef int (*cunit_test_check_active)(void);
-/* the macro used to have test names (strings) matching function symbols */
-#define _CU_TEST_INFO(test_func) {#test_func, test_func}
+typedef struct {
+ CU_TestInfo testinfo;
+ cunit_test_check_active check_active;
+} odp_testinfo_t;
+
+typedef struct {
+ const char *pName;
+ CU_InitializeFunc pInitFunc;
+ CU_CleanupFunc pCleanupFunc;
+ odp_testinfo_t *pTests;
+} odp_suiteinfo_t;
+
+static inline int odp_cunit_test_inactive(void) { return 0; }
+static inline void odp_cunit_test_missing(void) { }
+
+/* An active test case, with the test name matching the test function name */
+#define ODP_TEST_INFO(test_func) \
+ {{#test_func, test_func}, NULL}
+
+/* A test case that is unconditionally inactive. Its name will be registered
+ * with CUnit but it won't be executed and will be reported as inactive in
+ * the result summary. */
+#define ODP_TEST_INFO_INACTIVE(test_func) \
+ {{#test_func, odp_cunit_test_missing}, odp_cunit_test_inactive}
+
+/* A test case that may be marked as inactive at runtime based on the
+ * return value of the cond_func function. A return value of 0 means
+ * inactive, anything else is active. */
+#define ODP_TEST_INFO_CONDITIONAL(test_func, cond_func) \
+ {{#test_func, test_func}, cond_func}
+
+#define ODP_TEST_INFO_NULL {CU_TEST_INFO_NULL, NULL}
+#define ODP_SUITE_INFO_NULL {NULL, NULL, NULL, NULL}
typedef struct {
uint32_t foo;
@@ -37,9 +68,16 @@ typedef struct {
int numthrds; /**< no of pthreads to create */
} pthrd_arg;
+/* register suites to be run via odp_cunit_run() */
+int odp_cunit_register(odp_suiteinfo_t testsuites[]);
+/* update tests previously registered via odp_cunit_register() */
+int odp_cunit_update(odp_suiteinfo_t testsuites[]);
+/* the function, called by module main(), to run the testsuites: */
+int odp_cunit_run(void);
+
/** 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 *);
+int odp_cunit_thread_create(void *func_ptr(void *), pthrd_arg *arg);
+int odp_cunit_thread_exit(pthrd_arg *);
/**
* Global tests initialization/termination.
diff --git a/test/validation/config/config.c b/test/validation/config/config.c
index a54d51ec0..f957150cf 100644
--- a/test/validation/config/config.c
+++ b/test/validation/config/config.c
@@ -40,21 +40,23 @@ void config_test(void)
CU_ASSERT(odp_config_shm_blocks() == ODP_CONFIG_SHM_BLOCKS);
}
-CU_TestInfo config_suite[] = {
- _CU_TEST_INFO(config_test),
- CU_TEST_INFO_NULL,
+odp_testinfo_t config_suite[] = {
+ ODP_TEST_INFO(config_test),
+ ODP_TEST_INFO_NULL,
};
-CU_SuiteInfo config_suites[] = {
- { .pName = "config tests",
- .pTests = config_suite,
- .pInitFunc = config_suite_init,
- .pCleanupFunc = config_suite_term,
- },
- CU_SUITE_INFO_NULL,
+odp_suiteinfo_t config_suites[] = {
+ {"config tests", config_suite_init,config_suite_term,
+ config_suite},
+ ODP_SUITE_INFO_NULL,
};
int config_main(void)
{
- return odp_cunit_run(config_suites);
+ int ret = odp_cunit_register(config_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/config/config.h b/test/validation/config/config.h
index 95c1631da..55cb5399c 100644
--- a/test/validation/config/config.h
+++ b/test/validation/config/config.h
@@ -7,20 +7,20 @@
#ifndef _ODP_TEST_CONFIG_H_
#define _ODP_TEST_CONFIG_H_
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
void config_test(void);
/* test arrays: */
-extern CU_TestInfo config_suite[];
+extern odp_testinfo_t config_suite[];
/* test array init/term functions: */
int config_suite_init(void);
int config_suite_term(void);
/* test registry: */
-extern CU_SuiteInfo config_suites[];
+extern odp_suiteinfo_t config_suites[];
/* main test program: */
int config_main(void);
diff --git a/test/validation/cpumask/cpumask.c b/test/validation/cpumask/cpumask.c
index d09744a0f..2419f47dc 100644
--- a/test/validation/cpumask/cpumask.c
+++ b/test/validation/cpumask/cpumask.c
@@ -72,34 +72,39 @@ void cpumask_test_odp_cpumask_def(void)
CU_ASSERT(num_worker > 0);
}
-CU_TestInfo cpumask_suite[] = {
- _CU_TEST_INFO(cpumask_test_odp_cpumask_to_from_str),
- _CU_TEST_INFO(cpumask_test_odp_cpumask_equal),
- _CU_TEST_INFO(cpumask_test_odp_cpumask_zero),
- _CU_TEST_INFO(cpumask_test_odp_cpumask_set),
- _CU_TEST_INFO(cpumask_test_odp_cpumask_clr),
- _CU_TEST_INFO(cpumask_test_odp_cpumask_isset),
- _CU_TEST_INFO(cpumask_test_odp_cpumask_count),
- _CU_TEST_INFO(cpumask_test_odp_cpumask_and),
- _CU_TEST_INFO(cpumask_test_odp_cpumask_or),
- _CU_TEST_INFO(cpumask_test_odp_cpumask_xor),
- _CU_TEST_INFO(cpumask_test_odp_cpumask_copy),
- _CU_TEST_INFO(cpumask_test_odp_cpumask_first),
- _CU_TEST_INFO(cpumask_test_odp_cpumask_last),
- _CU_TEST_INFO(cpumask_test_odp_cpumask_next),
- _CU_TEST_INFO(cpumask_test_odp_cpumask_setall),
- _CU_TEST_INFO(cpumask_test_odp_cpumask_def_control),
- _CU_TEST_INFO(cpumask_test_odp_cpumask_def_worker),
- _CU_TEST_INFO(cpumask_test_odp_cpumask_def),
- CU_TEST_INFO_NULL,
+odp_testinfo_t cpumask_suite[] = {
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_to_from_str),
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_equal),
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_zero),
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_set),
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_clr),
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_isset),
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_count),
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_and),
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_or),
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_xor),
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_copy),
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_first),
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_last),
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_next),
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_setall),
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_def_control),
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_def_worker),
+ ODP_TEST_INFO(cpumask_test_odp_cpumask_def),
+ ODP_TEST_INFO_NULL,
};
-CU_SuiteInfo cpumask_suites[] = {
- {"Cpumask", NULL, NULL, NULL, NULL, cpumask_suite},
- CU_SUITE_INFO_NULL,
+odp_suiteinfo_t cpumask_suites[] = {
+ {"Cpumask", NULL, NULL, cpumask_suite},
+ ODP_SUITE_INFO_NULL,
};
int cpumask_main(void)
{
- return odp_cunit_run(cpumask_suites);
+ int ret = odp_cunit_register(cpumask_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/cpumask/cpumask.h b/test/validation/cpumask/cpumask.h
index 7a58b5d0e..c6f9cde9d 100644
--- a/test/validation/cpumask/cpumask.h
+++ b/test/validation/cpumask/cpumask.h
@@ -8,7 +8,7 @@
#define _ODP_TEST_CPUMASK_H_
#include <odp.h>
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
#include "mask_common.h"
@@ -17,10 +17,10 @@ void cpumask_test_odp_cpumask_def_worker(void);
void cpumask_test_odp_cpumask_def(void);
/* test arrays: */
-extern CU_TestInfo cpumask_suite[];
+extern odp_testinfo_t cpumask_suite[];
/* test registry: */
-extern CU_SuiteInfo cpumask_suites[];
+extern odp_suiteinfo_t cpumask_suites[];
/* main test program: */
int cpumask_main(void);
diff --git a/test/validation/crypto/crypto.c b/test/validation/crypto/crypto.c
index cad660163..9229cab95 100644
--- a/test/validation/crypto/crypto.c
+++ b/test/validation/crypto/crypto.c
@@ -5,7 +5,7 @@
*/
#include <odp.h>
-#include "odp_cunit_common.h"
+#include <odp_cunit_common.h>
#include "odp_crypto_test_inp.h"
#include "crypto.h"
@@ -15,12 +15,10 @@
#define SHM_COMPL_POOL_SIZE (128 * 1024)
#define SHM_COMPL_POOL_BUF_SIZE 128
-CU_SuiteInfo crypto_suites[] = {
- {ODP_CRYPTO_SYNC_INP, crypto_suite_sync_init, NULL, NULL, NULL,
- crypto_suite},
- {ODP_CRYPTO_ASYNC_INP, crypto_suite_async_init, NULL, NULL, NULL,
- crypto_suite},
- CU_SUITE_INFO_NULL,
+odp_suiteinfo_t crypto_suites[] = {
+ {ODP_CRYPTO_SYNC_INP, crypto_suite_sync_init, NULL, crypto_suite},
+ {ODP_CRYPTO_ASYNC_INP, crypto_suite_async_init, NULL, crypto_suite},
+ ODP_SUITE_INFO_NULL,
};
int crypto_init(void)
@@ -96,7 +94,15 @@ int crypto_term(void)
int crypto_main(void)
{
+ int ret;
+
odp_cunit_register_global_init(crypto_init);
odp_cunit_register_global_term(crypto_term);
- return odp_cunit_run(crypto_suites);
+
+ ret = odp_cunit_register(crypto_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/crypto/crypto.h b/test/validation/crypto/crypto.h
index 41dd4ed7d..7cb60d4a7 100644
--- a/test/validation/crypto/crypto.h
+++ b/test/validation/crypto/crypto.h
@@ -7,7 +7,7 @@
#ifndef _ODP_TEST_CRYPTO_H_
#define _ODP_TEST_CRYPTO_H_
-#include <CUnit/Basic.h>
+#include "odp_cunit_common.h"
/* test functions: */
void crypto_test_enc_alg_3des_cbc(void);
@@ -17,14 +17,14 @@ void crypto_test_dec_alg_3des_cbc_ovr_iv(void);
void crypto_test_alg_hmac_md5(void);
/* test arrays: */
-extern CU_TestInfo crypto_suite[];
+extern odp_testinfo_t crypto_suite[];
/* test array init/term functions: */
int crypto_suite_sync_init(void);
int crypto_suite_async_init(void);
/* test registry: */
-extern CU_SuiteInfo crypto_suites[];
+extern odp_suiteinfo_t crypto_suites[];
/* executable init/term functions: */
int crypto_init(void);
diff --git a/test/validation/crypto/odp_crypto_test_inp.c b/test/validation/crypto/odp_crypto_test_inp.c
index 187a04c28..69325a4a7 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -319,11 +319,11 @@ int crypto_suite_async_init(void)
return 0;
}
-CU_TestInfo crypto_suite[] = {
- _CU_TEST_INFO(crypto_test_enc_alg_3des_cbc),
- _CU_TEST_INFO(crypto_test_dec_alg_3des_cbc),
- _CU_TEST_INFO(crypto_test_enc_alg_3des_cbc_ovr_iv),
- _CU_TEST_INFO(crypto_test_dec_alg_3des_cbc_ovr_iv),
- _CU_TEST_INFO(crypto_test_alg_hmac_md5),
- CU_TEST_INFO_NULL,
+odp_testinfo_t crypto_suite[] = {
+ ODP_TEST_INFO(crypto_test_enc_alg_3des_cbc),
+ ODP_TEST_INFO(crypto_test_dec_alg_3des_cbc),
+ ODP_TEST_INFO(crypto_test_enc_alg_3des_cbc_ovr_iv),
+ ODP_TEST_INFO(crypto_test_dec_alg_3des_cbc_ovr_iv),
+ ODP_TEST_INFO(crypto_test_alg_hmac_md5),
+ ODP_TEST_INFO_NULL,
};
diff --git a/test/validation/crypto/odp_crypto_test_inp.h b/test/validation/crypto/odp_crypto_test_inp.h
index d46994fb7..8bda34472 100644
--- a/test/validation/crypto/odp_crypto_test_inp.h
+++ b/test/validation/crypto/odp_crypto_test_inp.h
@@ -6,14 +6,14 @@
#ifndef ODP_CRYPTO_TEST_ASYNC_INP_
#define ODP_CRYPTO_TEST_ASYNC_INP_
-#include "CUnit/TestDB.h"
+#include <odp_cunit_common.h>
/* Suite names */
#define ODP_CRYPTO_ASYNC_INP "odp_crypto_async_inp"
#define ODP_CRYPTO_SYNC_INP "odp_crypto_sync_inp"
/* Suite test array */
-extern CU_TestInfo crypto_suite[];
+extern odp_testinfo_t crypto_suite[];
int crypto_suite_sync_init(void);
int crypto_suite_async_init(void);
diff --git a/test/validation/errno/errno.c b/test/validation/errno/errno.c
index c4f4aabee..d0e2128c6 100644
--- a/test/validation/errno/errno.c
+++ b/test/validation/errno/errno.c
@@ -19,17 +19,22 @@ void errno_test_odp_errno_sunny_day(void)
CU_ASSERT_PTR_NOT_NULL(odp_errno_str(my_errno));
}
-CU_TestInfo errno_suite[] = {
- _CU_TEST_INFO(errno_test_odp_errno_sunny_day),
- CU_TEST_INFO_NULL,
+odp_testinfo_t errno_suite[] = {
+ ODP_TEST_INFO(errno_test_odp_errno_sunny_day),
+ ODP_TEST_INFO_NULL,
};
-CU_SuiteInfo errno_suites[] = {
- {"Errno", NULL, NULL, NULL, NULL, errno_suite},
- CU_SUITE_INFO_NULL,
+odp_suiteinfo_t errno_suites[] = {
+ {"Errno", NULL, NULL, errno_suite},
+ ODP_SUITE_INFO_NULL,
};
int errno_main(void)
{
- return odp_cunit_run(errno_suites);
+ int ret = odp_cunit_register(errno_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/errno/errno.h b/test/validation/errno/errno.h
index 374a3c96a..3e217b5d4 100644
--- a/test/validation/errno/errno.h
+++ b/test/validation/errno/errno.h
@@ -7,16 +7,16 @@
#ifndef _ODP_TEST_ERRNO_H_
#define _ODP_TEST_ERRNO_H_
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
void errno_test_odp_errno_sunny_day(void);
/* test arrays: */
-extern CU_TestInfo errno_suite[];
+extern odp_testinfo_t errno_suite[];
/* test registry: */
-extern CU_SuiteInfo errno_suites[];
+extern odp_suiteinfo_t errno_suites[];
/* main test program: */
int errno_main(void);
diff --git a/test/validation/hash/hash.c b/test/validation/hash/hash.c
index d2dfbf231..11b331e28 100644
--- a/test/validation/hash/hash.c
+++ b/test/validation/hash/hash.c
@@ -27,17 +27,23 @@ void hash_test_crc32c(void)
CU_ASSERT(ret == 0xe6e910b0);
}
-CU_TestInfo hash_suite[] = {
- _CU_TEST_INFO(hash_test_crc32c),
- CU_TEST_INFO_NULL,
+odp_testinfo_t hash_suite[] = {
+ ODP_TEST_INFO(hash_test_crc32c),
+ ODP_TEST_INFO_NULL,
};
-CU_SuiteInfo hash_suites[] = {
- {"Hash", NULL, NULL, NULL, NULL, hash_suite},
- CU_SUITE_INFO_NULL,
+odp_suiteinfo_t hash_suites[] = {
+ {"Hash", NULL, NULL, hash_suite},
+ ODP_SUITE_INFO_NULL
};
int hash_main(void)
{
- return odp_cunit_run(hash_suites);
+ int ret = odp_cunit_register(hash_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
+
}
diff --git a/test/validation/hash/hash.h b/test/validation/hash/hash.h
index ea0e444bb..46c74660d 100644
--- a/test/validation/hash/hash.h
+++ b/test/validation/hash/hash.h
@@ -7,16 +7,16 @@
#ifndef _ODP_TEST_HASH_H_
#define _ODP_TEST_HASH_H_
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
void hash_test_crc32c(void);
/* test arrays: */
-extern CU_TestInfo hash_suite[];
+extern odp_testinfo_t hash_suite[];
/* test registry: */
-extern CU_SuiteInfo hash_suites[];
+extern odp_suiteinfo_t hash_suites[];
/* main test program: */
int hash_main(void);
diff --git a/test/validation/hash/hash_main b/test/validation/hash/hash_main
new file mode 100755
index 000000000..e938ffc56
--- /dev/null
+++ b/test/validation/hash/hash_main
Binary files differ
diff --git a/test/validation/init/init.c b/test/validation/init/init.c
index 3a04fc9c8..a8a564063 100644
--- a/test/validation/init/init.c
+++ b/test/validation/init/init.c
@@ -8,7 +8,6 @@
#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 */
@@ -37,14 +36,14 @@ void init_test_odp_init_global_replace_abort(void)
CU_ASSERT(status == 0);
}
-CU_TestInfo init_suite_abort[] = {
- _CU_TEST_INFO(init_test_odp_init_global_replace_abort),
- CU_TEST_INFO_NULL,
+odp_testinfo_t init_suite_abort[] = {
+ ODP_TEST_INFO(init_test_odp_init_global_replace_abort),
+ ODP_TEST_INFO_NULL,
};
-CU_SuiteInfo init_suites_abort[] = {
- {"Init", NULL, NULL, NULL, NULL, init_suite_abort},
- CU_SUITE_INFO_NULL,
+odp_suiteinfo_t init_suites_abort[] = {
+ {"Init", NULL, NULL, init_suite_abort},
+ ODP_SUITE_INFO_NULL,
};
static void odp_init_abort(void)
@@ -54,12 +53,19 @@ static void odp_init_abort(void)
int init_main_abort(void)
{
+ int ret;
+
/* 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);
+ ret = odp_cunit_register(init_suites_abort);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
/* test ODP global init, with alternate log function */
@@ -82,14 +88,14 @@ void init_test_odp_init_global_replace_log(void)
CU_ASSERT(status == 0);
}
-CU_TestInfo init_suite_log[] = {
- _CU_TEST_INFO(init_test_odp_init_global_replace_log),
- CU_TEST_INFO_NULL,
+odp_testinfo_t init_suite_log[] = {
+ ODP_TEST_INFO(init_test_odp_init_global_replace_log),
+ ODP_TEST_INFO_NULL,
};
-CU_SuiteInfo init_suites_log[] = {
- {"Init", NULL, NULL, NULL, NULL, init_suite_log},
- CU_SUITE_INFO_NULL,
+odp_suiteinfo_t init_suites_log[] = {
+ {"Init", NULL, NULL, init_suite_log},
+ ODP_SUITE_INFO_NULL,
};
static int odp_init_log(odp_log_level_e level __attribute__((unused)),
@@ -110,12 +116,20 @@ static int odp_init_log(odp_log_level_e level __attribute__((unused)),
int init_main_log(void)
{
+ int ret;
+
/* prevent default ODP init: */
odp_cunit_register_global_init(NULL);
odp_cunit_register_global_term(NULL);
+ /* register the tests: */
+ ret = odp_cunit_register(init_suites_log);
+
/* run the tests: */
- return odp_cunit_run(init_suites_log);
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
/* test normal ODP global init */
@@ -130,22 +144,30 @@ void init_test_odp_init_global(void)
CU_ASSERT(status == 0);
}
-CU_TestInfo init_suite_ok[] = {
- _CU_TEST_INFO(init_test_odp_init_global),
- CU_TEST_INFO_NULL,
+odp_testinfo_t init_suite_ok[] = {
+ ODP_TEST_INFO(init_test_odp_init_global),
+ ODP_TEST_INFO_NULL,
};
-CU_SuiteInfo init_suites_ok[] = {
- {"Init", NULL, NULL, NULL, NULL, init_suite_ok},
- CU_SUITE_INFO_NULL,
+odp_suiteinfo_t init_suites_ok[] = {
+ {"Init", NULL, NULL, init_suite_ok},
+ ODP_SUITE_INFO_NULL,
};
int init_main_ok(void)
{
+ int ret;
+
/* prevent default ODP init: */
odp_cunit_register_global_init(NULL);
odp_cunit_register_global_term(NULL);
+ /* register the tests: */
+ ret = odp_cunit_register(init_suites_ok);
+
/* run the tests: */
- return odp_cunit_run(init_suites_ok);
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/init/init.h b/test/validation/init/init.h
index 08f09e55c..272d42652 100644
--- a/test/validation/init/init.h
+++ b/test/validation/init/init.h
@@ -7,7 +7,7 @@
#ifndef _ODP_TEST_INIT_H_
#define _ODP_TEST_INIT_H_
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
void init_test_odp_init_global_replace_abort(void);
@@ -15,14 +15,14 @@ void init_test_odp_init_global_replace_log(void);
void init_test_odp_init_global(void);
/* test arrays: */
-extern CU_TestInfo init_suite_abort[];
-extern CU_TestInfo init_suite_log[];
-extern CU_TestInfo init_suite_ok[];
+extern odp_testinfo_t init_suite_abort[];
+extern odp_testinfo_t init_suite_log[];
+extern odp_testinfo_t init_suite_ok[];
/* test registry: */
-extern CU_SuiteInfo init_suites_abort[];
-extern CU_SuiteInfo init_suites_log[];
-extern CU_SuiteInfo init_suites_ok[];
+extern odp_suiteinfo_t init_suites_abort[];
+extern odp_suiteinfo_t init_suites_log[];
+extern odp_suiteinfo_t init_suites_ok[];
/* main test program: */
int init_main_abort(void);
diff --git a/test/validation/packet/packet.c b/test/validation/packet/packet.c
index 0c749c377..1694293ce 100644
--- a/test/validation/packet/packet.c
+++ b/test/validation/packet/packet.c
@@ -7,7 +7,7 @@
#include <stdlib.h>
#include <odp.h>
-#include "odp_cunit_common.h"
+#include <odp_cunit_common.h>
#include "packet.h"
#define PACKET_BUF_LEN ODP_CONFIG_PACKET_SEG_LEN_MIN
@@ -778,38 +778,43 @@ void packet_test_offset(void)
CU_ASSERT_PTR_NOT_NULL(ptr);
}
-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,
+odp_testinfo_t packet_suite[] = {
+ ODP_TEST_INFO(packet_test_alloc_free),
+ ODP_TEST_INFO(packet_test_alloc_segmented),
+ ODP_TEST_INFO(packet_test_basic_metadata),
+ ODP_TEST_INFO(packet_test_debug),
+ ODP_TEST_INFO(packet_test_length),
+ ODP_TEST_INFO(packet_test_headroom),
+ ODP_TEST_INFO(packet_test_tailroom),
+ ODP_TEST_INFO(packet_test_context),
+ ODP_TEST_INFO(packet_test_event_conversion),
+ ODP_TEST_INFO(packet_test_layer_offsets),
+ ODP_TEST_INFO(packet_test_segments),
+ ODP_TEST_INFO(packet_test_segment_last),
+ ODP_TEST_INFO(packet_test_in_flags),
+ ODP_TEST_INFO(packet_test_error_flags),
+ ODP_TEST_INFO(packet_test_add_rem_data),
+ ODP_TEST_INFO(packet_test_copy),
+ ODP_TEST_INFO(packet_test_copydata),
+ ODP_TEST_INFO(packet_test_offset),
+ ODP_TEST_INFO_NULL,
};
-CU_SuiteInfo packet_suites[] = {
+odp_suiteinfo_t packet_suites[] = {
{ .pName = "packet tests",
.pTests = packet_suite,
.pInitFunc = packet_suite_init,
.pCleanupFunc = packet_suite_term,
},
- CU_SUITE_INFO_NULL,
+ ODP_SUITE_INFO_NULL,
};
int packet_main(void)
{
- return odp_cunit_run(packet_suites);
+ int ret = odp_cunit_register(packet_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/packet/packet.h b/test/validation/packet/packet.h
index f8a16a8e2..096a1e2b1 100644
--- a/test/validation/packet/packet.h
+++ b/test/validation/packet/packet.h
@@ -7,7 +7,7 @@
#ifndef _ODP_TEST_PACKET_H_
#define _ODP_TEST_PACKET_H_
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
void packet_test_alloc_free(void);
@@ -30,14 +30,14 @@ void packet_test_copydata(void);
void packet_test_offset(void);
/* test arrays: */
-extern CU_TestInfo packet_suite[];
+extern odp_testinfo_t packet_suite[];
/* test array init/term functions: */
int packet_suite_init(void);
int packet_suite_term(void);
/* test registry: */
-extern CU_SuiteInfo packet_suites[];
+extern odp_suiteinfo_t packet_suites[];
/* main test program: */
int packet_main(void);
diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index 26ff4cd42..a746b9aab 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -520,7 +520,9 @@ void pktio_test_mtu(void)
{
int ret;
int mtu;
+
odp_pktio_t pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0);
+ CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
mtu = odp_pktio_mtu(pktio);
CU_ASSERT(mtu > 0);
@@ -534,7 +536,9 @@ void pktio_test_mtu(void)
void pktio_test_promisc(void)
{
int ret;
+
odp_pktio_t pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0);
+ CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
ret = odp_pktio_promisc_mode_set(pktio, 1);
CU_ASSERT(0 == ret);
@@ -562,6 +566,7 @@ void pktio_test_mac(void)
odp_pktio_t pktio;
pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0);
+ CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
printf("testing mac for %s\n", iface_name[0]);
@@ -589,7 +594,7 @@ void pktio_test_inq_remdef(void)
int i;
pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0);
- CU_ASSERT(pktio != ODP_PKTIO_INVALID);
+ CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
CU_ASSERT(create_inq(pktio, ODP_QUEUE_TYPE_POLL) == 0);
inq = odp_pktio_inq_getdef(pktio);
CU_ASSERT(inq != ODP_QUEUE_INVALID);
@@ -617,7 +622,7 @@ void pktio_test_open(void)
/* test the sequence open->close->open->close() */
for (i = 0; i < 2; ++i) {
pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0);
- CU_ASSERT(pktio != ODP_PKTIO_INVALID);
+ CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
CU_ASSERT(odp_pktio_close(pktio) == 0);
}
@@ -656,7 +661,7 @@ void pktio_test_inq(void)
odp_pktio_t pktio;
pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0);
- CU_ASSERT(pktio != ODP_PKTIO_INVALID);
+ CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
CU_ASSERT(create_inq(pktio, ODP_QUEUE_TYPE_POLL) == 0);
CU_ASSERT(destroy_inq(pktio) == 0);
@@ -675,7 +680,7 @@ static void pktio_test_start_stop(void)
for (i = 0; i < num_ifaces; i++) {
pktio[i] = create_pktio(iface_name[i], ODP_QUEUE_TYPE_SCHED, 0);
- CU_ASSERT(pktio[i] != ODP_PKTIO_INVALID);
+ CU_ASSERT_FATAL(pktio[i] != ODP_PKTIO_INVALID);
create_inq(pktio[i], ODP_QUEUE_TYPE_SCHED);
}
@@ -790,7 +795,8 @@ static int create_pool(const char *iface, int num)
pool[num] = odp_pool_create(pool_name, &params);
if (ODP_POOL_INVALID == pool[num]) {
- CU_FAIL("unable to create pool");
+ fprintf(stderr, "%s: failed to create pool: %d",
+ __func__, odp_errno());
return -1;
}
@@ -871,41 +877,46 @@ int pktio_suite_term(void)
return ret;
}
-CU_TestInfo pktio_suite_unsegmented[] = {
- _CU_TEST_INFO(pktio_test_open),
- _CU_TEST_INFO(pktio_test_lookup),
- _CU_TEST_INFO(pktio_test_inq),
- _CU_TEST_INFO(pktio_test_poll_queue),
- _CU_TEST_INFO(pktio_test_poll_multi),
- _CU_TEST_INFO(pktio_test_sched_queue),
- _CU_TEST_INFO(pktio_test_sched_multi),
- _CU_TEST_INFO(pktio_test_jumbo),
- _CU_TEST_INFO(pktio_test_mtu),
- _CU_TEST_INFO(pktio_test_promisc),
- _CU_TEST_INFO(pktio_test_mac),
- _CU_TEST_INFO(pktio_test_inq_remdef),
- _CU_TEST_INFO(pktio_test_start_stop),
- CU_TEST_INFO_NULL
+odp_testinfo_t pktio_suite_unsegmented[] = {
+ ODP_TEST_INFO(pktio_test_open),
+ ODP_TEST_INFO(pktio_test_lookup),
+ ODP_TEST_INFO(pktio_test_inq),
+ ODP_TEST_INFO(pktio_test_poll_queue),
+ ODP_TEST_INFO(pktio_test_poll_multi),
+ ODP_TEST_INFO(pktio_test_sched_queue),
+ ODP_TEST_INFO(pktio_test_sched_multi),
+ ODP_TEST_INFO(pktio_test_jumbo),
+ ODP_TEST_INFO(pktio_test_mtu),
+ ODP_TEST_INFO(pktio_test_promisc),
+ ODP_TEST_INFO(pktio_test_mac),
+ ODP_TEST_INFO(pktio_test_inq_remdef),
+ ODP_TEST_INFO(pktio_test_start_stop),
+ ODP_TEST_INFO_NULL
};
-CU_TestInfo pktio_suite_segmented[] = {
- {"pktio poll queues", pktio_test_poll_queue},
- {"pktio poll multi", pktio_test_poll_multi},
- {"pktio sched queues", pktio_test_sched_queue},
- {"pktio sched multi", pktio_test_sched_multi},
- {"pktio jumbo frames", pktio_test_jumbo},
- CU_TEST_INFO_NULL
+odp_testinfo_t pktio_suite_segmented[] = {
+ ODP_TEST_INFO(pktio_test_poll_queue),
+ ODP_TEST_INFO(pktio_test_poll_multi),
+ ODP_TEST_INFO(pktio_test_sched_queue),
+ ODP_TEST_INFO(pktio_test_sched_multi),
+ ODP_TEST_INFO(pktio_test_jumbo),
+ ODP_TEST_INFO_NULL
};
-CU_SuiteInfo pktio_suites[] = {
+odp_suiteinfo_t pktio_suites[] = {
{"Packet I/O Unsegmented", pktio_suite_init_unsegmented,
- pktio_suite_term, NULL, NULL, pktio_suite_unsegmented},
+ pktio_suite_term, pktio_suite_unsegmented},
{"Packet I/O Segmented", pktio_suite_init_segmented,
- pktio_suite_term, NULL, NULL, pktio_suite_segmented},
- CU_SUITE_INFO_NULL
+ pktio_suite_term, pktio_suite_segmented},
+ ODP_SUITE_INFO_NULL
};
int pktio_main(void)
{
- return odp_cunit_run(pktio_suites);
+ int ret = odp_cunit_register(pktio_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/pktio/pktio.h b/test/validation/pktio/pktio.h
index feaf7fb70..2928dbe2b 100644
--- a/test/validation/pktio/pktio.h
+++ b/test/validation/pktio/pktio.h
@@ -7,7 +7,7 @@
#ifndef _ODP_TEST_PKTIO_H_
#define _ODP_TEST_PKTIO_H_
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
void pktio_test_poll_queue(void);
@@ -24,7 +24,7 @@ void pktio_test_lookup(void);
void pktio_test_inq(void);
/* test arrays: */
-extern CU_TestInfo pktio_suite[];
+extern odp_testinfo_t pktio_suite[];
/* test array init/term functions: */
int pktio_suite_term(void);
@@ -32,7 +32,7 @@ int pktio_suite_init_segmented(void);
int pktio_suite_init_unsegmented(void);
/* test registry: */
-extern CU_SuiteInfo pktio_suites[];
+extern odp_suiteinfo_t pktio_suites[];
/* main test program: */
int pktio_main(void);
diff --git a/test/validation/pool/pool.c b/test/validation/pool/pool.c
index 44ba155c6..bca210aa4 100644
--- a/test/validation/pool/pool.c
+++ b/test/validation/pool/pool.c
@@ -99,22 +99,27 @@ void pool_test_lookup_info_print(void)
CU_ASSERT(odp_pool_destroy(pool) == 0);
}
-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,
+odp_testinfo_t pool_suite[] = {
+ ODP_TEST_INFO(pool_test_create_destroy_buffer),
+ ODP_TEST_INFO(pool_test_create_destroy_packet),
+ ODP_TEST_INFO(pool_test_create_destroy_timeout),
+ ODP_TEST_INFO(pool_test_lookup_info_print),
+ ODP_TEST_INFO_NULL,
};
-CU_SuiteInfo pool_suites[] = {
+odp_suiteinfo_t pool_suites[] = {
{ .pName = "Pool tests",
.pTests = pool_suite,
},
- CU_SUITE_INFO_NULL,
+ ODP_SUITE_INFO_NULL,
};
int pool_main(void)
{
- return odp_cunit_run(pool_suites);
+ int ret = odp_cunit_register(pool_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/pool/pool.h b/test/validation/pool/pool.h
index 12c6193d8..6a83a2e72 100644
--- a/test/validation/pool/pool.h
+++ b/test/validation/pool/pool.h
@@ -7,7 +7,7 @@
#ifndef _ODP_TEST_POOL_H_
#define _ODP_TEST_POOL_H_
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
void pool_test_create_destroy_buffer(void);
@@ -17,10 +17,10 @@ void pool_test_create_destroy_buffer_shm(void);
void pool_test_lookup_info_print(void);
/* test arrays: */
-extern CU_TestInfo pool_suite[];
+extern odp_testinfo_t pool_suite[];
/* test registry: */
-extern CU_SuiteInfo pool_suites[];
+extern odp_suiteinfo_t pool_suites[];
/* main test program: */
int pool_main(void);
diff --git a/test/validation/queue/queue.c b/test/validation/queue/queue.c
index 02a553817..98da2ec0c 100644
--- a/test/validation/queue/queue.c
+++ b/test/validation/queue/queue.c
@@ -125,18 +125,22 @@ void queue_test_sunnydays(void)
CU_ASSERT(odp_queue_destroy(queue_id) == 0);
}
-CU_TestInfo queue_suite[] = {
- _CU_TEST_INFO(queue_test_sunnydays),
- CU_TEST_INFO_NULL,
+odp_testinfo_t queue_suite[] = {
+ ODP_TEST_INFO(queue_test_sunnydays),
+ ODP_TEST_INFO_NULL,
};
-CU_SuiteInfo queue_suites[] = {
- {"Queue", queue_suite_init, queue_suite_term,
- NULL, NULL, queue_suite},
- CU_SUITE_INFO_NULL,
+odp_suiteinfo_t queue_suites[] = {
+ {"Queue", queue_suite_init, queue_suite_term, queue_suite},
+ ODP_SUITE_INFO_NULL,
};
int queue_main(void)
{
- return odp_cunit_run(queue_suites);
+ int ret = odp_cunit_register(queue_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/queue/queue.h b/test/validation/queue/queue.h
index d2765ce46..5de7b2c23 100644
--- a/test/validation/queue/queue.h
+++ b/test/validation/queue/queue.h
@@ -7,20 +7,20 @@
#ifndef _ODP_TEST_QUEUE_H_
#define _ODP_TEST_QUEUE_H_
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
void queue_test_sunnydays(void);
/* test arrays: */
-extern CU_TestInfo queue_suite[];
+extern odp_testinfo_t queue_suite[];
/* test array init/term functions: */
int queue_suite_init(void);
int queue_suite_term(void);
/* test registry: */
-extern CU_SuiteInfo queue_suites[];
+extern odp_suiteinfo_t queue_suites[];
/* main test program: */
int queue_main(void);
diff --git a/test/validation/random/random.c b/test/validation/random/random.c
index b6426f4c0..8ed594420 100644
--- a/test/validation/random/random.c
+++ b/test/validation/random/random.c
@@ -17,17 +17,22 @@ void random_test_get_size(void)
CU_ASSERT(ret == sizeof(buf));
}
-CU_TestInfo random_suite[] = {
- _CU_TEST_INFO(random_test_get_size),
- CU_TEST_INFO_NULL,
+odp_testinfo_t random_suite[] = {
+ ODP_TEST_INFO(random_test_get_size),
+ ODP_TEST_INFO_NULL,
};
-CU_SuiteInfo random_suites[] = {
- {"Random", NULL, NULL, NULL, NULL, random_suite},
- CU_SUITE_INFO_NULL,
+odp_suiteinfo_t random_suites[] = {
+ {"Random", NULL, NULL, random_suite},
+ ODP_SUITE_INFO_NULL,
};
int random_main(void)
{
- return odp_cunit_run(random_suites);
+ int ret = odp_cunit_register(random_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/random/random.h b/test/validation/random/random.h
index cda1843e4..4101ef17d 100644
--- a/test/validation/random/random.h
+++ b/test/validation/random/random.h
@@ -7,16 +7,16 @@
#ifndef _ODP_TEST_RANDOM_H_
#define _ODP_TEST_RANDOM_H_
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
void random_test_get_size(void);
/* test arrays: */
-extern CU_TestInfo random_suite[];
+extern odp_testinfo_t random_suite[];
/* test registry: */
-extern CU_SuiteInfo random_suites[];
+extern odp_suiteinfo_t random_suites[];
/* main test program: */
int random_main(void);
diff --git a/test/validation/scheduler/scheduler.c b/test/validation/scheduler/scheduler.c
index 0c96dc3a3..89c1099c1 100644
--- a/test/validation/scheduler/scheduler.c
+++ b/test/validation/scheduler/scheduler.c
@@ -1130,49 +1130,54 @@ int scheduler_suite_term(void)
return 0;
}
-CU_TestInfo scheduler_suite[] = {
- _CU_TEST_INFO(scheduler_test_wait_time),
- _CU_TEST_INFO(scheduler_test_num_prio),
- _CU_TEST_INFO(scheduler_test_queue_destroy),
- _CU_TEST_INFO(scheduler_test_groups),
- _CU_TEST_INFO(scheduler_test_1q_1t_n),
- _CU_TEST_INFO(scheduler_test_1q_1t_a),
- _CU_TEST_INFO(scheduler_test_1q_1t_o),
- _CU_TEST_INFO(scheduler_test_mq_1t_n),
- _CU_TEST_INFO(scheduler_test_mq_1t_a),
- _CU_TEST_INFO(scheduler_test_mq_1t_o),
- _CU_TEST_INFO(scheduler_test_mq_1t_prio_n),
- _CU_TEST_INFO(scheduler_test_mq_1t_prio_a),
- _CU_TEST_INFO(scheduler_test_mq_1t_prio_o),
- _CU_TEST_INFO(scheduler_test_mq_mt_prio_n),
- _CU_TEST_INFO(scheduler_test_mq_mt_prio_a),
- _CU_TEST_INFO(scheduler_test_mq_mt_prio_o),
- _CU_TEST_INFO(scheduler_test_1q_mt_a_excl),
- _CU_TEST_INFO(scheduler_test_multi_1q_1t_n),
- _CU_TEST_INFO(scheduler_test_multi_1q_1t_a),
- _CU_TEST_INFO(scheduler_test_multi_1q_1t_o),
- _CU_TEST_INFO(scheduler_test_multi_mq_1t_n),
- _CU_TEST_INFO(scheduler_test_multi_mq_1t_a),
- _CU_TEST_INFO(scheduler_test_multi_mq_1t_o),
- _CU_TEST_INFO(scheduler_test_multi_mq_1t_prio_n),
- _CU_TEST_INFO(scheduler_test_multi_mq_1t_prio_a),
- _CU_TEST_INFO(scheduler_test_multi_mq_1t_prio_o),
- _CU_TEST_INFO(scheduler_test_multi_mq_mt_prio_n),
- _CU_TEST_INFO(scheduler_test_multi_mq_mt_prio_a),
- _CU_TEST_INFO(scheduler_test_multi_mq_mt_prio_o),
- _CU_TEST_INFO(scheduler_test_multi_1q_mt_a_excl),
- _CU_TEST_INFO(scheduler_test_pause_resume),
- CU_TEST_INFO_NULL,
+odp_testinfo_t scheduler_suite[] = {
+ ODP_TEST_INFO(scheduler_test_wait_time),
+ ODP_TEST_INFO(scheduler_test_num_prio),
+ ODP_TEST_INFO(scheduler_test_queue_destroy),
+ ODP_TEST_INFO(scheduler_test_groups),
+ ODP_TEST_INFO(scheduler_test_1q_1t_n),
+ ODP_TEST_INFO(scheduler_test_1q_1t_a),
+ ODP_TEST_INFO(scheduler_test_1q_1t_o),
+ ODP_TEST_INFO(scheduler_test_mq_1t_n),
+ ODP_TEST_INFO(scheduler_test_mq_1t_a),
+ ODP_TEST_INFO(scheduler_test_mq_1t_o),
+ ODP_TEST_INFO(scheduler_test_mq_1t_prio_n),
+ ODP_TEST_INFO(scheduler_test_mq_1t_prio_a),
+ ODP_TEST_INFO(scheduler_test_mq_1t_prio_o),
+ ODP_TEST_INFO(scheduler_test_mq_mt_prio_n),
+ ODP_TEST_INFO(scheduler_test_mq_mt_prio_a),
+ ODP_TEST_INFO(scheduler_test_mq_mt_prio_o),
+ ODP_TEST_INFO(scheduler_test_1q_mt_a_excl),
+ ODP_TEST_INFO(scheduler_test_multi_1q_1t_n),
+ ODP_TEST_INFO(scheduler_test_multi_1q_1t_a),
+ ODP_TEST_INFO(scheduler_test_multi_1q_1t_o),
+ ODP_TEST_INFO(scheduler_test_multi_mq_1t_n),
+ ODP_TEST_INFO(scheduler_test_multi_mq_1t_a),
+ ODP_TEST_INFO(scheduler_test_multi_mq_1t_o),
+ ODP_TEST_INFO(scheduler_test_multi_mq_1t_prio_n),
+ ODP_TEST_INFO(scheduler_test_multi_mq_1t_prio_a),
+ ODP_TEST_INFO(scheduler_test_multi_mq_1t_prio_o),
+ ODP_TEST_INFO(scheduler_test_multi_mq_mt_prio_n),
+ ODP_TEST_INFO(scheduler_test_multi_mq_mt_prio_a),
+ ODP_TEST_INFO(scheduler_test_multi_mq_mt_prio_o),
+ ODP_TEST_INFO(scheduler_test_multi_1q_mt_a_excl),
+ ODP_TEST_INFO(scheduler_test_pause_resume),
+ ODP_TEST_INFO_NULL,
};
-CU_SuiteInfo scheduler_suites[] = {
+odp_suiteinfo_t scheduler_suites[] = {
{"Scheduler",
- scheduler_suite_init, scheduler_suite_term, NULL, NULL, scheduler_suite
+ scheduler_suite_init, scheduler_suite_term, scheduler_suite
},
- CU_SUITE_INFO_NULL,
+ ODP_SUITE_INFO_NULL,
};
int scheduler_main(void)
{
- return odp_cunit_run(scheduler_suites);
+ int ret = odp_cunit_register(scheduler_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/scheduler/scheduler.h b/test/validation/scheduler/scheduler.h
index eab8787b7..c869e414f 100644
--- a/test/validation/scheduler/scheduler.h
+++ b/test/validation/scheduler/scheduler.h
@@ -7,7 +7,7 @@
#ifndef _ODP_TEST_SCHEDULER_H_
#define _ODP_TEST_SCHEDULER_H_
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
void scheduler_test_wait_time(void);
@@ -43,14 +43,14 @@ void scheduler_test_multi_1q_mt_a_excl(void);
void scheduler_test_pause_resume(void);
/* test arrays: */
-extern CU_TestInfo scheduler_suite[];
+extern odp_testinfo_t scheduler_suite[];
/* test array init/term functions: */
int scheduler_suite_init(void);
int scheduler_suite_term(void);
/* test registry: */
-extern CU_SuiteInfo scheduler_suites[];
+extern odp_suiteinfo_t scheduler_suites[];
/* main test program: */
int scheduler_main(void);
diff --git a/test/validation/shmem/shmem.c b/test/validation/shmem/shmem.c
index 6dc579a39..5524b5cc1 100644
--- a/test/validation/shmem/shmem.c
+++ b/test/validation/shmem/shmem.c
@@ -76,17 +76,22 @@ void shmem_test_odp_shm_sunnyday(void)
odp_cunit_thread_exit(&thrdarg);
}
-CU_TestInfo shmem_suite[] = {
- _CU_TEST_INFO(shmem_test_odp_shm_sunnyday),
- CU_TEST_INFO_NULL,
+odp_testinfo_t shmem_suite[] = {
+ ODP_TEST_INFO(shmem_test_odp_shm_sunnyday),
+ ODP_TEST_INFO_NULL,
};
-CU_SuiteInfo shmem_suites[] = {
- {"Shared Memory", NULL, NULL, NULL, NULL, shmem_suite},
- CU_SUITE_INFO_NULL,
+odp_suiteinfo_t shmem_suites[] = {
+ {"Shared Memory", NULL, NULL, shmem_suite},
+ ODP_SUITE_INFO_NULL,
};
int shmem_main(void)
{
- return odp_cunit_run(shmem_suites);
+ int ret = odp_cunit_register(shmem_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/shmem/shmem.h b/test/validation/shmem/shmem.h
index 8de0bc660..d60cf6482 100644
--- a/test/validation/shmem/shmem.h
+++ b/test/validation/shmem/shmem.h
@@ -7,16 +7,16 @@
#ifndef _ODP_TEST_SHMEM_H_
#define _ODP_TEST_SHMEM_H_
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
void shmem_test_odp_shm_sunnyday(void);
/* test arrays: */
-extern CU_TestInfo shmem_suite[];
+extern odp_testinfo_t shmem_suite[];
/* test registry: */
-extern CU_SuiteInfo shmem_suites[];
+extern odp_suiteinfo_t shmem_suites[];
/* main test program: */
int shmem_main(void);
diff --git a/test/validation/synchronizers/synchronizers.c b/test/validation/synchronizers/synchronizers.c
index 47295c88a..2406c7706 100644
--- a/test/validation/synchronizers/synchronizers.c
+++ b/test/validation/synchronizers/synchronizers.c
@@ -942,10 +942,10 @@ void synchronizers_test_barrier_functional(void)
odp_cunit_thread_exit(&arg);
}
-CU_TestInfo synchronizers_suite_barrier[] = {
- _CU_TEST_INFO(synchronizers_test_no_barrier_functional),
- _CU_TEST_INFO(synchronizers_test_barrier_functional),
- CU_TEST_INFO_NULL
+odp_testinfo_t synchronizers_suite_barrier[] = {
+ ODP_TEST_INFO(synchronizers_test_no_barrier_functional),
+ ODP_TEST_INFO(synchronizers_test_barrier_functional),
+ ODP_TEST_INFO_NULL
};
/* Thread-unsafe tests */
@@ -958,9 +958,9 @@ void synchronizers_test_no_lock_functional(void)
odp_cunit_thread_exit(&arg);
}
-CU_TestInfo synchronizers_suite_no_locking[] = {
- _CU_TEST_INFO(synchronizers_test_no_lock_functional),
- CU_TEST_INFO_NULL
+odp_testinfo_t synchronizers_suite_no_locking[] = {
+ ODP_TEST_INFO(synchronizers_test_no_lock_functional),
+ ODP_TEST_INFO_NULL
};
/* Spin lock tests */
@@ -983,10 +983,10 @@ void synchronizers_test_spinlock_functional(void)
odp_cunit_thread_exit(&arg);
}
-CU_TestInfo synchronizers_suite_spinlock[] = {
- _CU_TEST_INFO(synchronizers_test_spinlock_api),
- _CU_TEST_INFO(synchronizers_test_spinlock_functional),
- CU_TEST_INFO_NULL
+odp_testinfo_t synchronizers_suite_spinlock[] = {
+ ODP_TEST_INFO(synchronizers_test_spinlock_api),
+ ODP_TEST_INFO(synchronizers_test_spinlock_functional),
+ ODP_TEST_INFO_NULL
};
/* Ticket lock tests */
@@ -1010,10 +1010,10 @@ void synchronizers_test_ticketlock_functional(void)
odp_cunit_thread_exit(&arg);
}
-CU_TestInfo synchronizers_suite_ticketlock[] = {
- _CU_TEST_INFO(synchronizers_test_ticketlock_api),
- _CU_TEST_INFO(synchronizers_test_ticketlock_functional),
- CU_TEST_INFO_NULL
+odp_testinfo_t synchronizers_suite_ticketlock[] = {
+ ODP_TEST_INFO(synchronizers_test_ticketlock_api),
+ ODP_TEST_INFO(synchronizers_test_ticketlock_functional),
+ ODP_TEST_INFO_NULL
};
/* RW lock tests */
@@ -1036,10 +1036,10 @@ void synchronizers_test_rwlock_functional(void)
odp_cunit_thread_exit(&arg);
}
-CU_TestInfo synchronizers_suite_rwlock[] = {
- _CU_TEST_INFO(synchronizers_test_rwlock_api),
- _CU_TEST_INFO(synchronizers_test_rwlock_functional),
- CU_TEST_INFO_NULL
+odp_testinfo_t synchronizers_suite_rwlock[] = {
+ ODP_TEST_INFO(synchronizers_test_rwlock_api),
+ ODP_TEST_INFO(synchronizers_test_rwlock_functional),
+ ODP_TEST_INFO_NULL
};
int synchronizers_suite_init(void)
@@ -1188,32 +1188,40 @@ void synchronizers_test_atomic_fetch_add_sub(void)
test_atomic_functional(test_atomic_fetch_add_sub_thread);
}
-CU_TestInfo synchronizers_suite_atomic[] = {
- _CU_TEST_INFO(synchronizers_test_atomic_inc_dec),
- _CU_TEST_INFO(synchronizers_test_atomic_add_sub),
- _CU_TEST_INFO(synchronizers_test_atomic_fetch_inc_dec),
- _CU_TEST_INFO(synchronizers_test_atomic_fetch_add_sub),
- CU_TEST_INFO_NULL,
+odp_testinfo_t synchronizers_suite_atomic[] = {
+ ODP_TEST_INFO(synchronizers_test_atomic_inc_dec),
+ ODP_TEST_INFO(synchronizers_test_atomic_add_sub),
+ ODP_TEST_INFO(synchronizers_test_atomic_fetch_inc_dec),
+ ODP_TEST_INFO(synchronizers_test_atomic_fetch_add_sub),
+ ODP_TEST_INFO_NULL,
};
-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
+odp_suiteinfo_t synchronizers_suites[] = {
+ {"barrier", NULL, NULL,
+ synchronizers_suite_barrier},
+ {"nolocking", synchronizers_suite_init, NULL,
+ synchronizers_suite_no_locking},
+ {"spinlock", synchronizers_suite_init, NULL,
+ synchronizers_suite_spinlock},
+ {"ticketlock", synchronizers_suite_init, NULL,
+ synchronizers_suite_ticketlock},
+ {"rwlock", synchronizers_suite_init, NULL,
+ synchronizers_suite_rwlock},
+ {"atomic", NULL, NULL,
+ synchronizers_suite_atomic},
+ ODP_SUITE_INFO_NULL
};
int synchronizers_main(void)
{
+ int ret;
+
odp_cunit_register_global_init(synchronizers_init);
- return odp_cunit_run(synchronizers_suites);
+
+ ret = odp_cunit_register(synchronizers_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/synchronizers/synchronizers.h b/test/validation/synchronizers/synchronizers.h
index 45b90e946..f16477cb9 100644
--- a/test/validation/synchronizers/synchronizers.h
+++ b/test/validation/synchronizers/synchronizers.h
@@ -7,7 +7,7 @@
#ifndef _ODP_TEST_SYNCHRONIZERS_H_
#define _ODP_TEST_SYNCHRONIZERS_H_
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
void synchronizers_test_no_barrier_functional(void);
@@ -25,18 +25,18 @@ void synchronizers_test_atomic_fetch_inc_dec(void);
void synchronizers_test_atomic_fetch_add_sub(void);
/* test arrays: */
-extern CU_TestInfo synchronizers_suite_barrier[];
-extern CU_TestInfo synchronizers_suite_no_locking[];
-extern CU_TestInfo synchronizers_suite_spinlock[];
-extern CU_TestInfo synchronizers_suite_ticketlock[];
-extern CU_TestInfo synchronizers_suite_rwlock[];
-extern CU_TestInfo synchronizers_suite_atomic[];
+extern odp_testinfo_t synchronizers_suite_barrier[];
+extern odp_testinfo_t synchronizers_suite_no_locking[];
+extern odp_testinfo_t synchronizers_suite_spinlock[];
+extern odp_testinfo_t synchronizers_suite_ticketlock[];
+extern odp_testinfo_t synchronizers_suite_rwlock[];
+extern odp_testinfo_t synchronizers_suite_atomic[];
/* test array init/term functions: */
int synchronizers_suite_init(void);
/* test registry: */
-extern CU_SuiteInfo synchronizers_suites[];
+extern odp_suiteinfo_t synchronizers_suites[];
/* executable init/term functions: */
int synchronizers_init(void);
diff --git a/test/validation/system/system.c b/test/validation/system/system.c
index eebeb52d9..171fb74e7 100644
--- a/test/validation/system/system.c
+++ b/test/validation/system/system.c
@@ -141,27 +141,32 @@ void system_test_odp_cpu_hz_max_id(void)
}
}
-CU_TestInfo system_suite[] = {
- _CU_TEST_INFO(system_test_odp_version_numbers),
- _CU_TEST_INFO(system_test_odp_cpu_count),
- _CU_TEST_INFO(system_test_odp_sys_cache_line_size),
- _CU_TEST_INFO(system_test_odp_cpu_model_str),
- _CU_TEST_INFO(system_test_odp_cpu_model_str_id),
- _CU_TEST_INFO(system_test_odp_sys_page_size),
- _CU_TEST_INFO(system_test_odp_sys_huge_page_size),
- _CU_TEST_INFO(system_test_odp_cpu_hz),
- _CU_TEST_INFO(system_test_odp_cpu_hz_id),
- _CU_TEST_INFO(system_test_odp_cpu_hz_max),
- _CU_TEST_INFO(system_test_odp_cpu_hz_max_id),
- CU_TEST_INFO_NULL,
+odp_testinfo_t system_suite[] = {
+ ODP_TEST_INFO(system_test_odp_version_numbers),
+ ODP_TEST_INFO(system_test_odp_cpu_count),
+ ODP_TEST_INFO(system_test_odp_sys_cache_line_size),
+ ODP_TEST_INFO(system_test_odp_cpu_model_str),
+ ODP_TEST_INFO(system_test_odp_cpu_model_str_id),
+ ODP_TEST_INFO(system_test_odp_sys_page_size),
+ ODP_TEST_INFO(system_test_odp_sys_huge_page_size),
+ ODP_TEST_INFO(system_test_odp_cpu_hz),
+ ODP_TEST_INFO(system_test_odp_cpu_hz_id),
+ ODP_TEST_INFO(system_test_odp_cpu_hz_max),
+ ODP_TEST_INFO(system_test_odp_cpu_hz_max_id),
+ ODP_TEST_INFO_NULL,
};
-CU_SuiteInfo system_suites[] = {
- {"System Info", NULL, NULL, NULL, NULL, system_suite},
- CU_SUITE_INFO_NULL,
+odp_suiteinfo_t system_suites[] = {
+ {"System Info", NULL, NULL, system_suite},
+ ODP_SUITE_INFO_NULL,
};
int system_main(void)
{
- return odp_cunit_run(system_suites);
+ int ret = odp_cunit_register(system_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/system/system.h b/test/validation/system/system.h
index 4abe78ca9..13725db30 100644
--- a/test/validation/system/system.h
+++ b/test/validation/system/system.h
@@ -7,7 +7,7 @@
#ifndef _ODP_TEST_SYSTEM_H_
#define _ODP_TEST_SYSTEM_H_
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
void system_test_odp_version_numbers(void);
@@ -23,10 +23,10 @@ void system_test_odp_cpu_hz_max(void);
void system_test_odp_cpu_hz_max_id(void);
/* test arrays: */
-extern CU_TestInfo system_suite[];
+extern odp_testinfo_t system_suite[];
/* test registry: */
-extern CU_SuiteInfo system_suites[];
+extern odp_suiteinfo_t system_suites[];
/* main test program: */
int system_main(void);
diff --git a/test/validation/thread/thread.c b/test/validation/thread/thread.c
index 093e68802..03bf3cd2d 100644
--- a/test/validation/thread/thread.c
+++ b/test/validation/thread/thread.c
@@ -95,35 +95,40 @@ void thread_test_odp_thrmask_control(void)
CU_ASSERT(ret == 1);
}
-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(thread_test_odp_thrmask_to_from_str),
- _CU_TEST_INFO(thread_test_odp_thrmask_equal),
- _CU_TEST_INFO(thread_test_odp_thrmask_zero),
- _CU_TEST_INFO(thread_test_odp_thrmask_set),
- _CU_TEST_INFO(thread_test_odp_thrmask_clr),
- _CU_TEST_INFO(thread_test_odp_thrmask_isset),
- _CU_TEST_INFO(thread_test_odp_thrmask_count),
- _CU_TEST_INFO(thread_test_odp_thrmask_and),
- _CU_TEST_INFO(thread_test_odp_thrmask_or),
- _CU_TEST_INFO(thread_test_odp_thrmask_xor),
- _CU_TEST_INFO(thread_test_odp_thrmask_copy),
- _CU_TEST_INFO(thread_test_odp_thrmask_first),
- _CU_TEST_INFO(thread_test_odp_thrmask_last),
- _CU_TEST_INFO(thread_test_odp_thrmask_next),
- _CU_TEST_INFO(thread_test_odp_thrmask_worker),
- _CU_TEST_INFO(thread_test_odp_thrmask_control),
- CU_TEST_INFO_NULL,
+odp_testinfo_t thread_suite[] = {
+ ODP_TEST_INFO(thread_test_odp_cpu_id),
+ ODP_TEST_INFO(thread_test_odp_thread_id),
+ ODP_TEST_INFO(thread_test_odp_thread_count),
+ ODP_TEST_INFO(thread_test_odp_thrmask_to_from_str),
+ ODP_TEST_INFO(thread_test_odp_thrmask_equal),
+ ODP_TEST_INFO(thread_test_odp_thrmask_zero),
+ ODP_TEST_INFO(thread_test_odp_thrmask_set),
+ ODP_TEST_INFO(thread_test_odp_thrmask_clr),
+ ODP_TEST_INFO(thread_test_odp_thrmask_isset),
+ ODP_TEST_INFO(thread_test_odp_thrmask_count),
+ ODP_TEST_INFO(thread_test_odp_thrmask_and),
+ ODP_TEST_INFO(thread_test_odp_thrmask_or),
+ ODP_TEST_INFO(thread_test_odp_thrmask_xor),
+ ODP_TEST_INFO(thread_test_odp_thrmask_copy),
+ ODP_TEST_INFO(thread_test_odp_thrmask_first),
+ ODP_TEST_INFO(thread_test_odp_thrmask_last),
+ ODP_TEST_INFO(thread_test_odp_thrmask_next),
+ ODP_TEST_INFO(thread_test_odp_thrmask_worker),
+ ODP_TEST_INFO(thread_test_odp_thrmask_control),
+ ODP_TEST_INFO_NULL,
};
-CU_SuiteInfo thread_suites[] = {
- {"thread", NULL, NULL, NULL, NULL, thread_suite},
- CU_SUITE_INFO_NULL,
+odp_suiteinfo_t thread_suites[] = {
+ {"thread", NULL, NULL, thread_suite},
+ ODP_SUITE_INFO_NULL,
};
int thread_main(void)
{
- return odp_cunit_run(thread_suites);
+ int ret = odp_cunit_register(thread_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/thread/thread.h b/test/validation/thread/thread.h
index ef645b4b0..6cbc69432 100644
--- a/test/validation/thread/thread.h
+++ b/test/validation/thread/thread.h
@@ -8,7 +8,7 @@
#define _ODP_TEST_THREAD_H_
#include <odp.h>
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
#ifndef TEST_THRMASK
@@ -22,10 +22,10 @@ void thread_test_odp_thrmask_control(void);
void thread_test_odp_thrmask_worker(void);
/* test arrays: */
-extern CU_TestInfo thread_suite[];
+extern odp_testinfo_t thread_suite[];
/* test registry: */
-extern CU_SuiteInfo thread_suites[];
+extern odp_suiteinfo_t thread_suites[];
/* main test program: */
int thread_main(void);
diff --git a/test/validation/time/time.c b/test/validation/time/time.c
index 4b81c2c0b..41db0e954 100644
--- a/test/validation/time/time.c
+++ b/test/validation/time/time.c
@@ -61,19 +61,24 @@ void time_test_odp_time_conversion(void)
CU_ASSERT((ns2 <= upper_limit) && (ns2 >= lower_limit));
}
-CU_TestInfo time_suite_time[] = {
- _CU_TEST_INFO(time_test_odp_cycles_diff),
- _CU_TEST_INFO(time_test_odp_cycles_negative_diff),
- _CU_TEST_INFO(time_test_odp_time_conversion),
- CU_TEST_INFO_NULL
+odp_testinfo_t time_suite_time[] = {
+ ODP_TEST_INFO(time_test_odp_cycles_diff),
+ ODP_TEST_INFO(time_test_odp_cycles_negative_diff),
+ ODP_TEST_INFO(time_test_odp_time_conversion),
+ ODP_TEST_INFO_NULL
};
-CU_SuiteInfo time_suites[] = {
- {"Time", NULL, NULL, NULL, NULL, time_suite_time},
- CU_SUITE_INFO_NULL
+odp_suiteinfo_t time_suites[] = {
+ {"Time", NULL, NULL, time_suite_time},
+ ODP_SUITE_INFO_NULL
};
int time_main(void)
{
- return odp_cunit_run(time_suites);
+ int ret = odp_cunit_register(time_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/time/time.h b/test/validation/time/time.h
index 1f6982633..9ccdeb762 100644
--- a/test/validation/time/time.h
+++ b/test/validation/time/time.h
@@ -7,7 +7,7 @@
#ifndef _ODP_TEST_TIME_H_
#define _ODP_TEST_TIME_H_
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
void time_test_odp_cycles_diff(void);
@@ -15,10 +15,10 @@ void time_test_odp_cycles_negative_diff(void);
void time_test_odp_time_conversion(void);
/* test arrays: */
-extern CU_TestInfo time_suite_time[];
+extern odp_testinfo_t time_suite_time[];
/* test registry: */
-extern CU_SuiteInfo time_suites[];
+extern odp_suiteinfo_t time_suites[];
/* main test program: */
int time_main(void);
diff --git a/test/validation/timer/timer.c b/test/validation/timer/timer.c
index 7a8b98a17..645dc5882 100644
--- a/test/validation/timer/timer.c
+++ b/test/validation/timer/timer.c
@@ -529,20 +529,25 @@ void timer_test_odp_timer_all(void)
CU_PASS("ODP timer test");
}
-CU_TestInfo timer_suite[] = {
- _CU_TEST_INFO(timer_test_timeout_pool_alloc),
- _CU_TEST_INFO(timer_test_timeout_pool_free),
- _CU_TEST_INFO(timer_test_odp_timer_cancel),
- _CU_TEST_INFO(timer_test_odp_timer_all),
- CU_TEST_INFO_NULL,
+odp_testinfo_t timer_suite[] = {
+ ODP_TEST_INFO(timer_test_timeout_pool_alloc),
+ ODP_TEST_INFO(timer_test_timeout_pool_free),
+ ODP_TEST_INFO(timer_test_odp_timer_cancel),
+ ODP_TEST_INFO(timer_test_odp_timer_all),
+ ODP_TEST_INFO_NULL,
};
-CU_SuiteInfo timer_suites[] = {
- {"Timer", NULL, NULL, NULL, NULL, timer_suite},
- CU_SUITE_INFO_NULL,
+odp_suiteinfo_t timer_suites[] = {
+ {"Timer", NULL, NULL, timer_suite},
+ ODP_SUITE_INFO_NULL,
};
int timer_main(void)
{
- return odp_cunit_run(timer_suites);
+ int ret = odp_cunit_register(timer_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
}
diff --git a/test/validation/timer/timer.h b/test/validation/timer/timer.h
index 3694671f0..46ea8d768 100644
--- a/test/validation/timer/timer.h
+++ b/test/validation/timer/timer.h
@@ -7,7 +7,7 @@
#ifndef _ODP_TEST_TIMER_H_
#define _ODP_TEST_TIMER_H_
-#include <CUnit/Basic.h>
+#include <odp_cunit_common.h>
/* test functions: */
void timer_test_timeout_pool_alloc(void);
@@ -16,10 +16,10 @@ void timer_test_odp_timer_cancel(void);
void timer_test_odp_timer_all(void);
/* test arrays: */
-extern CU_TestInfo timer_suite[];
+extern odp_testinfo_t timer_suite[];
/* test registry: */
-extern CU_SuiteInfo timer_suites[];
+extern odp_suiteinfo_t timer_suites[];
/* main test program: */
int timer_main(void);