@@ -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)