@@ -8,3 +8,4 @@ odp_shm
odp_system
odp_pktio
odp_buffer
+odp_time
@@ -6,11 +6,19 @@ AM_LDFLAGS += -static
TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform}
if ODP_CUNIT_ENABLED
-TESTS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio_run odp_buffer odp_system
+TESTS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio_run odp_buffer odp_system odp_time
check_PROGRAMS = ${bin_PROGRAMS}
-bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio odp_buffer odp_system
-odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
+bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio odp_buffer odp_system odp_time
odp_buffer_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/buffer
+odp_init_LDFLAGS = $(AM_LDFLAGS)
+odp_queue_LDFLAGS = $(AM_LDFLAGS)
+odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
+odp_crypto_LDFLAGS = $(AM_LDFLAGS)
+odp_shm_CFLAGS = $(AM_CFLAGS)
+odp_shm_LDFLAGS = $(AM_LDFLAGS)
+odp_schedule_CFLAGS = $(AM_CFLAGS)
+odp_schedule_LDFLAGS = $(AM_LDFLAGS)
+odp_time_LDFLAGS = $(AM_LDFLAGS)
endif
dist_odp_init_SOURCES = odp_init.c
@@ -27,3 +35,8 @@ dist_odp_buffer_SOURCES = buffer/odp_buffer_pool_test.c \
buffer/odp_packet_test.c \
odp_buffer.c common/odp_cunit_common.c
dist_odp_system_SOURCES = odp_system.c common/odp_cunit_common.c
+dist_odp_time_SOURCES = odp_time.c common/odp_cunit_common.c
+
+#For Linux generic the unimplemented crypto API functions break the
+#regression TODO: https://bugs.linaro.org/show_bug.cgi?id=975
+XFAIL_TESTS=odp_crypto
new file mode 100644
@@ -0,0 +1,70 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp.h>
+#include "odp_cunit_common.h"
+
+#define TOLERANCE 1
+#define BUSY_LOOP_CNT 100
+
+/* check that a cycles difference gives a reasonable result */
+static void test_odp_time_diff(void)
+{
+ /* volatile to stop optimization of busy loop */
+ volatile int count;
+ uint64_t diff, cycles1, cycles2;
+
+ cycles1 = odp_time_cycles();
+
+ while (count < BUSY_LOOP_CNT) {
+ count++;
+ };
+
+ cycles2 = odp_time_cycles();
+ CU_ASSERT(cycles2 > cycles1);
+
+ diff = odp_time_diff_cycles(cycles1, cycles2);
+ CU_ASSERT(diff > 0);
+}
+
+/* check that a negative cycles difference gives a reasonable result */
+static void test_odp_time_negative_diff(void)
+{
+ uint64_t diff, cycles1, cycles2;
+ cycles1 = 10;
+ cycles2 = 5;
+ diff = odp_time_diff_cycles(cycles1, cycles2);
+ CU_ASSERT(diff > 0);
+}
+/* check that related conversions come back to the same value */
+static void test_odp_time_conversion(void)
+{
+ uint64_t ns1, ns2, cycles1;
+ uint64_t upper_limit, lower_limit;
+ ns1 = 100;
+ cycles1 = odp_time_ns_to_cycles(ns1);
+ CU_ASSERT(cycles1 > 0);
+
+ ns2 = odp_time_cycles_to_ns(cycles1);
+
+ /* need to check within arithmetic tolerance that the same
+ * value in ns is returned after conversions */
+ upper_limit = ns1 + TOLERANCE;
+ lower_limit = ns1 - TOLERANCE;
+ CU_ASSERT((ns2 <= upper_limit) && (ns2 >= lower_limit));
+}
+
+CU_TestInfo test_odp_time[] = {
+ {"diff", test_odp_time_diff},
+ {"negative diff", test_odp_time_negative_diff},
+ {"conversion", test_odp_time_conversion},
+ CU_TEST_INFO_NULL
+};
+
+CU_SuiteInfo odp_testsuites[] = {
+ {"Time", NULL, NULL, NULL, NULL, test_odp_time},
+ CU_SUITE_INFO_NULL
+};
Add odp_time_x API tests Signed-off-by: Mike Holmes <mike.holmes@linaro.org> --- test/validation/.gitignore | 1 + test/validation/Makefile.am | 19 ++++++++++-- test/validation/odp_time.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 test/validation/odp_time.c