diff mbox series

[API-NEXT,v1,3/3] validation: time: test odp_time_diff_ns

Message ID 1511528406-25262-4-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v1,1/3] api: time: time difference in nsec | expand

Commit Message

Github ODP bot Nov. 24, 2017, 1 p.m. UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


Added tests for the new time difference in nsec function.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
/** Email created from pull request 310 (psavol:next-time-convert)
 ** https://github.com/Linaro/odp/pull/310
 ** Patch: https://github.com/Linaro/odp/pull/310.patch
 ** Base sha: b95e7d08043ba45d12635c5afaa3fbf3a07ecc90
 ** Merge commit sha: 7700d0dab4af4db47973c2a88e5a6d6765bf979e
 **/
 test/validation/api/time/time.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/test/validation/api/time/time.c b/test/validation/api/time/time.c
index ef1372578..c8f90dbac 100644
--- a/test/validation/api/time/time.c
+++ b/test/validation/api/time/time.c
@@ -201,7 +201,8 @@  static void time_test_diff(time_cb time_cur,
 	/* volatile to stop optimization of busy loop */
 	volatile int count = 0;
 	odp_time_t diff, t1, t2;
-	uint64_t nsdiff, ns1, ns2, ns;
+	uint64_t ns1, ns2, ns;
+	uint64_t nsdiff, diff_ns;
 	uint64_t upper_limit, lower_limit;
 
 	/* test timestamp diff */
@@ -217,6 +218,9 @@  static void time_test_diff(time_cb time_cur,
 	diff = odp_time_diff(t2, t1);
 	CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL) > 0);
 
+	diff_ns = odp_time_diff_ns(t2, t1);
+	CU_ASSERT(diff_ns > 0);
+
 	ns1 = odp_time_to_ns(t1);
 	ns2 = odp_time_to_ns(t2);
 	ns = ns2 - ns1;
@@ -225,6 +229,7 @@  static void time_test_diff(time_cb time_cur,
 	upper_limit = ns + 2 * res;
 	lower_limit = ns - 2 * res;
 	CU_ASSERT((nsdiff <= upper_limit) && (nsdiff >= lower_limit));
+	CU_ASSERT((diff_ns <= upper_limit) && (diff_ns >= lower_limit));
 
 	/* test timestamp and interval diff */
 	ns1 = 54;
@@ -233,11 +238,16 @@  static void time_test_diff(time_cb time_cur,
 
 	diff = odp_time_diff(t2, t1);
 	CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL) > 0);
+
+	diff_ns = odp_time_diff_ns(t2, t1);
+	CU_ASSERT(diff_ns > 0);
+
 	nsdiff = odp_time_to_ns(diff);
 
 	upper_limit = ns + 2 * res;
 	lower_limit = ns - 2 * res;
 	CU_ASSERT((nsdiff <= upper_limit) && (nsdiff >= lower_limit));
+	CU_ASSERT((diff_ns <= upper_limit) && (diff_ns >= lower_limit));
 
 	/* test interval diff */
 	ns2 = 60 * 10 * ODP_TIME_SEC_IN_NS;
@@ -246,11 +256,16 @@  static void time_test_diff(time_cb time_cur,
 	t2 = time_from_ns(ns2);
 	diff = odp_time_diff(t2, t1);
 	CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL) > 0);
+
+	diff_ns = odp_time_diff_ns(t2, t1);
+	CU_ASSERT(diff_ns > 0);
+
 	nsdiff = odp_time_to_ns(diff);
 
 	upper_limit = ns + 2 * res;
 	lower_limit = ns - 2 * res;
 	CU_ASSERT((nsdiff <= upper_limit) && (nsdiff >= lower_limit));
+	CU_ASSERT((diff_ns <= upper_limit) && (diff_ns >= lower_limit));
 
 	/* same time has to diff to 0 */
 	diff = odp_time_diff(t2, t2);
@@ -258,6 +273,9 @@  static void time_test_diff(time_cb time_cur,
 
 	diff = odp_time_diff(t2, ODP_TIME_NULL);
 	CU_ASSERT(odp_time_cmp(t2, diff) == 0);
+
+	diff_ns = odp_time_diff_ns(t2, t2);
+	CU_ASSERT(diff_ns == 0);
 }
 
 void time_test_local_diff(void)