aboutsummaryrefslogtreecommitdiff
path: root/test/validation/api
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2024-02-29 10:17:50 +0200
committerMatias Elo <matias.elo@nokia.com>2024-02-29 10:17:50 +0200
commit16e67fed112cd472a9fd1be20b75903cb6bf219c (patch)
treed4d7794d3e9f0ad47f33a97b0df943c98a818168 /test/validation/api
parentc00ef7d6bce1e483c4cf1bb3cdf6cd629530d795 (diff)
parent7abbd0d823091bfc52ec0345fb8fc67f68cc8c80 (diff)
Merge ODP v1.44.0.0
Merge ODP linux-generic v1.44.0.0 into linux-dpdk. Signed-off-by: Matias Elo <matias.elo@nokia.com>
Diffstat (limited to 'test/validation/api')
-rw-r--r--test/validation/api/Makefile.am38
-rw-r--r--test/validation/api/align/.gitignore1
-rw-r--r--test/validation/api/align/Makefile.am4
-rw-r--r--test/validation/api/align/align.c156
-rw-r--r--test/validation/api/atomic/atomic.c2
-rw-r--r--test/validation/api/barrier/barrier.c2
-rw-r--r--test/validation/api/buffer/buffer.c2
-rw-r--r--test/validation/api/byteorder/.gitignore1
-rw-r--r--test/validation/api/byteorder/Makefile.am4
-rw-r--r--test/validation/api/byteorder/byteorder.c107
-rw-r--r--test/validation/api/chksum/chksum.c2
-rw-r--r--test/validation/api/classification/classification.c2
-rw-r--r--test/validation/api/comp/comp.c2
-rw-r--r--test/validation/api/cpumask/cpumask.c2
-rw-r--r--test/validation/api/crypto/crypto_op_test.c20
-rw-r--r--test/validation/api/crypto/odp_crypto_test_inp.c2
-rw-r--r--test/validation/api/dma/dma.c2
-rw-r--r--test/validation/api/errno/errno.c2
-rw-r--r--test/validation/api/event/event.c2
-rw-r--r--test/validation/api/hash/hash.c2
-rw-r--r--test/validation/api/hints/.gitignore1
-rw-r--r--test/validation/api/hints/Makefile.am4
-rw-r--r--test/validation/api/hints/hints.c92
-rw-r--r--test/validation/api/init/.gitignore10
-rw-r--r--test/validation/api/init/Makefile.am36
-rwxr-xr-xtest/validation/api/init/init_abort.sh3
-rwxr-xr-xtest/validation/api/init/init_defaults.sh3
-rwxr-xr-xtest/validation/api/init/init_feature_disabled.sh3
-rwxr-xr-xtest/validation/api/init/init_feature_enabled.sh3
-rwxr-xr-xtest/validation/api/init/init_log.sh3
-rwxr-xr-xtest/validation/api/init/init_log_thread.sh3
-rw-r--r--test/validation/api/init/init_main.c21
-rwxr-xr-xtest/validation/api/init/init_num_thr.sh3
-rwxr-xr-xtest/validation/api/init/init_test_param_init.sh3
-rwxr-xr-xtest/validation/api/init/init_test_term_abnormal.sh3
-rw-r--r--test/validation/api/ipsec/.gitignore5
-rw-r--r--test/validation/api/ipsec/Makefile.am17
-rw-r--r--test/validation/api/ipsec/ipsec.c32
-rw-r--r--test/validation/api/ipsec/ipsec.h5
-rw-r--r--test/validation/api/ipsec/ipsec_async.c55
-rwxr-xr-xtest/validation/api/ipsec/ipsec_async.sh3
-rw-r--r--test/validation/api/ipsec/ipsec_inline_in.c54
-rwxr-xr-xtest/validation/api/ipsec/ipsec_inline_in.sh3
-rw-r--r--test/validation/api/ipsec/ipsec_inline_out.c54
-rwxr-xr-xtest/validation/api/ipsec/ipsec_inline_out.sh3
-rw-r--r--test/validation/api/ipsec/ipsec_main.c83
-rw-r--r--test/validation/api/ipsec/ipsec_sync.c49
-rwxr-xr-xtest/validation/api/ipsec/ipsec_sync.sh3
-rw-r--r--test/validation/api/lock/lock.c2
-rw-r--r--test/validation/api/ml/.gitignore1
-rw-r--r--test/validation/api/ml/Makefile.am4
-rw-r--r--test/validation/api/ml/ml.c572
-rw-r--r--test/validation/api/packet/packet.c2
-rw-r--r--test/validation/api/pktio/lso.c8
-rw-r--r--test/validation/api/pktio/pktio.c25
-rw-r--r--test/validation/api/pool/pool.c5
-rw-r--r--test/validation/api/queue/queue.c2
-rw-r--r--test/validation/api/random/random.c11
-rw-r--r--test/validation/api/scheduler/scheduler.c84
-rw-r--r--test/validation/api/scheduler/scheduler_no_predef_groups.c2
-rw-r--r--test/validation/api/shmem/shmem.c2
-rw-r--r--test/validation/api/stash/stash.c2
-rw-r--r--test/validation/api/std/std.c2
-rw-r--r--test/validation/api/system/system.c18
-rw-r--r--test/validation/api/thread/thread.c2
-rw-r--r--test/validation/api/time/time.c17
-rw-r--r--test/validation/api/timer/timer.c43
-rw-r--r--test/validation/api/traffic_mngr/traffic_mngr.c2
68 files changed, 1271 insertions, 447 deletions
diff --git a/test/validation/api/Makefile.am b/test/validation/api/Makefile.am
index ade387152..5a3c0216b 100644
--- a/test/validation/api/Makefile.am
+++ b/test/validation/api/Makefile.am
@@ -1,6 +1,8 @@
-ODP_MODULES = atomic \
+ODP_MODULES = align \
+ atomic \
barrier \
buffer \
+ byteorder \
chksum \
classification \
comp \
@@ -10,9 +12,11 @@ ODP_MODULES = atomic \
errno \
event \
hash \
+ hints \
init \
ipsec \
lock \
+ ml \
queue \
packet \
pktio \
@@ -31,12 +35,14 @@ ODP_MODULES = atomic \
SUBDIRS = $(ODP_MODULES)
include $(top_srcdir)/test/Makefile.inc
-TESTS_ENVIRONMENT += TEST_DIR=${top_builddir}/test/validation
+TESTS_ENVIRONMENT += TEST_DIR=${top_builddir}/test/validation/api
TESTS = \
+ align/align_main$(EXEEXT) \
atomic/atomic_main$(EXEEXT) \
barrier/barrier_main$(EXEEXT) \
buffer/buffer_main$(EXEEXT) \
+ byteorder/byteorder_main$(EXEEXT) \
chksum/chksum_main$(EXEEXT) \
classification/classification_main$(EXEEXT) \
comp/comp_main$(EXEEXT) \
@@ -46,20 +52,22 @@ TESTS = \
errno/errno_main$(EXEEXT) \
event/event_main$(EXEEXT) \
hash/hash_main$(EXEEXT) \
- init/init_defaults$(EXEEXT) \
- init/init_abort$(EXEEXT) \
- init/init_log$(EXEEXT) \
- init/init_log_thread$(EXEEXT) \
- init/init_num_thr$(EXEEXT) \
- init/init_feature_enabled$(EXEEXT) \
- init/init_feature_disabled$(EXEEXT) \
- init/init_test_param_init$(EXEEXT) \
- init/init_test_term_abnormal$(EXEEXT) \
- ipsec/ipsec_sync$(EXEEXT) \
- ipsec/ipsec_async$(EXEEXT) \
- ipsec/ipsec_inline_in$(EXEEXT) \
- ipsec/ipsec_inline_out$(EXEEXT) \
+ hints/hints_main$(EXEEXT) \
+ init/init_defaults.sh \
+ init/init_abort.sh \
+ init/init_log.sh \
+ init/init_log_thread.sh \
+ init/init_num_thr.sh \
+ init/init_feature_enabled.sh \
+ init/init_feature_disabled.sh \
+ init/init_test_param_init.sh \
+ init/init_test_term_abnormal.sh \
+ ipsec/ipsec_sync.sh \
+ ipsec/ipsec_async.sh \
+ ipsec/ipsec_inline_in.sh \
+ ipsec/ipsec_inline_out.sh \
lock/lock_main$(EXEEXT) \
+ ml/ml_main$(EXEEXT) \
packet/packet_main$(EXEEXT) \
pktio/pktio_main$(EXEEXT) \
pool/pool_main$(EXEEXT) \
diff --git a/test/validation/api/align/.gitignore b/test/validation/api/align/.gitignore
new file mode 100644
index 000000000..3031151a1
--- /dev/null
+++ b/test/validation/api/align/.gitignore
@@ -0,0 +1 @@
+align_main
diff --git a/test/validation/api/align/Makefile.am b/test/validation/api/align/Makefile.am
new file mode 100644
index 000000000..dd6e36bcd
--- /dev/null
+++ b/test/validation/api/align/Makefile.am
@@ -0,0 +1,4 @@
+include ../Makefile.inc
+
+test_PROGRAMS = align_main
+align_main_SOURCES = align.c
diff --git a/test/validation/api/align/align.c b/test/validation/api/align/align.c
new file mode 100644
index 000000000..ddbd1a2fe
--- /dev/null
+++ b/test/validation/api/align/align.c
@@ -0,0 +1,156 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2024 Nokia
+ */
+
+#include <odp_api.h>
+#include <odp_cunit_common.h>
+
+#include <stddef.h>
+#include <stdint.h>
+
+/* Test struct without gaps */
+typedef struct ODP_PACKED {
+ uint8_t a;
+ uint8_t b;
+ uint16_t c;
+ uint32_t d;
+} test_type_t;
+
+/* Test struct with gaps */
+typedef struct ODP_PACKED {
+ uint8_t a;
+ uint16_t b;
+ uint8_t c;
+ uint32_t d;
+} test_type_2_t;
+
+static void test_aligned(void)
+{
+ uint8_t align_2 ODP_ALIGNED(2);
+ uint16_t align_4 ODP_ALIGNED(4);
+ uint32_t align_8 ODP_ALIGNED(8);
+ uint64_t align_16 ODP_ALIGNED(16);
+
+ CU_ASSERT((uintptr_t)&align_2 % 2 == 0);
+ CU_ASSERT((uintptr_t)&align_4 % 4 == 0);
+ CU_ASSERT((uintptr_t)&align_8 % 8 == 0);
+ CU_ASSERT((uintptr_t)&align_16 % 16 == 0);
+}
+
+static void test_packed(void)
+{
+ uint32_t offset;
+
+ offset = 0;
+ CU_ASSERT(offsetof(test_type_t, a) == offset);
+
+ offset += sizeof(uint8_t);
+ CU_ASSERT(offsetof(test_type_t, b) == offset);
+
+ offset += sizeof(uint8_t);
+ CU_ASSERT(offsetof(test_type_t, c) == offset);
+
+ offset += sizeof(uint16_t);
+ CU_ASSERT(offsetof(test_type_t, d) == offset);
+
+ offset = 0;
+ CU_ASSERT(offsetof(test_type_2_t, a) == offset);
+
+ offset += sizeof(uint8_t);
+ CU_ASSERT(offsetof(test_type_2_t, b) == offset);
+
+ offset += sizeof(uint16_t);
+ CU_ASSERT(offsetof(test_type_2_t, c) == offset);
+
+ offset += sizeof(uint8_t);
+ CU_ASSERT(offsetof(test_type_2_t, d) == offset);
+}
+
+static void test_offsetof(void)
+{
+ CU_ASSERT(ODP_OFFSETOF(test_type_t, a) == offsetof(test_type_t, a));
+ CU_ASSERT(ODP_OFFSETOF(test_type_t, b) == offsetof(test_type_t, b));
+ CU_ASSERT(ODP_OFFSETOF(test_type_t, c) == offsetof(test_type_t, c));
+ CU_ASSERT(ODP_OFFSETOF(test_type_t, d) == offsetof(test_type_t, d));
+ CU_ASSERT(ODP_OFFSETOF(test_type_2_t, a) == offsetof(test_type_2_t, a));
+ CU_ASSERT(ODP_OFFSETOF(test_type_2_t, b) == offsetof(test_type_2_t, b));
+ CU_ASSERT(ODP_OFFSETOF(test_type_2_t, c) == offsetof(test_type_2_t, c));
+ CU_ASSERT(ODP_OFFSETOF(test_type_2_t, d) == offsetof(test_type_2_t, d));
+}
+
+static void test_field_sizeof(void)
+{
+ test_type_t tt;
+
+ CU_ASSERT(ODP_FIELD_SIZEOF(test_type_t, a) == sizeof(tt.a));
+ CU_ASSERT(ODP_FIELD_SIZEOF(test_type_t, b) == sizeof(tt.b));
+ CU_ASSERT(ODP_FIELD_SIZEOF(test_type_t, c) == sizeof(tt.c));
+ CU_ASSERT(ODP_FIELD_SIZEOF(test_type_t, d) == sizeof(tt.d));
+}
+
+static void test_cache_line_size(void)
+{
+ CU_ASSERT(ODP_CACHE_LINE_SIZE > 0);
+ CU_ASSERT(ODP_CACHE_LINE_SIZE % 2 == 0);
+}
+
+static void test_page_size(void)
+{
+ CU_ASSERT(ODP_PAGE_SIZE > 0);
+ CU_ASSERT(ODP_PAGE_SIZE % 2 == 0);
+}
+
+static void test_aligned_cache(void)
+{
+ uint8_t arr[123] ODP_ALIGNED_CACHE;
+
+ CU_ASSERT((uintptr_t)arr % ODP_CACHE_LINE_SIZE == 0);
+}
+
+static void test_aligned_page(void)
+{
+ uint8_t arr[123] ODP_ALIGNED_PAGE;
+
+ CU_ASSERT((uintptr_t)arr % ODP_PAGE_SIZE == 0);
+}
+
+static void test_cache_line_roundup(void)
+{
+ CU_ASSERT(ODP_CACHE_LINE_ROUNDUP(123) % ODP_CACHE_LINE_SIZE == 0);
+ CU_ASSERT(ODP_CACHE_LINE_ROUNDUP(ODP_CACHE_LINE_SIZE) == ODP_CACHE_LINE_SIZE);
+ CU_ASSERT(ODP_CACHE_LINE_ROUNDUP(0) == 0);
+}
+
+odp_testinfo_t align_suite[] = {
+ ODP_TEST_INFO(test_aligned),
+ ODP_TEST_INFO(test_packed),
+ ODP_TEST_INFO(test_offsetof),
+ ODP_TEST_INFO(test_field_sizeof),
+ ODP_TEST_INFO(test_cache_line_size),
+ ODP_TEST_INFO(test_page_size),
+ ODP_TEST_INFO(test_aligned_cache),
+ ODP_TEST_INFO(test_aligned_page),
+ ODP_TEST_INFO(test_cache_line_roundup),
+ ODP_TEST_INFO_NULL,
+};
+
+odp_suiteinfo_t align_suites[] = {
+ {"align", NULL, NULL, align_suite},
+ ODP_SUITE_INFO_NULL
+};
+
+int main(int argc, char *argv[])
+{
+ int ret;
+
+ /* Parse common options */
+ if (odp_cunit_parse_options(&argc, argv))
+ return -1;
+
+ ret = odp_cunit_register(align_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
+}
diff --git a/test/validation/api/atomic/atomic.c b/test/validation/api/atomic/atomic.c
index 76e3c0d49..fab982462 100644
--- a/test/validation/api/atomic/atomic.c
+++ b/test/validation/api/atomic/atomic.c
@@ -1702,7 +1702,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
odp_cunit_register_global_init(atomic_init);
diff --git a/test/validation/api/barrier/barrier.c b/test/validation/api/barrier/barrier.c
index e4fba770f..7dc9a44c6 100644
--- a/test/validation/api/barrier/barrier.c
+++ b/test/validation/api/barrier/barrier.c
@@ -444,7 +444,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
odp_cunit_register_global_init(barrier_init);
diff --git a/test/validation/api/buffer/buffer.c b/test/validation/api/buffer/buffer.c
index 91cfbfb5f..2a79ed27e 100644
--- a/test/validation/api/buffer/buffer.c
+++ b/test/validation/api/buffer/buffer.c
@@ -598,7 +598,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
ret = odp_cunit_register(buffer_suites);
diff --git a/test/validation/api/byteorder/.gitignore b/test/validation/api/byteorder/.gitignore
new file mode 100644
index 000000000..0b0d91053
--- /dev/null
+++ b/test/validation/api/byteorder/.gitignore
@@ -0,0 +1 @@
+byteorder_main
diff --git a/test/validation/api/byteorder/Makefile.am b/test/validation/api/byteorder/Makefile.am
new file mode 100644
index 000000000..186f4ecbc
--- /dev/null
+++ b/test/validation/api/byteorder/Makefile.am
@@ -0,0 +1,4 @@
+include ../Makefile.inc
+
+test_PROGRAMS = byteorder_main
+byteorder_main_SOURCES = byteorder.c
diff --git a/test/validation/api/byteorder/byteorder.c b/test/validation/api/byteorder/byteorder.c
new file mode 100644
index 000000000..087dfce95
--- /dev/null
+++ b/test/validation/api/byteorder/byteorder.c
@@ -0,0 +1,107 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2024 Nokia
+ */
+
+#include <odp_api.h>
+#include <odp_cunit_common.h>
+
+#include <stdint.h>
+
+static void test_defines(void)
+{
+ /* Endianness */
+ CU_ASSERT(ODP_BIG_ENDIAN || ODP_LITTLE_ENDIAN);
+
+ if (ODP_BIG_ENDIAN) {
+ CU_ASSERT(ODP_BYTE_ORDER == ODP_BIG_ENDIAN);
+ CU_ASSERT(!ODP_LITTLE_ENDIAN);
+ }
+
+ if (ODP_LITTLE_ENDIAN) {
+ CU_ASSERT(ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN);
+ CU_ASSERT(!ODP_BIG_ENDIAN);
+ }
+
+ /* Bitfield endianness */
+ CU_ASSERT(ODP_BIG_ENDIAN_BITFIELD || ODP_LITTLE_ENDIAN_BITFIELD);
+
+ if (ODP_BIG_ENDIAN_BITFIELD) {
+ CU_ASSERT(ODP_BITFIELD_ORDER == ODP_BIG_ENDIAN_BITFIELD);
+ CU_ASSERT(!ODP_LITTLE_ENDIAN_BITFIELD);
+ }
+
+ if (ODP_LITTLE_ENDIAN_BITFIELD) {
+ CU_ASSERT(ODP_BITFIELD_ORDER == ODP_LITTLE_ENDIAN_BITFIELD);
+ CU_ASSERT(!ODP_BIG_ENDIAN_BITFIELD);
+ }
+}
+
+static void test_types(void)
+{
+ const uint16_t u16_val = 0x1234;
+ const uint32_t u32_val = 0x12345678;
+ const uint64_t u64_val = 0x1234567890123456;
+ const uint16_t u16_val_conv = 0x3412;
+ const uint32_t u32_val_conv = 0x78563412;
+ const uint64_t u64_val_conv = 0x5634129078563412;
+ odp_u16be_t be16 = odp_cpu_to_be_16(u16_val);
+ odp_u32be_t be32 = odp_cpu_to_be_32(u32_val);
+ odp_u64be_t be64 = odp_cpu_to_be_64(u64_val);
+ odp_u16le_t le16 = odp_cpu_to_le_16(u16_val);
+ odp_u32le_t le32 = odp_cpu_to_le_32(u32_val);
+ odp_u64le_t le64 = odp_cpu_to_le_64(u64_val);
+ odp_u16sum_t sum16 = u16_val;
+ odp_u32sum_t sum32 = u16_val;
+
+ CU_ASSERT(sum16 == sum32);
+
+ if (ODP_BIG_ENDIAN) {
+ CU_ASSERT(be16 == u16_val);
+ CU_ASSERT(be32 == u32_val);
+ CU_ASSERT(be64 == u64_val);
+ CU_ASSERT(le16 == u16_val_conv);
+ CU_ASSERT(le32 == u32_val_conv);
+ CU_ASSERT(le64 == u64_val_conv);
+ } else {
+ CU_ASSERT(le16 == u16_val);
+ CU_ASSERT(le32 == u32_val);
+ CU_ASSERT(le64 == u64_val);
+ CU_ASSERT(be16 == u16_val_conv);
+ CU_ASSERT(be32 == u32_val_conv);
+ CU_ASSERT(be64 == u64_val_conv);
+ }
+
+ CU_ASSERT(odp_be_to_cpu_16(be16) == u16_val);
+ CU_ASSERT(odp_be_to_cpu_32(be32) == u32_val);
+ CU_ASSERT(odp_be_to_cpu_64(be64) == u64_val);
+ CU_ASSERT(odp_le_to_cpu_16(le16) == u16_val);
+ CU_ASSERT(odp_le_to_cpu_32(le32) == u32_val);
+ CU_ASSERT(odp_le_to_cpu_64(le64) == u64_val);
+}
+
+odp_testinfo_t byteorder_suite[] = {
+ ODP_TEST_INFO(test_defines),
+ ODP_TEST_INFO(test_types),
+ ODP_TEST_INFO_NULL,
+};
+
+odp_suiteinfo_t byteorder_suites[] = {
+ {"byteorder", NULL, NULL, byteorder_suite},
+ ODP_SUITE_INFO_NULL
+};
+
+int main(int argc, char *argv[])
+{
+ int ret;
+
+ /* Parse common options */
+ if (odp_cunit_parse_options(&argc, argv))
+ return -1;
+
+ ret = odp_cunit_register(byteorder_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
+}
diff --git a/test/validation/api/chksum/chksum.c b/test/validation/api/chksum/chksum.c
index 86306ab0b..0be418f3a 100644
--- a/test/validation/api/chksum/chksum.c
+++ b/test/validation/api/chksum/chksum.c
@@ -442,7 +442,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
ret = odp_cunit_register(chksum_suites);
diff --git a/test/validation/api/classification/classification.c b/test/validation/api/classification/classification.c
index ef35377dc..ef9a647cb 100644
--- a/test/validation/api/classification/classification.c
+++ b/test/validation/api/classification/classification.c
@@ -36,7 +36,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
ret = odp_cunit_register(classification_suites);
diff --git a/test/validation/api/comp/comp.c b/test/validation/api/comp/comp.c
index cb771c989..b7dfcd359 100644
--- a/test/validation/api/comp/comp.c
+++ b/test/validation/api/comp/comp.c
@@ -558,7 +558,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
odp_cunit_register_global_init(comp_init);
diff --git a/test/validation/api/cpumask/cpumask.c b/test/validation/api/cpumask/cpumask.c
index b358a5be6..db500df3a 100644
--- a/test/validation/api/cpumask/cpumask.c
+++ b/test/validation/api/cpumask/cpumask.c
@@ -188,7 +188,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
ret = odp_cunit_register(cpumask_suites);
diff --git a/test/validation/api/crypto/crypto_op_test.c b/test/validation/api/crypto/crypto_op_test.c
index 1c6944fdf..ae1465581 100644
--- a/test/validation/api/crypto/crypto_op_test.c
+++ b/test/validation/api/crypto/crypto_op_test.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2021-2023, Nokia
+ * Copyright (c) 2021-2024, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -50,7 +50,7 @@ int crypto_op(odp_packet_t pkt_in,
odp_crypto_op_type_t op_type)
{
int rc;
- odp_event_t event;
+ odp_event_t event, event2;
odp_crypto_packet_result_t result;
odp_event_subtype_t subtype;
odp_packet_t orig_pkt_out;
@@ -95,15 +95,19 @@ int crypto_op(odp_packet_t pkt_in,
if (op_type != ODP_CRYPTO_OP_TYPE_BASIC)
CU_ASSERT(*pkt_out == orig_pkt_out);
- CU_ASSERT(ODP_EVENT_PACKET ==
- odp_event_type(odp_packet_to_event(*pkt_out)));
- CU_ASSERT(ODP_EVENT_PACKET_CRYPTO ==
- odp_event_subtype(odp_packet_to_event(*pkt_out)));
- CU_ASSERT(ODP_EVENT_PACKET ==
- odp_event_types(odp_packet_to_event(*pkt_out), &subtype));
+
+ event = odp_packet_to_event(*pkt_out);
+ CU_ASSERT(ODP_EVENT_PACKET == odp_event_type(event));
+ CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == odp_event_subtype(event));
+ CU_ASSERT(ODP_EVENT_PACKET == odp_event_types(event, &subtype));
CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == subtype);
CU_ASSERT(odp_packet_subtype(*pkt_out) == ODP_EVENT_PACKET_CRYPTO);
+ event2 = odp_crypto_packet_to_event(*pkt_out);
+ CU_ASSERT(ODP_EVENT_PACKET == odp_event_type(event2));
+ CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == odp_event_subtype(event2));
+ CU_ASSERT(odp_event_to_u64(event) == odp_event_to_u64(event2));
+
rc = odp_crypto_result(&result, *pkt_out);
if (rc < -1)
CU_FAIL("Failed odp_crypto_result()");
diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c
index d5f2e3e7a..532aaf525 100644
--- a/test/validation/api/crypto/odp_crypto_test_inp.c
+++ b/test/validation/api/crypto/odp_crypto_test_inp.c
@@ -2399,7 +2399,7 @@ int main(int argc, char *argv[])
printf("Test mode: %s\n", full_test ? "full" : "partial");
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
odp_cunit_register_global_init(crypto_init);
diff --git a/test/validation/api/dma/dma.c b/test/validation/api/dma/dma.c
index 4f454168d..efc7fa039 100644
--- a/test/validation/api/dma/dma.c
+++ b/test/validation/api/dma/dma.c
@@ -1693,7 +1693,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
ret = odp_cunit_register(dma_suites);
diff --git a/test/validation/api/errno/errno.c b/test/validation/api/errno/errno.c
index ed2ab391d..70708ce01 100644
--- a/test/validation/api/errno/errno.c
+++ b/test/validation/api/errno/errno.c
@@ -33,7 +33,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
ret = odp_cunit_register(errno_suites);
diff --git a/test/validation/api/event/event.c b/test/validation/api/event/event.c
index f6ad86365..fbcc08d6f 100644
--- a/test/validation/api/event/event.c
+++ b/test/validation/api/event/event.c
@@ -461,7 +461,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
ret = odp_cunit_register(event_suites);
diff --git a/test/validation/api/hash/hash.c b/test/validation/api/hash/hash.c
index 5e4209800..a935ef7ac 100644
--- a/test/validation/api/hash/hash.c
+++ b/test/validation/api/hash/hash.c
@@ -753,7 +753,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
ret = odp_cunit_register(hash_suites);
diff --git a/test/validation/api/hints/.gitignore b/test/validation/api/hints/.gitignore
new file mode 100644
index 000000000..586f429bc
--- /dev/null
+++ b/test/validation/api/hints/.gitignore
@@ -0,0 +1 @@
+hints_main
diff --git a/test/validation/api/hints/Makefile.am b/test/validation/api/hints/Makefile.am
new file mode 100644
index 000000000..bcc77f606
--- /dev/null
+++ b/test/validation/api/hints/Makefile.am
@@ -0,0 +1,4 @@
+include ../Makefile.inc
+
+test_PROGRAMS = hints_main
+hints_main_SOURCES = hints.c
diff --git a/test/validation/api/hints/hints.c b/test/validation/api/hints/hints.c
new file mode 100644
index 000000000..4c049f33b
--- /dev/null
+++ b/test/validation/api/hints/hints.c
@@ -0,0 +1,92 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2024 Nokia
+ */
+
+#include <odp_api.h>
+#include <odp_cunit_common.h>
+
+#include <stdint.h>
+#include <stdlib.h>
+
+ODP_NORETURN static void test_noreturn(void)
+{
+ abort();
+}
+
+int test_weak(void);
+
+ODP_WEAK_SYMBOL int test_weak(void)
+{
+ return 0;
+}
+
+ODP_COLD_CODE static int test_cold(void)
+{
+ return -1;
+}
+
+ODP_HOT_CODE static int test_hot(void)
+{
+ return 1;
+}
+
+ODP_PRINTF_FORMAT(2, 3)
+static int test_printf_format(int level ODP_UNUSED, const char *fmt ODP_UNUSED, ...)
+{
+ return 0;
+}
+
+static void test_hints(void)
+{
+ volatile int val = 1;
+
+ if (odp_unlikely(!val))
+ test_noreturn();
+
+ test_weak();
+ test_cold();
+
+ if (odp_likely(val))
+ test_hot();
+
+ test_printf_format(0, "test");
+}
+
+static void test_prefetch(void)
+{
+ const int rounds = 10;
+ uint64_t data[rounds];
+
+ for (int i = 0; i < rounds; i++)
+ odp_prefetch(&data[i]);
+
+ for (int i = 0; i < rounds; i++)
+ odp_prefetch_store(&data[i]);
+}
+
+odp_testinfo_t hints_suite[] = {
+ ODP_TEST_INFO(test_hints),
+ ODP_TEST_INFO(test_prefetch),
+ ODP_TEST_INFO_NULL,
+};
+
+odp_suiteinfo_t align_suites[] = {
+ {"hints", NULL, NULL, hints_suite},
+ ODP_SUITE_INFO_NULL
+};
+
+int main(int argc, char *argv[])
+{
+ int ret;
+
+ /* Parse common options */
+ if (odp_cunit_parse_options(&argc, argv))
+ return -1;
+
+ ret = odp_cunit_register(align_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
+}
diff --git a/test/validation/api/init/.gitignore b/test/validation/api/init/.gitignore
index 4e14eb040..f0ce98bdd 100644
--- a/test/validation/api/init/.gitignore
+++ b/test/validation/api/init/.gitignore
@@ -1,9 +1 @@
-init_defaults
-init_abort
-init_log
-init_log_thread
-init_num_thr
-init_feature_enabled
-init_feature_disabled
-init_test_param_init
-init_test_term_abnormal
+init_main
diff --git a/test/validation/api/init/Makefile.am b/test/validation/api/init/Makefile.am
index 8226b87ce..7465f683f 100644
--- a/test/validation/api/init/Makefile.am
+++ b/test/validation/api/init/Makefile.am
@@ -1,27 +1,15 @@
include ../Makefile.inc
-# Keep init test cases in separate binaries. Some implementations may not allow
-# the same application process to call odp_init_global() multiple times.
-test_PROGRAMS = init_defaults init_abort init_log init_num_thr \
- init_feature_enabled init_feature_disabled init_log_thread \
- init_test_param_init init_test_term_abnormal
+test_PROGRAMS = init_main
+init_main_SOURCES = init_main.c
-init_defaults_CPPFLAGS = -DINIT_TEST=0 $(AM_CPPFLAGS)
-init_abort_CPPFLAGS = -DINIT_TEST=1 $(AM_CPPFLAGS)
-init_log_CPPFLAGS = -DINIT_TEST=2 $(AM_CPPFLAGS)
-init_num_thr_CPPFLAGS = -DINIT_TEST=3 $(AM_CPPFLAGS)
-init_feature_enabled_CPPFLAGS = -DINIT_TEST=4 $(AM_CPPFLAGS)
-init_feature_disabled_CPPFLAGS = -DINIT_TEST=5 $(AM_CPPFLAGS)
-init_log_thread_CPPFLAGS = -DINIT_TEST=6 $(AM_CPPFLAGS)
-init_test_param_init_CPPFLAGS = -DINIT_TEST=7 $(AM_CPPFLAGS)
-init_test_term_abnormal_CPPFLAGS = -DINIT_TEST=8 $(AM_CPPFLAGS)
-
-init_defaults_SOURCES = init_main.c
-init_abort_SOURCES = init_main.c
-init_log_SOURCES = init_main.c
-init_num_thr_SOURCES = init_main.c
-init_feature_enabled_SOURCES = init_main.c
-init_feature_disabled_SOURCES = init_main.c
-init_log_thread_SOURCES = init_main.c
-init_test_param_init_SOURCES = init_main.c
-init_test_term_abnormal_SOURCES = init_main.c
+EXTRA_DIST = \
+ init_defaults.sh \
+ init_abort.sh \
+ init_log.sh \
+ init_num_thr.sh \
+ init_feature_enabled.sh \
+ init_feature_disabled.sh \
+ init_log_thread.sh \
+ init_test_param_init.sh \
+ init_test_term_abnormal.sh
diff --git a/test/validation/api/init/init_abort.sh b/test/validation/api/init/init_abort.sh
new file mode 100755
index 000000000..27796fcf9
--- /dev/null
+++ b/test/validation/api/init/init_abort.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+TEST_DIR="${TEST_DIR:-$(dirname $0)/..}/init"
+$TEST_DIR/init_main$EXEEXT 1
diff --git a/test/validation/api/init/init_defaults.sh b/test/validation/api/init/init_defaults.sh
new file mode 100755
index 000000000..2215a65a9
--- /dev/null
+++ b/test/validation/api/init/init_defaults.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+TEST_DIR="${TEST_DIR:-$(dirname $0)/..}/init"
+$TEST_DIR/init_main$EXEEXT 0
diff --git a/test/validation/api/init/init_feature_disabled.sh b/test/validation/api/init/init_feature_disabled.sh
new file mode 100755
index 000000000..e538429b6
--- /dev/null
+++ b/test/validation/api/init/init_feature_disabled.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+TEST_DIR="${TEST_DIR:-$(dirname $0)/..}/init"
+$TEST_DIR/init_main$EXEEXT 5
diff --git a/test/validation/api/init/init_feature_enabled.sh b/test/validation/api/init/init_feature_enabled.sh
new file mode 100755
index 000000000..18237cbf9
--- /dev/null
+++ b/test/validation/api/init/init_feature_enabled.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+TEST_DIR="${TEST_DIR:-$(dirname $0)/..}/init"
+$TEST_DIR/init_main$EXEEXT 4
diff --git a/test/validation/api/init/init_log.sh b/test/validation/api/init/init_log.sh
new file mode 100755
index 000000000..cf4177ed5
--- /dev/null
+++ b/test/validation/api/init/init_log.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+TEST_DIR="${TEST_DIR:-$(dirname $0)/..}/init"
+$TEST_DIR/init_main$EXEEXT 2
diff --git a/test/validation/api/init/init_log_thread.sh b/test/validation/api/init/init_log_thread.sh
new file mode 100755
index 000000000..b0bb02220
--- /dev/null
+++ b/test/validation/api/init/init_log_thread.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+TEST_DIR="${TEST_DIR:-$(dirname $0)/..}/init"
+$TEST_DIR/init_main$EXEEXT 6
diff --git a/test/validation/api/init/init_main.c b/test/validation/api/init/init_main.c
index 64cefa30b..ab1db421b 100644
--- a/test/validation/api/init/init_main.c
+++ b/test/validation/api/init/init_main.c
@@ -1,8 +1,6 @@
-/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2015-2018 Linaro Limited
+ * Copyright (c) 2019-2024 Nokia
*/
#include <odp_api.h>
@@ -297,12 +295,19 @@ static int fill_testinfo(odp_testinfo_t *info, unsigned int test_case)
int main(int argc, char *argv[])
{
int ret;
+ int test_id;
- if (fill_testinfo(&init_suite[0], INIT_TEST))
+ /* Parse common options */
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
- /* Parse common options */
- if (odp_cunit_parse_options(argc, argv))
+ if (argc < 2) {
+ ODPH_ERR("Usage: init_main <test case number>\n");
+ return -1;
+ }
+ test_id = atoi(argv[1]);
+
+ if (fill_testinfo(&init_suite[0], test_id))
return -1;
/* Prevent default ODP init */
diff --git a/test/validation/api/init/init_num_thr.sh b/test/validation/api/init/init_num_thr.sh
new file mode 100755
index 000000000..3889d2a14
--- /dev/null
+++ b/test/validation/api/init/init_num_thr.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+TEST_DIR="${TEST_DIR:-$(dirname $0)/..}/init"
+$TEST_DIR/init_main$EXEEXT 3
diff --git a/test/validation/api/init/init_test_param_init.sh b/test/validation/api/init/init_test_param_init.sh
new file mode 100755
index 000000000..afb4d17a2
--- /dev/null
+++ b/test/validation/api/init/init_test_param_init.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+TEST_DIR="${TEST_DIR:-$(dirname $0)/..}/init"
+$TEST_DIR/init_main$EXEEXT 7
diff --git a/test/validation/api/init/init_test_term_abnormal.sh b/test/validation/api/init/init_test_term_abnormal.sh
new file mode 100755
index 000000000..b3edd8391
--- /dev/null
+++ b/test/validation/api/init/init_test_term_abnormal.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+TEST_DIR="${TEST_DIR:-$(dirname $0)/..}/init"
+$TEST_DIR/init_main$EXEEXT 8
diff --git a/test/validation/api/ipsec/.gitignore b/test/validation/api/ipsec/.gitignore
index 967356064..2def047f3 100644
--- a/test/validation/api/ipsec/.gitignore
+++ b/test/validation/api/ipsec/.gitignore
@@ -1,4 +1 @@
-ipsec_sync
-ipsec_async
-ipsec_inline_in
-ipsec_inline_out
+ipsec_main
diff --git a/test/validation/api/ipsec/Makefile.am b/test/validation/api/ipsec/Makefile.am
index 1a29d687d..51b50dd02 100644
--- a/test/validation/api/ipsec/Makefile.am
+++ b/test/validation/api/ipsec/Makefile.am
@@ -11,14 +11,15 @@ libtestipsec_la_SOURCES = \
reass_test_vectors.c
test_PROGRAMS = \
- ipsec_sync \
- ipsec_async \
- ipsec_inline_in \
- ipsec_inline_out
+ ipsec_main
-ipsec_sync_SOURCES = ipsec_sync.c
-ipsec_async_SOURCES = ipsec_async.c
-ipsec_inline_in_SOURCES = ipsec_inline_in.c
-ipsec_inline_out_SOURCES = ipsec_inline_out.c
+ipsec_main_SOURCES = \
+ ipsec_main.c
PRELDADD += libtestipsec.la
+
+EXTRA_DIST = \
+ ipsec_sync.sh \
+ ipsec_async.sh \
+ ipsec_inline_in.sh \
+ ipsec_inline_out.sh
diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c
index 9849a44b5..5ad7bd48d 100644
--- a/test/validation/api/ipsec/ipsec.c
+++ b/test/validation/api/ipsec/ipsec.c
@@ -29,7 +29,6 @@ static odp_ipsec_capability_t capa;
static int sched_ev_buffer_tail;
odp_bool_t sa_expiry_notified;
-
#define PKT_POOL_NUM 64
#define EVENT_WAIT_TIME ODP_TIME_SEC_IN_NS
#define STATUS_EVENT_WAIT_TIME ODP_TIME_MSEC_IN_NS
@@ -38,6 +37,8 @@ odp_bool_t sa_expiry_notified;
#define PACKET_USER_PTR ((void *)0x1212fefe)
#define IPSEC_SA_CTX ((void *)0xfefefafa)
+static int ipsec_config(void);
+
static odp_pktio_t pktio_create(odp_pool_t pool)
{
odp_pktio_t pktio;
@@ -1296,16 +1297,6 @@ int ipsec_suite_term(void)
return 0;
}
-int ipsec_in_term(void)
-{
- return ipsec_suite_term();
-}
-
-int ipsec_out_term(void)
-{
- return ipsec_suite_term();
-}
-
static odp_queue_t sched_queue_create(const char *name)
{
odp_queue_param_t qparam;
@@ -1366,12 +1357,10 @@ int ipsec_suite_sched_init(void)
return ipsec_suite_init();
}
-int ipsec_init(odp_instance_t *inst, odp_ipsec_op_mode_t mode)
+int ipsec_init(odp_instance_t *inst)
{
odp_pool_param_t params;
- odp_pool_t pool;
odp_pool_capability_t pool_capa;
- odp_pktio_t pktio;
odp_init_t init_param;
odph_helper_options_t helper_options;
@@ -1427,25 +1416,26 @@ int ipsec_init(odp_instance_t *inst, odp_ipsec_op_mode_t mode)
return -1;
}
- pool = odp_pool_create("packet_pool", &params);
+ suite_context.pool = odp_pool_create("packet_pool", &params);
- if (ODP_POOL_INVALID == pool) {
+ if (suite_context.pool == ODP_POOL_INVALID) {
ODPH_ERR("Packet pool creation failed\n");
return -1;
}
- if (mode == ODP_IPSEC_OP_MODE_INLINE) {
- pktio = pktio_create(pool);
- if (ODP_PKTIO_INVALID == pktio) {
+ if (suite_context.inbound_op_mode == ODP_IPSEC_OP_MODE_INLINE ||
+ suite_context.outbound_op_mode == ODP_IPSEC_OP_MODE_INLINE) {
+ suite_context.pktio = pktio_create(suite_context.pool);
+ if (suite_context.pktio == ODP_PKTIO_INVALID) {
ODPH_ERR("IPsec pktio creation failed\n");
return -1;
}
}
- return 0;
+ return ipsec_config();
}
-int ipsec_config(odp_instance_t ODP_UNUSED inst)
+static int ipsec_config(void)
{
odp_ipsec_config_t ipsec_config;
diff --git a/test/validation/api/ipsec/ipsec.h b/test/validation/api/ipsec/ipsec.h
index 8eed65c50..47612e3b3 100644
--- a/test/validation/api/ipsec/ipsec.h
+++ b/test/validation/api/ipsec/ipsec.h
@@ -20,9 +20,8 @@
extern odp_testinfo_t ipsec_in_suite[];
extern odp_testinfo_t ipsec_out_suite[];
-int ipsec_init(odp_instance_t *inst, odp_ipsec_op_mode_t mode);
+int ipsec_init(odp_instance_t *inst);
int ipsec_term(odp_instance_t inst);
-int ipsec_config(odp_instance_t inst);
int ipsec_in_inline_init(void);
int ipsec_out_inline_init(void);
@@ -31,8 +30,6 @@ int ipsec_suite_sync_init(void);
int ipsec_suite_plain_init(void);
int ipsec_suite_sched_init(void);
int ipsec_suite_term(void);
-int ipsec_in_term(void);
-int ipsec_out_term(void);
struct suite_context_s {
odp_bool_t reass_ipv4;
diff --git a/test/validation/api/ipsec/ipsec_async.c b/test/validation/api/ipsec/ipsec_async.c
deleted file mode 100644
index 44c968a4d..000000000
--- a/test/validation/api/ipsec/ipsec_async.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "ipsec.h"
-
-static int ipsec_async_init(odp_instance_t *inst)
-{
- int rc;
-
- suite_context.inbound_op_mode = ODP_IPSEC_OP_MODE_ASYNC;
- suite_context.outbound_op_mode = ODP_IPSEC_OP_MODE_ASYNC;
-
- rc = ipsec_init(inst, ODP_IPSEC_OP_MODE_ASYNC);
- if (rc != 0)
- return rc;
-
- suite_context.pool = odp_pool_lookup("packet_pool");
- if (suite_context.pool == ODP_POOL_INVALID)
- return -1;
-
- return ipsec_config(*inst);
-}
-
-odp_suiteinfo_t ipsec_suites[] = {
- {"IPsec-plain-in", ipsec_suite_plain_init, ipsec_suite_term,
- ipsec_in_suite},
- {"IPsec-sched-in", ipsec_suite_sched_init, ipsec_suite_term,
- ipsec_in_suite},
- {"IPsec-plain-out", ipsec_suite_plain_init, ipsec_suite_term,
- ipsec_out_suite},
- {"IPsec-sched-out", ipsec_suite_sched_init, ipsec_suite_term,
- ipsec_out_suite},
- ODP_SUITE_INFO_NULL,
-};
-
-int main(int argc, char *argv[])
-{
- int ret;
-
- /* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
- return -1;
-
- odp_cunit_register_global_init(ipsec_async_init);
- odp_cunit_register_global_term(ipsec_term);
-
- ret = odp_cunit_register(ipsec_suites);
- if (ret == 0)
- ret = odp_cunit_run();
-
- return ret;
-}
diff --git a/test/validation/api/ipsec/ipsec_async.sh b/test/validation/api/ipsec/ipsec_async.sh
new file mode 100755
index 000000000..c12f3e70a
--- /dev/null
+++ b/test/validation/api/ipsec/ipsec_async.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+TEST_DIR="${TEST_DIR:-$(dirname $0)/..}/ipsec"
+$TEST_DIR/ipsec_main$EXEEXT async
diff --git a/test/validation/api/ipsec/ipsec_inline_in.c b/test/validation/api/ipsec/ipsec_inline_in.c
deleted file mode 100644
index cbb3a178a..000000000
--- a/test/validation/api/ipsec/ipsec_inline_in.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "ipsec.h"
-
-static int ipsec_sync_init(odp_instance_t *inst)
-{
- int rc;
-
- suite_context.inbound_op_mode = ODP_IPSEC_OP_MODE_INLINE;
- suite_context.outbound_op_mode = ODP_IPSEC_OP_MODE_ASYNC;
-
- rc = ipsec_init(inst, ODP_IPSEC_OP_MODE_INLINE);
- if (rc != 0)
- return rc;
-
- suite_context.pool = odp_pool_lookup("packet_pool");
- if (suite_context.pool == ODP_POOL_INVALID)
- return -1;
- suite_context.pktio = odp_pktio_lookup("loop");
- if (suite_context.pktio == ODP_PKTIO_INVALID)
- return -1;
-
- return ipsec_config(*inst);
-}
-
-odp_suiteinfo_t ipsec_suites[] = {
- {"IPsec-plain-in", ipsec_suite_plain_init, ipsec_suite_term,
- ipsec_in_suite},
- {"IPsec-sched-in", ipsec_suite_sched_init, ipsec_suite_term,
- ipsec_in_suite},
- ODP_SUITE_INFO_NULL,
-};
-
-int main(int argc, char *argv[])
-{
- int ret;
-
- /* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
- return -1;
-
- odp_cunit_register_global_init(ipsec_sync_init);
- odp_cunit_register_global_term(ipsec_term);
-
- ret = odp_cunit_register(ipsec_suites);
- if (ret == 0)
- ret = odp_cunit_run();
-
- return ret;
-}
diff --git a/test/validation/api/ipsec/ipsec_inline_in.sh b/test/validation/api/ipsec/ipsec_inline_in.sh
new file mode 100755
index 000000000..c1d1fed36
--- /dev/null
+++ b/test/validation/api/ipsec/ipsec_inline_in.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+TEST_DIR="${TEST_DIR:-$(dirname $0)/..}/ipsec"
+$TEST_DIR/ipsec_main$EXEEXT inline-in
diff --git a/test/validation/api/ipsec/ipsec_inline_out.c b/test/validation/api/ipsec/ipsec_inline_out.c
deleted file mode 100644
index 3da19892b..000000000
--- a/test/validation/api/ipsec/ipsec_inline_out.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "ipsec.h"
-
-static int ipsec_sync_init(odp_instance_t *inst)
-{
- int rc;
-
- suite_context.inbound_op_mode = ODP_IPSEC_OP_MODE_ASYNC;
- suite_context.outbound_op_mode = ODP_IPSEC_OP_MODE_INLINE;
-
- rc = ipsec_init(inst, ODP_IPSEC_OP_MODE_INLINE);
- if (rc != 0)
- return rc;
-
- suite_context.pool = odp_pool_lookup("packet_pool");
- if (suite_context.pool == ODP_POOL_INVALID)
- return -1;
- suite_context.pktio = odp_pktio_lookup("loop");
- if (suite_context.pktio == ODP_PKTIO_INVALID)
- return -1;
-
- return ipsec_config(*inst);
-}
-
-odp_suiteinfo_t ipsec_suites[] = {
- {"IPsec-plain-out", ipsec_suite_plain_init, ipsec_suite_term,
- ipsec_out_suite},
- {"IPsec-sched-out", ipsec_suite_sched_init, ipsec_suite_term,
- ipsec_out_suite},
- ODP_SUITE_INFO_NULL,
-};
-
-int main(int argc, char *argv[])
-{
- int ret;
-
- /* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
- return -1;
-
- odp_cunit_register_global_init(ipsec_sync_init);
- odp_cunit_register_global_term(ipsec_term);
-
- ret = odp_cunit_register(ipsec_suites);
- if (ret == 0)
- ret = odp_cunit_run();
-
- return ret;
-}
diff --git a/test/validation/api/ipsec/ipsec_inline_out.sh b/test/validation/api/ipsec/ipsec_inline_out.sh
new file mode 100755
index 000000000..91ebccac7
--- /dev/null
+++ b/test/validation/api/ipsec/ipsec_inline_out.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+TEST_DIR="${TEST_DIR:-$(dirname $0)/..}/ipsec"
+$TEST_DIR/ipsec_main$EXEEXT inline-out
diff --git a/test/validation/api/ipsec/ipsec_main.c b/test/validation/api/ipsec/ipsec_main.c
new file mode 100644
index 000000000..2c343f063
--- /dev/null
+++ b/test/validation/api/ipsec/ipsec_main.c
@@ -0,0 +1,83 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2017-2018 Linaro Limited
+ * Copyright (c) 2024 Nokia
+ */
+
+#include <odp_api.h>
+#include <odp_cunit_common.h>
+#include "ipsec.h"
+
+odp_suiteinfo_t ipsec_sync_suites[] = {
+ {"IPsec-in", ipsec_suite_sync_init, ipsec_suite_term, ipsec_in_suite},
+ {"IPsec-out", ipsec_suite_sync_init, ipsec_suite_term, ipsec_out_suite},
+ ODP_SUITE_INFO_NULL,
+};
+
+odp_suiteinfo_t ipsec_async_suites[] = {
+ {"IPsec-plain-in", ipsec_suite_plain_init, ipsec_suite_term, ipsec_in_suite},
+ {"IPsec-sched-in", ipsec_suite_sched_init, ipsec_suite_term, ipsec_in_suite},
+ {"IPsec-plain-out", ipsec_suite_plain_init, ipsec_suite_term, ipsec_out_suite},
+ {"IPsec-sched-out", ipsec_suite_sched_init, ipsec_suite_term, ipsec_out_suite},
+ ODP_SUITE_INFO_NULL,
+};
+
+odp_suiteinfo_t ipsec_inline_in_suites[] = {
+ {"IPsec-plain-in", ipsec_suite_plain_init, ipsec_suite_term, ipsec_in_suite},
+ {"IPsec-sched-in", ipsec_suite_sched_init, ipsec_suite_term, ipsec_in_suite},
+ ODP_SUITE_INFO_NULL,
+};
+
+odp_suiteinfo_t ipsec_inline_out_suites[] = {
+ {"IPsec-plain-out", ipsec_suite_plain_init, ipsec_suite_term, ipsec_out_suite},
+ {"IPsec-sched-out", ipsec_suite_sched_init, ipsec_suite_term, ipsec_out_suite},
+ ODP_SUITE_INFO_NULL,
+};
+
+static void usage_exit(void)
+{
+ fprintf(stderr, "Usage: ipsec_main {sync|async|inline-in|inline-out}\n");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char *argv[])
+{
+ char *test_mode;
+ odp_suiteinfo_t *suites = NULL;
+ int ret;
+
+ if (odp_cunit_parse_options(&argc, argv))
+ return EXIT_FAILURE;
+
+ if (argc < 2)
+ usage_exit();
+ test_mode = argv[1];
+
+ if ((!strcmp(test_mode, "sync"))) {
+ suite_context.inbound_op_mode = ODP_IPSEC_OP_MODE_SYNC;
+ suite_context.outbound_op_mode = ODP_IPSEC_OP_MODE_SYNC;
+ suites = ipsec_sync_suites;
+ } else if ((!strcmp(test_mode, "async"))) {
+ suite_context.inbound_op_mode = ODP_IPSEC_OP_MODE_ASYNC;
+ suite_context.outbound_op_mode = ODP_IPSEC_OP_MODE_ASYNC;
+ suites = ipsec_async_suites;
+ } else if ((!strcmp(test_mode, "inline-in"))) {
+ suite_context.inbound_op_mode = ODP_IPSEC_OP_MODE_INLINE;
+ suite_context.outbound_op_mode = ODP_IPSEC_OP_MODE_ASYNC;
+ suites = ipsec_inline_in_suites;
+ } else if ((!strcmp(test_mode, "inline-out"))) {
+ suite_context.inbound_op_mode = ODP_IPSEC_OP_MODE_ASYNC;
+ suite_context.outbound_op_mode = ODP_IPSEC_OP_MODE_INLINE;
+ suites = ipsec_inline_out_suites;
+ } else {
+ usage_exit();
+ }
+
+ odp_cunit_register_global_init(ipsec_init);
+ odp_cunit_register_global_term(ipsec_term);
+ ret = odp_cunit_register(suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
+}
diff --git a/test/validation/api/ipsec/ipsec_sync.c b/test/validation/api/ipsec/ipsec_sync.c
deleted file mode 100644
index 74ae1fe19..000000000
--- a/test/validation/api/ipsec/ipsec_sync.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Copyright (c) 2017-2018, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "ipsec.h"
-
-static int ipsec_sync_init(odp_instance_t *inst)
-{
- int rc;
-
- suite_context.inbound_op_mode = ODP_IPSEC_OP_MODE_SYNC;
- suite_context.outbound_op_mode = ODP_IPSEC_OP_MODE_SYNC;
-
- rc = ipsec_init(inst, ODP_IPSEC_OP_MODE_SYNC);
- if (rc != 0)
- return rc;
-
- suite_context.pool = odp_pool_lookup("packet_pool");
- if (suite_context.pool == ODP_POOL_INVALID)
- return -1;
-
- return ipsec_config(*inst);
-}
-
-odp_suiteinfo_t ipsec_suites[] = {
- {"IPsec-in", ipsec_suite_sync_init, ipsec_in_term, ipsec_in_suite},
- {"IPsec-out", ipsec_suite_sync_init, ipsec_out_term, ipsec_out_suite},
- ODP_SUITE_INFO_NULL,
-};
-
-int main(int argc, char *argv[])
-{
- int ret;
-
- /* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
- return -1;
-
- odp_cunit_register_global_init(ipsec_sync_init);
- odp_cunit_register_global_term(ipsec_term);
-
- ret = odp_cunit_register(ipsec_suites);
- if (ret == 0)
- ret = odp_cunit_run();
-
- return ret;
-}
diff --git a/test/validation/api/ipsec/ipsec_sync.sh b/test/validation/api/ipsec/ipsec_sync.sh
new file mode 100755
index 000000000..2653ddc78
--- /dev/null
+++ b/test/validation/api/ipsec/ipsec_sync.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+TEST_DIR="${TEST_DIR:-$(dirname $0)/..}/ipsec"
+$TEST_DIR/ipsec_main$EXEEXT sync
diff --git a/test/validation/api/lock/lock.c b/test/validation/api/lock/lock.c
index 78c6ee79b..a4e6932c4 100644
--- a/test/validation/api/lock/lock.c
+++ b/test/validation/api/lock/lock.c
@@ -1246,7 +1246,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
odp_cunit_register_global_init(lock_init);
diff --git a/test/validation/api/ml/.gitignore b/test/validation/api/ml/.gitignore
new file mode 100644
index 000000000..be2347720
--- /dev/null
+++ b/test/validation/api/ml/.gitignore
@@ -0,0 +1 @@
+ml_main
diff --git a/test/validation/api/ml/Makefile.am b/test/validation/api/ml/Makefile.am
new file mode 100644
index 000000000..b7946a963
--- /dev/null
+++ b/test/validation/api/ml/Makefile.am
@@ -0,0 +1,4 @@
+include ../Makefile.inc
+
+test_PROGRAMS = ml_main
+ml_main_SOURCES = ml.c
diff --git a/test/validation/api/ml/ml.c b/test/validation/api/ml/ml.c
new file mode 100644
index 000000000..5f8be1b64
--- /dev/null
+++ b/test/validation/api/ml/ml.c
@@ -0,0 +1,572 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Nokia
+ */
+
+#include <odp_api.h>
+#include <odp/helper/odph_api.h>
+#include "odp_cunit_common.h"
+
+#define UAREA 0xaa
+#define NUM_COMPL 10u
+#define COMPL_POOL_NAME "ML compl pool"
+
+typedef struct global_t {
+ int disabled;
+ uint32_t num_compl;
+ odp_ml_capability_t ml_capa;
+} global_t;
+
+typedef struct {
+ uint32_t count;
+ uint8_t mark[NUM_COMPL];
+} uarea_init_t;
+
+static global_t global;
+
+static int ml_suite_init(void)
+{
+ memset(&global, 0, sizeof(global_t));
+
+ if (odp_ml_capability(&global.ml_capa)) {
+ ODPH_ERR("ML capability failed\n");
+ return -1;
+ }
+
+ if (global.ml_capa.max_models == 0) {
+ global.disabled = 1;
+ ODPH_DBG("ML test disabled\n");
+ return 0;
+ }
+
+ global.num_compl = ODPH_MIN(NUM_COMPL, global.ml_capa.pool.max_num);
+
+ return 0;
+}
+
+static int check_ml_support(void)
+{
+ if (global.disabled)
+ return ODP_TEST_INACTIVE;
+
+ return ODP_TEST_ACTIVE;
+}
+
+static void test_ml_capability(void)
+{
+ odp_ml_capability_t ml_capa;
+
+ memset(&ml_capa, 0, sizeof(odp_ml_capability_t));
+ CU_ASSERT(odp_ml_capability(&ml_capa) == 0);
+
+ if (ml_capa.max_models == 0)
+ return;
+
+ CU_ASSERT(ml_capa.max_model_size > 0);
+ CU_ASSERT(ml_capa.max_models_loaded > 0);
+ CU_ASSERT(ml_capa.max_inputs > 0);
+ CU_ASSERT(ml_capa.max_outputs > 0);
+ CU_ASSERT(ml_capa.max_segs_per_input > 0);
+ CU_ASSERT(ml_capa.max_segs_per_output > 0);
+ CU_ASSERT(ml_capa.min_input_align > 0);
+ CU_ASSERT(ml_capa.min_output_align > 0);
+
+ if ((ml_capa.load.compl_mode_mask | ml_capa.run.compl_mode_mask) &
+ ODP_ML_COMPL_MODE_EVENT) {
+ odp_pool_capability_t pool_capa;
+
+ CU_ASSERT_FATAL(odp_pool_capability(&pool_capa) == 0);
+
+ CU_ASSERT(ml_capa.pool.max_pools > 0);
+ CU_ASSERT(ml_capa.pool.max_pools <= pool_capa.max_pools);
+ CU_ASSERT(ml_capa.pool.max_num > 0);
+ CU_ASSERT(ml_capa.pool.max_cache_size >= ml_capa.pool.min_cache_size);
+ }
+
+ CU_ASSERT(ml_capa.load.compl_mode_mask);
+ CU_ASSERT(ml_capa.run.compl_mode_mask);
+
+ if (ml_capa.load.compl_mode_mask & ODP_ML_COMPL_MODE_EVENT)
+ CU_ASSERT(ml_capa.load.compl_queue_plain || ml_capa.load.compl_queue_sched);
+
+ if (ml_capa.run.compl_mode_mask & ODP_ML_COMPL_MODE_EVENT)
+ CU_ASSERT(ml_capa.run.compl_queue_plain || ml_capa.run.compl_queue_sched);
+}
+
+static void test_ml_param(uint8_t fill)
+{
+ odp_ml_config_t config;
+ odp_ml_model_param_t model_param;
+ odp_ml_compl_pool_param_t pool_param;
+ odp_ml_compl_param_t compl_param;
+ odp_ml_run_param_t run_param;
+
+ memset(&config, fill, sizeof(config));
+ odp_ml_config_init(&config);
+ CU_ASSERT(config.max_models_created == 1);
+ CU_ASSERT(config.max_models_loaded == 1);
+ CU_ASSERT(config.load_mode_mask == 0);
+ CU_ASSERT(config.run_mode_mask == 0);
+
+ memset(&model_param, fill, sizeof(model_param));
+ odp_ml_model_param_init(&model_param);
+ CU_ASSERT(model_param.max_compl_id == 0);
+ CU_ASSERT(!model_param.extra_stat_enable);
+ CU_ASSERT(model_param.extra_param == NULL);
+ CU_ASSERT(model_param.extra_info.num_inputs == 0);
+ CU_ASSERT(model_param.extra_info.num_outputs == 0);
+ CU_ASSERT(model_param.extra_info.input_format == NULL);
+ CU_ASSERT(model_param.extra_info.output_format == NULL);
+
+ memset(&pool_param, fill, sizeof(pool_param));
+ odp_ml_compl_pool_param_init(&pool_param);
+ CU_ASSERT(pool_param.uarea_size == 0);
+ CU_ASSERT(pool_param.uarea_init.args == NULL);
+ CU_ASSERT(pool_param.uarea_init.init_fn == NULL);
+ CU_ASSERT(pool_param.cache_size <= global.ml_capa.pool.max_cache_size);
+ CU_ASSERT(pool_param.cache_size >= global.ml_capa.pool.min_cache_size);
+
+ memset(&compl_param, fill, sizeof(compl_param));
+ odp_ml_compl_param_init(&compl_param);
+ CU_ASSERT(compl_param.user_ptr == NULL);
+
+ memset(&run_param, fill, sizeof(run_param));
+ odp_ml_run_param_init(&run_param);
+ CU_ASSERT(run_param.batch_size == 0);
+ CU_ASSERT(run_param.result == NULL);
+}
+
+static void test_ml_param_init(void)
+{
+ test_ml_param(0x00);
+ test_ml_param(0xff);
+}
+
+static void test_ml_debug(void)
+{
+ odp_ml_print();
+}
+
+static void ml_compl_pool_create_max_pools(void)
+{
+ int ret;
+ uint32_t i, j;
+ odp_ml_compl_pool_param_t ml_pool_param;
+ uint32_t max_pools = global.ml_capa.pool.max_pools;
+ odp_pool_t compl_pools[max_pools];
+
+ odp_ml_compl_pool_param_init(&ml_pool_param);
+ ml_pool_param.num = global.num_compl;
+ for (i = 0; i < max_pools; i++) {
+ compl_pools[i] = odp_ml_compl_pool_create(NULL, &ml_pool_param);
+
+ if (compl_pools[i] == ODP_POOL_INVALID)
+ break;
+ }
+
+ CU_ASSERT(i == max_pools);
+
+ /* Destroy the created valid pools */
+ for (j = 0; j < i; j++) {
+ ret = odp_pool_destroy(compl_pools[j]);
+ CU_ASSERT(ret == 0);
+
+ if (ret == -1)
+ ODPH_ERR("ML completion pool destroy failed: %u / %u\n", j, i);
+ }
+}
+
+static void compl_pool_info(void)
+{
+ odp_pool_t pool;
+ odp_pool_t compl_pool;
+ odp_pool_info_t pool_info;
+ odp_ml_compl_pool_param_t pool_param;
+
+ /* Create an ML job completion pool */
+ odp_ml_compl_pool_param_init(&pool_param);
+ pool_param.num = global.num_compl;
+
+ compl_pool = odp_ml_compl_pool_create(COMPL_POOL_NAME, &pool_param);
+ CU_ASSERT_FATAL(compl_pool != ODP_POOL_INVALID);
+
+ /* Verify info about the created ML completion pool compl_pool */
+ pool = odp_pool_lookup(COMPL_POOL_NAME);
+ CU_ASSERT(pool == compl_pool);
+
+ memset(&pool_info, 0x66, sizeof(odp_pool_info_t));
+ CU_ASSERT_FATAL(odp_pool_info(compl_pool, &pool_info) == 0);
+
+ CU_ASSERT(!strcmp(pool_info.name, COMPL_POOL_NAME));
+ CU_ASSERT(pool_info.pool_ext == 0);
+ CU_ASSERT(pool_info.type == ODP_POOL_ML_COMPL);
+ CU_ASSERT(pool_info.ml_pool_param.num == NUM_COMPL);
+ CU_ASSERT(pool_info.ml_pool_param.uarea_size == 0);
+ CU_ASSERT(pool_info.ml_pool_param.cache_size == pool_param.cache_size);
+
+ CU_ASSERT_FATAL(odp_pool_destroy(compl_pool) == 0);
+}
+
+static void compl_alloc_max(void)
+{
+ uint64_t u64;
+ odp_event_t event;
+ odp_pool_t compl_pool;
+ odp_ml_compl_pool_param_t pool_param;
+ const int num = ODPH_MIN(global.ml_capa.pool.max_num, 1000000u);
+ odp_ml_compl_t *compl = malloc(num * sizeof(odp_ml_compl_t));
+
+ CU_ASSERT_FATAL(compl != NULL);
+
+ /* Create an ML job completion pool */
+ odp_ml_compl_pool_param_init(&pool_param);
+ pool_param.num = num;
+
+ compl_pool = odp_ml_compl_pool_create(COMPL_POOL_NAME, &pool_param);
+ CU_ASSERT_FATAL(compl_pool != ODP_POOL_INVALID);
+
+ for (int i = 0; i < num; i++) {
+ compl[i] = odp_ml_compl_alloc(compl_pool);
+ CU_ASSERT_FATAL(compl[i] != ODP_ML_COMPL_INVALID);
+
+ u64 = odp_ml_compl_to_u64(compl[i]);
+ CU_ASSERT(u64 != odp_ml_compl_to_u64(ODP_ML_COMPL_INVALID));
+
+ event = odp_ml_compl_to_event(compl[i]);
+ CU_ASSERT(odp_event_type(event) == ODP_EVENT_ML_COMPL);
+ }
+
+ for (int i = 0; i < num; i++)
+ odp_ml_compl_free(compl[i]);
+
+ free(compl);
+
+ CU_ASSERT_FATAL(odp_pool_destroy(compl_pool) == 0);
+}
+
+static void compl_pool_lookup(void)
+{
+ odp_pool_t pool, pool_a, pool_b;
+ odp_ml_compl_pool_param_t pool_param;
+
+ /* Create an ML job completion pool */
+ odp_ml_compl_pool_param_init(&pool_param);
+ pool_param.num = global.num_compl;
+
+ pool_a = odp_ml_compl_pool_create(COMPL_POOL_NAME, &pool_param);
+ CU_ASSERT_FATAL(pool_a != ODP_POOL_INVALID);
+
+ pool = odp_pool_lookup(COMPL_POOL_NAME);
+ CU_ASSERT(pool == pool_a);
+
+ /* Second pool with the same name */
+ pool_b = odp_ml_compl_pool_create(COMPL_POOL_NAME, &pool_param);
+ CU_ASSERT_FATAL(pool_b != ODP_POOL_INVALID);
+
+ pool = odp_pool_lookup(COMPL_POOL_NAME);
+ CU_ASSERT(pool == pool_a || pool == pool_b);
+
+ CU_ASSERT(odp_pool_destroy(pool_a) == 0);
+ CU_ASSERT(odp_pool_destroy(pool_b) == 0);
+}
+
+static int check_event_user_area(void)
+{
+ if (global.disabled)
+ return ODP_TEST_INACTIVE;
+
+ if (((global.ml_capa.load.compl_mode_mask | global.ml_capa.run.compl_mode_mask) &
+ ODP_ML_COMPL_MODE_EVENT) &&
+ (global.ml_capa.pool.max_uarea_size > 0))
+ return ODP_TEST_ACTIVE;
+
+ return ODP_TEST_INACTIVE;
+}
+
+static void test_ml_compl_user_area(void)
+{
+ uint32_t i;
+ void *addr;
+ void *prev;
+ odp_pool_t pool;
+ odp_ml_compl_pool_param_t pool_param;
+ uint32_t size = global.ml_capa.pool.max_uarea_size;
+ uint32_t num = global.num_compl;
+ odp_ml_compl_t compl_evs[num];
+
+ odp_ml_compl_pool_param_init(&pool_param);
+ pool_param.num = num;
+ pool_param.uarea_size = size;
+ pool = odp_ml_compl_pool_create(NULL, &pool_param);
+ CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+
+ prev = NULL;
+ for (i = 0; i < num; i++) {
+ odp_event_t ev;
+ int flag = 0;
+
+ compl_evs[i] = odp_ml_compl_alloc(pool);
+
+ if (compl_evs[i] == ODP_ML_COMPL_INVALID)
+ break;
+
+ addr = odp_ml_compl_user_area(compl_evs[i]);
+
+ CU_ASSERT_FATAL(addr != NULL);
+ CU_ASSERT(prev != addr);
+
+ memset(addr, 0, size);
+
+ ev = odp_ml_compl_to_event(compl_evs[i]);
+ CU_ASSERT(odp_event_user_area(ev) == addr);
+ CU_ASSERT(odp_event_user_area_and_flag(ev, &flag) == addr);
+ CU_ASSERT(flag < 0);
+
+ prev = addr;
+ }
+ CU_ASSERT(i == num);
+
+ for (uint32_t j = 0; j < i; j++)
+ odp_ml_compl_free(compl_evs[j]);
+
+ CU_ASSERT(odp_pool_destroy(pool) == 0);
+}
+
+static int check_event_user_area_init(void)
+{
+ if (global.disabled)
+ return ODP_TEST_INACTIVE;
+
+ if (global.ml_capa.pool.max_uarea_size > 0 && global.ml_capa.pool.uarea_persistence)
+ return ODP_TEST_ACTIVE;
+
+ return ODP_TEST_INACTIVE;
+}
+
+static void init_event_uarea(void *uarea, uint32_t size, void *args, uint32_t index)
+{
+ uarea_init_t *data = args;
+
+ data->count++;
+ data->mark[index] = 1;
+ memset(uarea, UAREA, size);
+}
+
+static void test_ml_compl_user_area_init(void)
+{
+ odp_ml_compl_pool_param_t pool_param;
+ uint32_t num = global.num_compl, i;
+ odp_pool_t pool;
+ uarea_init_t data;
+ odp_ml_compl_t compl_evs[num];
+ uint8_t *uarea;
+
+ memset(&data, 0, sizeof(uarea_init_t));
+ odp_ml_compl_pool_param_init(&pool_param);
+ pool_param.uarea_init.init_fn = init_event_uarea;
+ pool_param.uarea_init.args = &data;
+ pool_param.num = num;
+ pool_param.uarea_size = 1;
+ pool = odp_ml_compl_pool_create(NULL, &pool_param);
+
+ CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
+ CU_ASSERT(data.count == num);
+
+ for (i = 0; i < num; i++) {
+ CU_ASSERT(data.mark[i] == 1);
+
+ compl_evs[i] = odp_ml_compl_alloc(pool);
+
+ CU_ASSERT(compl_evs[i] != ODP_ML_COMPL_INVALID);
+
+ if (compl_evs[i] == ODP_ML_COMPL_INVALID)
+ break;
+
+ uarea = odp_ml_compl_user_area(compl_evs[i]);
+
+ CU_ASSERT(*uarea == UAREA);
+ }
+
+ for (uint32_t j = 0; j < i; j++)
+ odp_ml_compl_free(compl_evs[j]);
+
+ odp_pool_destroy(pool);
+}
+
+static void test_ml_fp32_to_uint8(void)
+{
+ uint8_t u8[8];
+ float fp[8] = {-20.f, -16.4f, -14.6f, -12.5f, 0, 31.4f, 80.f, 96.3f};
+ uint8_t expected[8] = {0, 0, 4, 10, 43, 127, 255, 255};
+ float scale = 0.3746f;
+ uint8_t zero_point = 43;
+
+ odp_ml_fp32_to_uint8(u8, fp, 8, scale, zero_point);
+ for (uint32_t i = 0; i < 8; i++)
+ CU_ASSERT(u8[i] == expected[i]);
+}
+
+static void test_ml_fp32_from_uint8(void)
+{
+ float fp[4];
+ float scale = 0.4f;
+ uint8_t zero_point = 43;
+ uint8_t u8[4] = {0, 43, 145, 255};
+ float expected[4] = {-17.2f, 0.0f, 40.8f, 84.8f};
+
+ odp_ml_fp32_from_uint8(fp, u8, 4, scale, zero_point);
+ for (uint32_t i = 0; i < 4; i++)
+ CU_ASSERT(fp[i] == expected[i]);
+}
+
+static void test_ml_fp32_to_int8(void)
+{
+ int8_t i8[5];
+ float scale = 0.0223f;
+ int8_t zero_point = 0;
+ float fp32[5] = {-3.4f, -2.5f, 0, 1.4f, 2.9f};
+ int8_t i8_expected[5] = {-127, -112, 0, 63, 127};
+
+ odp_ml_fp32_to_int8(i8, fp32, 5, scale, zero_point);
+
+ for (uint32_t i = 0; i < 5; i++)
+ CU_ASSERT(i8[i] == i8_expected[i]);
+}
+
+static void test_ml_fp32_to_int8_positive_zp(void)
+{
+ int8_t i8[6];
+ float scale = 0.0223f;
+ int8_t zero_point = 56;
+ float fp32[6] = {-4.1f, -3.4f, -2.5f, 0, 1.4f, 2.9f};
+ int8_t i8_expected[6] = {-127, -96, -56, 56, 119, 127};
+
+ odp_ml_fp32_to_int8(i8, fp32, 6, scale, zero_point);
+
+ for (uint32_t i = 0; i < 6; i++)
+ CU_ASSERT(i8[i] == i8_expected[i]);
+}
+
+static void test_ml_fp32_to_int8_negative_zp(void)
+{
+ int8_t i8[6];
+ float scale = 0.0223f;
+ int8_t zero_point = -56;
+ float fp32[6] = {-3.4f, -2.5f, 0, 1.4f, 2.9f, 4.1f};
+ int8_t i8_expected[6] = {-127, -127, -56, 7, 74, 127};
+
+ odp_ml_fp32_to_int8(i8, fp32, 6, scale, zero_point);
+
+ for (uint32_t i = 0; i < 6; i++)
+ CU_ASSERT(i8[i] == i8_expected[i]);
+}
+
+static void test_ml_fp32_from_int8(void)
+{
+ float fp32[6];
+ float scale = 0.05f;
+ int8_t zero_point = 56;
+ int8_t i8[6] = {-128, 46, 0, 56, 85, 127};
+ float fp32_expected[6] = {-9.2f, -0.5f, -2.8f, 0.0f, 1.45f, 3.55f};
+
+ odp_ml_fp32_from_int8(fp32, i8, 6, scale, zero_point);
+
+ for (uint32_t i = 0; i < 6; i++)
+ CU_ASSERT(fp32[i] == fp32_expected[i]);
+}
+
+static int approx_equal(double a, double b)
+{
+ const double tolerance = .01;
+
+ if (a < 0 && b < 0) {
+ a = -a;
+ b = -b;
+ }
+
+ if (a < b) {
+ double tmp = a;
+
+ a = b;
+ b = tmp;
+ }
+
+ return (a * (1 - tolerance) < b && a * (1 + tolerance) > b);
+}
+
+static void test_ml_fp32_fp16(void)
+{
+ float fp32[4];
+ uint16_t fp16[4];
+ float big = 1, small = 1;
+ const float phi = 1.618033988749;
+
+ fp32[0] = 0.0;
+ fp32[1] = -0.0;
+ memset(fp16, 1, sizeof(fp16));
+ odp_ml_fp32_to_fp16(fp16, fp32, 2);
+ memset(fp32, 1, sizeof(fp32));
+ odp_ml_fp32_from_fp16(fp32, fp16, 2);
+ CU_ASSERT(fp32[0] == 0);
+ CU_ASSERT(fp32[1] == 0);
+
+ /*
+ * 65504 is the largest normal number for fp16 with 5 exponent bits (IEEE 754-2008).
+ */
+ while (big < 65504 / 2) {
+ fp32[0] = big;
+ fp32[1] = -big;
+ fp32[2] = small;
+ fp32[3] = -small;
+ memset(fp16, 0, sizeof(fp16));
+ odp_ml_fp32_to_fp16(fp16, fp32, 4);
+ memset(fp32, 0, sizeof(fp32));
+ odp_ml_fp32_from_fp16(fp32, fp16, 4);
+ CU_ASSERT(approx_equal(fp32[0], big));
+ CU_ASSERT(approx_equal(fp32[1], -big));
+ CU_ASSERT(approx_equal(fp32[2], small));
+ CU_ASSERT(approx_equal(fp32[3], -small));
+ big *= phi;
+ small /= phi;
+ }
+}
+
+odp_testinfo_t ml_suite[] = {
+ ODP_TEST_INFO(test_ml_capability),
+ ODP_TEST_INFO_CONDITIONAL(test_ml_param_init, check_ml_support),
+ ODP_TEST_INFO_CONDITIONAL(test_ml_debug, check_ml_support),
+ ODP_TEST_INFO_CONDITIONAL(ml_compl_pool_create_max_pools, check_ml_support),
+ ODP_TEST_INFO_CONDITIONAL(compl_pool_info, check_ml_support),
+ ODP_TEST_INFO_CONDITIONAL(compl_alloc_max, check_ml_support),
+ ODP_TEST_INFO_CONDITIONAL(compl_pool_lookup, check_ml_support),
+ ODP_TEST_INFO_CONDITIONAL(test_ml_compl_user_area, check_event_user_area),
+ ODP_TEST_INFO_CONDITIONAL(test_ml_compl_user_area_init, check_event_user_area_init),
+ ODP_TEST_INFO_CONDITIONAL(test_ml_fp32_to_uint8, check_ml_support),
+ ODP_TEST_INFO_CONDITIONAL(test_ml_fp32_from_uint8, check_ml_support),
+ ODP_TEST_INFO_CONDITIONAL(test_ml_fp32_to_int8, check_ml_support),
+ ODP_TEST_INFO_CONDITIONAL(test_ml_fp32_to_int8_positive_zp, check_ml_support),
+ ODP_TEST_INFO_CONDITIONAL(test_ml_fp32_to_int8_negative_zp, check_ml_support),
+ ODP_TEST_INFO_CONDITIONAL(test_ml_fp32_from_int8, check_ml_support),
+ ODP_TEST_INFO_CONDITIONAL(test_ml_fp32_fp16, check_ml_support),
+ ODP_TEST_INFO_NULL
+};
+
+odp_suiteinfo_t ml_suites[] = {
+ {"ML", ml_suite_init, NULL, ml_suite},
+ ODP_SUITE_INFO_NULL
+};
+
+int main(int argc, char *argv[])
+{
+ int ret;
+
+ /* parse common options: */
+ if (odp_cunit_parse_options(&argc, argv))
+ return -1;
+
+ ret = odp_cunit_register(ml_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
+}
diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c
index 77a0f8494..ca9c73f17 100644
--- a/test/validation/api/packet/packet.c
+++ b/test/validation/api/packet/packet.c
@@ -4585,7 +4585,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
ret = odp_cunit_register(packet_suites);
diff --git a/test/validation/api/pktio/lso.c b/test/validation/api/pktio/lso.c
index 3e033ee8b..832c08859 100644
--- a/test/validation/api/pktio/lso.c
+++ b/test/validation/api/pktio/lso.c
@@ -689,9 +689,9 @@ static void lso_send_custom_eth(const uint8_t *test_packet, uint32_t pkt_len, ui
ODPH_DBG("\n Sent payload length: %u bytes\n", sent_payload);
- /* Wait 1 sec to receive all created segments. Timeout and MAX_NUM_SEG values should be
+ /* Wait a bit to receive all created segments. Timeout and MAX_NUM_SEG values should be
* large enough to ensure that we receive all created segments. */
- num = recv_packets(pktio_b, ODP_TIME_SEC_IN_NS, pkt_out, MAX_NUM_SEG);
+ num = recv_packets(pktio_b, 100 * ODP_TIME_MSEC_IN_NS, pkt_out, MAX_NUM_SEG);
CU_ASSERT(num > 0);
CU_ASSERT(num < MAX_NUM_SEG);
@@ -814,9 +814,9 @@ static void lso_send_ipv4(const uint8_t *test_packet, uint32_t pkt_len, uint32_t
ODPH_DBG("\n Sent payload length: %u bytes\n", sent_payload);
- /* Wait 1 sec to receive all created segments. Timeout and MAX_NUM_SEG values should be
+ /* Wait a bit to receive all created segments. Timeout and MAX_NUM_SEG values should be
* large enough to ensure that we receive all created segments. */
- num = recv_packets(pktio_b, ODP_TIME_SEC_IN_NS, packet, MAX_NUM_SEG);
+ num = recv_packets(pktio_b, 100 * ODP_TIME_MSEC_IN_NS, packet, MAX_NUM_SEG);
CU_ASSERT(num > 0);
CU_ASSERT(num < MAX_NUM_SEG);
diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c
index 780d83066..deef4895a 100644
--- a/test/validation/api/pktio/pktio.c
+++ b/test/validation/api/pktio/pktio.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2020-2023, Nokia
+ * Copyright (c) 2020-2024, Nokia
* Copyright (c) 2020, Marvell
* All rights reserved.
*
@@ -11,6 +11,7 @@
#include <odp/helper/odph_api.h>
+#include <inttypes.h>
#include <stdlib.h>
#include "parser.h"
#include "lso.h"
@@ -3303,7 +3304,7 @@ static void pktio_test_pktin_ts(void)
odp_packet_t pkt_tbl[TX_BATCH_LEN];
uint32_t pkt_seq[TX_BATCH_LEN];
uint64_t ns1, ns2;
- uint64_t res, res_ns;
+ uint64_t res, res_ns, input_delay;
odp_time_t ts_prev;
odp_time_t ts;
int num_rx = 0;
@@ -3366,6 +3367,18 @@ static void pktio_test_pktin_ts(void)
1, TXRX_MODE_SINGLE, ODP_TIME_SEC_IN_NS, false);
if (ret != 1)
break;
+
+ /* Compare to packet IO time to input timestamp */
+ ts = odp_pktio_time(pktio_rx_info.id, NULL);
+ CU_ASSERT_FATAL(odp_packet_has_ts(pkt_tbl[i]));
+ ts_prev = odp_packet_ts(pkt_tbl[i]);
+ CU_ASSERT(odp_time_cmp(ts, ts_prev) >= 0);
+ input_delay = odp_time_diff_ns(ts, ts_prev);
+ if (input_delay > 100 * ODP_TIME_MSEC_IN_NS) {
+ printf(" Test packet %d input delay: %" PRIu64 "ns\n", i, input_delay);
+ CU_FAIL("Packet input delay too long");
+ }
+
odp_time_wait_ns(PKTIO_TS_INTERVAL);
}
num_rx = i;
@@ -5097,7 +5110,7 @@ static void pktio_test_pktin_event_queue(odp_pktin_mode_t pktin_mode)
int num_buf = 0;
int num_bad = 0;
odp_pktio_t pktio[MAX_NUM_IFACES] = {0};
- uint64_t wait_sec = odp_schedule_wait_time(ODP_TIME_SEC_IN_NS);
+ uint64_t wait_time = odp_schedule_wait_time(100 * ODP_TIME_MSEC_IN_NS);
CU_ASSERT_FATAL(num_ifaces >= 1);
@@ -5170,9 +5183,9 @@ static void pktio_test_pktin_event_queue(odp_pktin_mode_t pktin_mode)
/* Receive events */
while (1) {
- /* Break after 1 sec of inactivity */
+ /* Break after a period of inactivity */
if (pktin_mode == ODP_PKTIN_MODE_SCHED) {
- ev = odp_schedule(&from, wait_sec);
+ ev = odp_schedule(&from, wait_time);
if (ev == ODP_EVENT_INVALID)
break;
@@ -5492,7 +5505,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
ret = odp_cunit_register(pktio_suites);
diff --git a/test/validation/api/pool/pool.c b/test/validation/api/pool/pool.c
index ee8aa4b67..86a47230a 100644
--- a/test/validation/api/pool/pool.c
+++ b/test/validation/api/pool/pool.c
@@ -1718,7 +1718,8 @@ static void test_packet_pool_ext_capa(void)
odp_pool_ext_capability_t capa;
odp_pool_type_t type;
const odp_pool_type_t unsupported_types[] = {ODP_POOL_BUFFER, ODP_POOL_TIMEOUT,
- ODP_POOL_VECTOR, ODP_POOL_DMA_COMPL};
+ ODP_POOL_VECTOR, ODP_POOL_DMA_COMPL,
+ ODP_POOL_ML_COMPL};
const int num_types = ODPH_ARRAY_SIZE(unsupported_types);
/* Verify operation for unsupported pool types */
@@ -2373,7 +2374,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
ret = odp_cunit_register(pool_suites);
diff --git a/test/validation/api/queue/queue.c b/test/validation/api/queue/queue.c
index cb2b147ac..4b5ccde65 100644
--- a/test/validation/api/queue/queue.c
+++ b/test/validation/api/queue/queue.c
@@ -1164,7 +1164,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
ret = odp_cunit_register(queue_suites);
diff --git a/test/validation/api/random/random.c b/test/validation/api/random/random.c
index 97e367678..551fe775d 100644
--- a/test/validation/api/random/random.c
+++ b/test/validation/api/random/random.c
@@ -313,11 +313,10 @@ static void random_test_independence(odp_random_kind_t kind)
for (int i = 0; i < 256; i++) {
for (int j = 0; j < 256; j++) {
- double expected =
- (double)row[i] * (double)col[j] / (double)num;
- double diff =
- (double)freq[i][j] - expected;
- chisq += diff * diff / expected;
+ double expect = (double)row[i] * (double)col[j] / (double)num;
+ double diff = (double)freq[i][j] - expect;
+
+ chisq += diff * diff / expect;
}
}
@@ -527,7 +526,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
ret = odp_cunit_register(random_suites);
diff --git a/test/validation/api/scheduler/scheduler.c b/test/validation/api/scheduler/scheduler.c
index 8f450a057..8dddd8d8f 100644
--- a/test/validation/api/scheduler/scheduler.c
+++ b/test/validation/api/scheduler/scheduler.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2014-2018, Linaro Limited
- * Copyright (c) 2019-2022, Nokia
+ * Copyright (c) 2019-2024, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -54,9 +54,9 @@
#define CHAOS_PTR_TO_NDX(p) ((uint64_t)(uint32_t)(uintptr_t)p)
#define CHAOS_NDX_TO_PTR(n) ((void *)(uintptr_t)n)
-#define WAIT_TIMEOUT (1000 * ODP_TIME_MSEC_IN_NS)
+#define WAIT_TIMEOUT (100 * ODP_TIME_MSEC_IN_NS)
#define WAIT_ROUNDS 5
-#define WAIT_TOLERANCE (150 * ODP_TIME_MSEC_IN_NS)
+#define WAIT_TOLERANCE (15 * ODP_TIME_MSEC_IN_NS)
#define WAIT_1MS_RETRIES 1000
#define SCHED_AND_PLAIN_ROUNDS 10000
@@ -1355,7 +1355,7 @@ static void chaos_run(unsigned int qtype)
test_globals_t *globals;
thread_args_t *args;
odp_shm_t shm;
- int i, rc, num_thr;
+ int i, rc;
void *arg_ptr;
odp_schedule_sync_t sync[] = {ODP_SCHED_SYNC_PARALLEL,
ODP_SCHED_SYNC_ATOMIC,
@@ -1418,16 +1418,10 @@ static void chaos_run(unsigned int qtype)
CU_ASSERT_FATAL(rc == 0);
}
- /* Test runs also on the main thread */
- num_thr = globals->num_workers - 1;
arg_ptr = args;
- if (num_thr > 0)
- odp_cunit_thread_create(num_thr, chaos_thread, &arg_ptr, 0, 0);
+ odp_cunit_thread_create(globals->num_workers, chaos_thread, &arg_ptr, 0, 0);
- chaos_thread(args);
-
- if (num_thr > 0)
- odp_cunit_thread_join(num_thr);
+ odp_cunit_thread_join(globals->num_workers);
if (CHAOS_DEBUG)
printf("Thread %d returning from chaos threads..cleaning up\n",
@@ -1475,8 +1469,7 @@ static int schedule_common_(void *arg)
odp_pool_t pool;
int locked;
int num;
- odp_event_t ev;
- odp_buffer_t buf, buf_cpy;
+ odp_buffer_t buf;
odp_queue_t from;
globals = args->globals;
@@ -1559,7 +1552,8 @@ static int schedule_common_(void *arg)
odp_event_free(events[j]);
}
} else {
- ev = odp_schedule(&from, ODP_SCHED_NO_WAIT);
+ odp_event_t ev = odp_schedule(&from, ODP_SCHED_NO_WAIT);
+
if (ev == ODP_EVENT_INVALID)
continue;
@@ -1570,6 +1564,7 @@ static int schedule_common_(void *arg)
uint32_t ndx;
uint32_t ndx_max;
int rc;
+ odp_buffer_t buf_cpy;
ndx_max = odp_queue_lock_count(from);
CU_ASSERT_FATAL(ndx_max > 0);
@@ -1830,7 +1825,6 @@ static void parallel_execute(odp_schedule_sync_t sync, int num_queues,
test_globals_t *globals;
thread_args_t *args;
void *arg_ptr;
- int num;
shm = odp_shm_lookup(GLOBALS_SHM_NAME);
CU_ASSERT_FATAL(shm != ODP_SHM_INVALID);
@@ -1860,18 +1854,11 @@ static void parallel_execute(odp_schedule_sync_t sync, int num_queues,
odp_schedule_print();
/* Create and launch worker threads */
-
- /* Test runs also on the main thread */
- num = globals->num_workers - 1;
arg_ptr = args;
- if (num > 0)
- odp_cunit_thread_create(num, schedule_common_, &arg_ptr, 0, 0);
-
- schedule_common_(args);
+ odp_cunit_thread_create(globals->num_workers, schedule_common_, &arg_ptr, 0, 0);
/* Wait for worker threads to terminate */
- if (num > 0)
- odp_cunit_thread_join(num);
+ odp_cunit_thread_join(globals->num_workers);
/* Cleanup ordered queues for next pass */
if (sync == ODP_SCHED_SYNC_ORDERED)
@@ -2495,16 +2482,6 @@ out:
CU_ASSERT(odp_queue_destroy(queue) == 0);
}
-static int check_2_workers(void)
-{
- if (globals->num_workers < 2) {
- printf("\nTest: scheduler_test_order_wait_2_threads: SKIPPED\n");
- return ODP_TEST_INACTIVE;
- }
-
- return ODP_TEST_ACTIVE;
-}
-
static int sched_and_plain_thread(void *arg)
{
odp_event_t ev1, ev2;
@@ -2590,7 +2567,7 @@ static void scheduler_test_sched_and_plain(odp_schedule_sync_t sync)
uint64_t wait = odp_schedule_wait_time(100 * ODP_TIME_MSEC_IN_NS);
uint32_t events_per_queue = BUFS_PER_QUEUE / 2;
uint32_t prev_seq;
- int first, num;
+ int first;
void *arg_ptr;
CU_ASSERT_FATAL(!odp_schedule_capability(&sched_capa));
@@ -2673,16 +2650,10 @@ static void scheduler_test_sched_and_plain(odp_schedule_sync_t sync)
}
CU_ASSERT_FATAL(seq > 2);
- /* Test runs also on the main thread */
- num = globals->num_workers - 1;
arg_ptr = args;
- if (num > 0)
- odp_cunit_thread_create(num, sched_and_plain_thread, &arg_ptr, 0, 0);
-
- sched_and_plain_thread(args);
+ odp_cunit_thread_create(globals->num_workers, sched_and_plain_thread, &arg_ptr, 0, 0);
- if (num > 0)
- odp_cunit_thread_join(num);
+ odp_cunit_thread_join(globals->num_workers);
/* Check plain queue sequence numbers and free events */
first = 1;
@@ -2979,15 +2950,10 @@ static void scheduler_fifo_mt(odp_schedule_sync_t sync, int multi)
for (i = 0; i < num_thr; i++)
arg[i] = i;
- if (num_thr > 1)
- odp_cunit_thread_create(num_thr - 1, scheduler_fifo_test, (void **)&arg[1], 1, 0);
-
- /* Main thread runs as thread 0 */
- scheduler_fifo_test(0);
+ odp_cunit_thread_create(num_thr, scheduler_fifo_test, (void **)&arg[0], 1, 0);
/* Wait for worker threads to terminate */
- if (num_thr > 1)
- odp_cunit_thread_join(num_thr - 1);
+ odp_cunit_thread_join(num_thr);
}
static void scheduler_fifo_mt_parallel_single(void)
@@ -3083,7 +3049,7 @@ static void scheduler_test_atomicity(void)
odp_pool_t pool;
odp_queue_t queue;
odp_queue_param_t queue_param;
- int i, num;
+ int i;
void *arg_ptr;
shm = odp_shm_lookup(GLOBALS_SHM_NAME);
@@ -3121,18 +3087,12 @@ static void scheduler_test_atomicity(void)
odp_atomic_init_u32(&globals->atomicity_q.state, 0);
/* Create and launch worker threads */
- /* Test runs also on the main thread */
args->num_workers = globals->num_workers;
- num = globals->num_workers - 1;
arg_ptr = args;
- if (num > 0)
- odp_cunit_thread_create(num, atomicity_test_run, &arg_ptr, 0, 0);
-
- atomicity_test_run(args);
+ odp_cunit_thread_create(globals->num_workers, atomicity_test_run, &arg_ptr, 0, 0);
/* Wait for worker threads to terminate */
- if (num > 0)
- odp_cunit_thread_join(num);
+ odp_cunit_thread_join(globals->num_workers);
odp_queue_destroy(globals->atomicity_q.handle);
}
@@ -3720,7 +3680,7 @@ odp_testinfo_t scheduler_basic_suite[] = {
ODP_TEST_INFO(scheduler_test_pause_enqueue),
ODP_TEST_INFO(scheduler_test_ordered_lock),
ODP_TEST_INFO(scheduler_test_order_wait_1_thread),
- ODP_TEST_INFO_CONDITIONAL(scheduler_test_order_wait_2_threads, check_2_workers),
+ ODP_TEST_INFO(scheduler_test_order_wait_2_threads),
ODP_TEST_INFO_CONDITIONAL(scheduler_test_flow_aware,
check_flow_aware_support),
ODP_TEST_INFO(scheduler_test_parallel),
@@ -3795,7 +3755,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
odp_cunit_register_global_init(global_init);
diff --git a/test/validation/api/scheduler/scheduler_no_predef_groups.c b/test/validation/api/scheduler/scheduler_no_predef_groups.c
index 1b941ac61..ad6f6d3a2 100644
--- a/test/validation/api/scheduler/scheduler_no_predef_groups.c
+++ b/test/validation/api/scheduler/scheduler_no_predef_groups.c
@@ -212,7 +212,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
odp_cunit_register_global_init(global_init);
diff --git a/test/validation/api/shmem/shmem.c b/test/validation/api/shmem/shmem.c
index 257e0214e..9e91dab35 100644
--- a/test/validation/api/shmem/shmem.c
+++ b/test/validation/api/shmem/shmem.c
@@ -1163,7 +1163,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
ret = odp_cunit_register(shmem_suites);
diff --git a/test/validation/api/stash/stash.c b/test/validation/api/stash/stash.c
index 67c336a2f..162697ba9 100644
--- a/test/validation/api/stash/stash.c
+++ b/test/validation/api/stash/stash.c
@@ -1385,7 +1385,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
ret = odp_cunit_register(stash_suites);
diff --git a/test/validation/api/std/std.c b/test/validation/api/std/std.c
index 56d05a4b4..161ee87cf 100644
--- a/test/validation/api/std/std.c
+++ b/test/validation/api/std/std.c
@@ -97,7 +97,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
ret = odp_cunit_register(std_suites);
diff --git a/test/validation/api/system/system.c b/test/validation/api/system/system.c
index 89a46a7f2..3f7e0497d 100644
--- a/test/validation/api/system/system.c
+++ b/test/validation/api/system/system.c
@@ -202,23 +202,27 @@ static void system_test_cpu_cycles_long_period(void)
{
int i;
int periods = PERIODS_100_MSEC;
+ uint64_t max_period_duration = 100 * ODP_TIME_MSEC_IN_NS + periods - 1;
uint64_t c2, c1, c3, max;
uint64_t tmp, diff, res;
res = odp_cpu_cycles_resolution();
max = odp_cpu_cycles_max();
+ c3 = odp_cpu_cycles();
+
+ CU_ASSERT(c3 <= max);
/*
- * We can virtually never see a 64 bit cycle counter wrap around,
- * so let's not even try. Use small a number of periods to speed
- * up testing in this common case.
+ * If the cycle counter is not close to wrapping around during
+ * the test, then speed up the test by not trying to see the wrap
+ * around too hard. Assume cycle counter frequency of less than 10 GHz.
*/
- if (max == UINT64_MAX)
+ CU_ASSERT(odp_cpu_hz_max() < 10ULL * ODP_TIME_SEC_IN_NS);
+ if (max - c3 > 10 * periods * max_period_duration)
periods = 10;
printf("\n Testing CPU cycles for %i seconds... ", periods / 10);
- c3 = odp_cpu_cycles();
for (i = 0; i < periods; i++) {
c1 = odp_cpu_cycles();
odp_time_wait_ns(100 * ODP_TIME_MSEC_IN_NS + i);
@@ -241,7 +245,7 @@ static void system_test_cpu_cycles_long_period(void)
}
/* wrap was detected, no need to continue */
- if (i < PERIODS_100_MSEC) {
+ if (i < periods) {
printf("wrap was detected.\n");
return;
}
@@ -683,7 +687,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
ret = odp_cunit_register(system_suites);
diff --git a/test/validation/api/thread/thread.c b/test/validation/api/thread/thread.c
index 840256fcf..ad9ffa745 100644
--- a/test/validation/api/thread/thread.c
+++ b/test/validation/api/thread/thread.c
@@ -255,7 +255,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
odp_cunit_register_global_init(thread_global_init);
diff --git a/test/validation/api/time/time.c b/test/validation/api/time/time.c
index 8d3481e26..cfef7f619 100644
--- a/test/validation/api/time/time.c
+++ b/test/validation/api/time/time.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2019-2023, Nokia
+ * Copyright (c) 2019-2024, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -24,6 +24,7 @@
#define TIME_SAMPLES 2
#define TIME_TOLERANCE_NS 1000000
#define TIME_TOLERANCE_CI_NS 40000000
+#define TIME_TOLERANCE_1CPU_NS 40000000
#define GLOBAL_SHM_NAME "GlobalTimeTest"
#define YEAR_IN_NS (365 * 24 * ODP_TIME_HOUR_IN_NS)
@@ -858,8 +859,7 @@ static void time_test_global_sync(const int ctrl)
odph_thread_common_param_t thr_common;
odph_thread_param_t thr_param;
odph_thread_t thread_tbl[MAX_WORKERS];
- const uint64_t tolerance =
- odp_cunit_ci() ? TIME_TOLERANCE_CI_NS : TIME_TOLERANCE_NS;
+ uint64_t tolerance = odp_cunit_ci() ? TIME_TOLERANCE_CI_NS : TIME_TOLERANCE_NS;
const int num = ctrl ? 2 : global_mem->num_threads;
if (num < 2) {
@@ -879,14 +879,23 @@ static void time_test_global_sync(const int ctrl)
if (ctrl) {
/* Test sync between one control and one worker thread. */
+ int control_cpu;
+ int worker_cpu;
+
odp_cpumask_default_control(&cpumask, 1);
thr_common.cpumask = &cpumask;
thr_param.thr_type = ODP_THREAD_CONTROL;
+ control_cpu = odp_cpumask_first(&cpumask);
int r = odph_thread_create(&thread_tbl[thr++],
&thr_common, &thr_param, 1);
CU_ASSERT_FATAL(r == 1);
odp_cpumask_default_worker(&cpumask, 1);
+ worker_cpu = odp_cpumask_first(&cpumask);
+ if (control_cpu == worker_cpu) {
+ printf(" single CPU, relaxing tolerance. ");
+ tolerance = TIME_TOLERANCE_1CPU_NS;
+ }
} else {
/* Test sync between num worker threads. */
odp_cpumask_default_worker(&cpumask, num);
@@ -1007,7 +1016,7 @@ int main(int argc, char *argv[])
int ret;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
odp_cunit_register_global_init(time_global_init);
diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c
index 28b1399a2..3678d0cb2 100644
--- a/test/validation/api/timer/timer.c
+++ b/test/validation/api/timer/timer.c
@@ -192,8 +192,8 @@ static int timer_global_init(odp_instance_t *instance)
global_mem->periodic_support = capa.periodic.max_pools > 0;
- /* By default 20 msec resolution */
- res_ns = 20 * ODP_TIME_MSEC_IN_NS;
+ /* By default 2 msec resolution */
+ res_ns = 2 * ODP_TIME_MSEC_IN_NS;
if (res_ns < capa.max_res.res_ns)
res_ns = capa.max_res.res_ns;
@@ -1131,42 +1131,42 @@ static void timer_single_shot(odp_queue_type_t queue_type, odp_timer_tick_type_t
static void timer_plain_rel_wait(void)
{
- timer_single_shot(ODP_QUEUE_TYPE_PLAIN, RELATIVE, START, TIMEOUT, 2, 500 * MSEC);
+ timer_single_shot(ODP_QUEUE_TYPE_PLAIN, RELATIVE, START, TIMEOUT, 2, 50 * MSEC);
}
static void timer_plain_abs_wait(void)
{
- timer_single_shot(ODP_QUEUE_TYPE_PLAIN, ABSOLUTE, START, TIMEOUT, 2, 500 * MSEC);
+ timer_single_shot(ODP_QUEUE_TYPE_PLAIN, ABSOLUTE, START, TIMEOUT, 2, 50 * MSEC);
}
static void timer_plain_rel_cancel(void)
{
- timer_single_shot(ODP_QUEUE_TYPE_PLAIN, RELATIVE, START, CANCEL, 5, 1000 * MSEC);
+ timer_single_shot(ODP_QUEUE_TYPE_PLAIN, RELATIVE, START, CANCEL, 5, 100 * MSEC);
}
static void timer_plain_abs_cancel(void)
{
- timer_single_shot(ODP_QUEUE_TYPE_PLAIN, ABSOLUTE, START, CANCEL, 5, 1000 * MSEC);
+ timer_single_shot(ODP_QUEUE_TYPE_PLAIN, ABSOLUTE, START, CANCEL, 5, 100 * MSEC);
}
static void timer_plain_rel_restart_wait(void)
{
- timer_single_shot(ODP_QUEUE_TYPE_PLAIN, RELATIVE, RESTART, TIMEOUT, 2, 600 * MSEC);
+ timer_single_shot(ODP_QUEUE_TYPE_PLAIN, RELATIVE, RESTART, TIMEOUT, 2, 60 * MSEC);
}
static void timer_plain_abs_restart_wait(void)
{
- timer_single_shot(ODP_QUEUE_TYPE_PLAIN, ABSOLUTE, RESTART, TIMEOUT, 2, 600 * MSEC);
+ timer_single_shot(ODP_QUEUE_TYPE_PLAIN, ABSOLUTE, RESTART, TIMEOUT, 2, 60 * MSEC);
}
static void timer_plain_rel_restart_cancel(void)
{
- timer_single_shot(ODP_QUEUE_TYPE_PLAIN, RELATIVE, RESTART, CANCEL, 5, 1000 * MSEC);
+ timer_single_shot(ODP_QUEUE_TYPE_PLAIN, RELATIVE, RESTART, CANCEL, 5, 100 * MSEC);
}
static void timer_plain_abs_restart_cancel(void)
{
- timer_single_shot(ODP_QUEUE_TYPE_PLAIN, ABSOLUTE, RESTART, CANCEL, 5, 1000 * MSEC);
+ timer_single_shot(ODP_QUEUE_TYPE_PLAIN, ABSOLUTE, RESTART, CANCEL, 5, 100 * MSEC);
}
static void timer_plain_abs_wait_3sec(void)
@@ -1176,42 +1176,42 @@ static void timer_plain_abs_wait_3sec(void)
static void timer_sched_rel_wait(void)
{
- timer_single_shot(ODP_QUEUE_TYPE_SCHED, RELATIVE, START, TIMEOUT, 2, 500 * MSEC);
+ timer_single_shot(ODP_QUEUE_TYPE_SCHED, RELATIVE, START, TIMEOUT, 2, 50 * MSEC);
}
static void timer_sched_abs_wait(void)
{
- timer_single_shot(ODP_QUEUE_TYPE_SCHED, ABSOLUTE, START, TIMEOUT, 2, 500 * MSEC);
+ timer_single_shot(ODP_QUEUE_TYPE_SCHED, ABSOLUTE, START, TIMEOUT, 2, 50 * MSEC);
}
static void timer_sched_rel_cancel(void)
{
- timer_single_shot(ODP_QUEUE_TYPE_SCHED, RELATIVE, START, CANCEL, 5, 1000 * MSEC);
+ timer_single_shot(ODP_QUEUE_TYPE_SCHED, RELATIVE, START, CANCEL, 5, 100 * MSEC);
}
static void timer_sched_abs_cancel(void)
{
- timer_single_shot(ODP_QUEUE_TYPE_SCHED, ABSOLUTE, START, CANCEL, 5, 1000 * MSEC);
+ timer_single_shot(ODP_QUEUE_TYPE_SCHED, ABSOLUTE, START, CANCEL, 5, 100 * MSEC);
}
static void timer_sched_rel_restart_wait(void)
{
- timer_single_shot(ODP_QUEUE_TYPE_SCHED, RELATIVE, RESTART, TIMEOUT, 2, 600 * MSEC);
+ timer_single_shot(ODP_QUEUE_TYPE_SCHED, RELATIVE, RESTART, TIMEOUT, 2, 60 * MSEC);
}
static void timer_sched_abs_restart_wait(void)
{
- timer_single_shot(ODP_QUEUE_TYPE_SCHED, ABSOLUTE, RESTART, TIMEOUT, 2, 600 * MSEC);
+ timer_single_shot(ODP_QUEUE_TYPE_SCHED, ABSOLUTE, RESTART, TIMEOUT, 2, 60 * MSEC);
}
static void timer_sched_rel_restart_cancel(void)
{
- timer_single_shot(ODP_QUEUE_TYPE_SCHED, RELATIVE, RESTART, CANCEL, 5, 1000 * MSEC);
+ timer_single_shot(ODP_QUEUE_TYPE_SCHED, RELATIVE, RESTART, CANCEL, 5, 100 * MSEC);
}
static void timer_sched_abs_restart_cancel(void)
{
- timer_single_shot(ODP_QUEUE_TYPE_SCHED, ABSOLUTE, RESTART, CANCEL, 5, 1000 * MSEC);
+ timer_single_shot(ODP_QUEUE_TYPE_SCHED, ABSOLUTE, RESTART, CANCEL, 5, 100 * MSEC);
}
static void timer_sched_abs_wait_3sec(void)
@@ -2403,7 +2403,6 @@ static int worker_entrypoint(void *arg ODP_UNUSED)
}
} else {
uint64_t cur_tick;
- uint64_t tck;
int reset_timer = 0;
if (tt[i].ev != ODP_EVENT_INVALID) {
@@ -2862,9 +2861,9 @@ static void timer_test_periodic(odp_queue_type_t queue_type, int use_first, int
int num_tmo;
int done;
const int num = 200;
- /* Test frequency: 1x 100Hz, or 1x min/max_base_freq */
+ /* Test frequency: 1x 1000 Hz, or 1x min/max_base_freq */
const uint64_t multiplier = 1;
- odp_fract_u64_t base_freq = {100, 0, 0};
+ odp_fract_u64_t base_freq = {1000, 0, 0};
odp_timer_clk_src_t clk_src = test_global->clk_src;
memset(&timer_capa, 0, sizeof(odp_timer_capability_t));
@@ -3262,7 +3261,7 @@ int main(int argc, char *argv[])
int ret = 0;
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
if (global_init())
diff --git a/test/validation/api/traffic_mngr/traffic_mngr.c b/test/validation/api/traffic_mngr/traffic_mngr.c
index ed07db751..b7f546dcd 100644
--- a/test/validation/api/traffic_mngr/traffic_mngr.c
+++ b/test/validation/api/traffic_mngr/traffic_mngr.c
@@ -5025,7 +5025,7 @@ odp_suiteinfo_t traffic_mngr_suites[] = {
int main(int argc, char *argv[])
{
/* parse common options: */
- if (odp_cunit_parse_options(argc, argv))
+ if (odp_cunit_parse_options(&argc, argv))
return -1;
int ret = odp_cunit_register(traffic_mngr_suites);