@@ -12,6 +12,7 @@
#define BUSY_LOOP_CNT_LONG 12000000000 /* used for t > 4 sec */
#define MIN_TIME_RATE 32000
#define MAX_TIME_RATE 15000000000
+#define DELAY_TOLERANCE 50 /* deviation for delay */
static uint64_t res;
@@ -244,6 +245,30 @@ void time_test_odp_sum(void)
CU_ASSERT(odp_time_cmp(t2, sum) == 0);
}
+void time_test_wait(void)
+{
+ int i;
+ odp_time_t start_time, end_time, diff;
+ odp_time_t lower_limit, upper_limit, tolerance;
+ odp_time_t second = odp_time_local_from_ns(ODP_TIME_SEC_IN_NS);
+
+ start_time = odp_time_local();
+ for (i = 1; i < 6; i++) {
+ odp_time_wait(second);
+ printf("%d..", i);
+ }
+ end_time = odp_time_local();
+
+ diff = odp_time_diff(end_time, start_time);
+ tolerance = odp_time_local_from_ns(DELAY_TOLERANCE);
+
+ lower_limit = odp_time_diff(diff, tolerance);
+ upper_limit = odp_time_sum(diff, tolerance);
+
+ CU_ASSERT(odp_time_cmp(diff, lower_limit) >= 0);
+ CU_ASSERT(odp_time_cmp(diff, upper_limit) <= 0);
+}
+
void time_test_odp_to_u64(void)
{
volatile int count = 0;
@@ -277,6 +302,7 @@ odp_testinfo_t time_suite_time[] = {
ODP_TEST_INFO(time_test_odp_cmp),
ODP_TEST_INFO(time_test_odp_diff),
ODP_TEST_INFO(time_test_odp_sum),
+ ODP_TEST_INFO(time_test_wait),
ODP_TEST_INFO(time_test_odp_to_u64),
ODP_TEST_INFO_NULL
};
@@ -17,6 +17,7 @@ void time_test_monotony(void);
void time_test_odp_cmp(void);
void time_test_odp_diff(void);
void time_test_odp_sum(void);
+void time_test_wait(void);
void time_test_odp_to_u64(void);
/* test arrays: */
This patch adds validation test for odp_time_wait(). Also it visually demonstrates 5 second count. Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> --- test/validation/time/time.c | 26 ++++++++++++++++++++++++++ test/validation/time/time.h | 1 + 2 files changed, 27 insertions(+)