test/event: fix timeout accuracy
authorPavan Nikhilesh <pbhagavatula@marvell.com>
Sat, 6 Mar 2021 20:26:58 +0000 (01:56 +0530)
committerJerin Jacob <jerinj@marvell.com>
Mon, 12 Apr 2021 07:19:02 +0000 (09:19 +0200)
Round timeout ticks when converting from nanoseconds, this prevents
loss of accuracy and deviation from requested timeout value.

Fixes: d1f3385d0076 ("test: add event timer adapter auto-test")
Cc: stable@dpdk.org
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Acked-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
app/test/test_event_timer_adapter.c

index ad3f4dc..b536dde 100644 (file)
@@ -3,6 +3,8 @@
  * Copyright(c) 2017-2018 Intel Corporation.
  */
 
+#include <math.h>
+
 #include <rte_atomic.h>
 #include <rte_common.h>
 #include <rte_cycles.h>
@@ -46,7 +48,7 @@ static uint64_t global_info_bkt_tck_ns;
 static volatile uint8_t arm_done;
 
 #define CALC_TICKS(tks)                                        \
-       ((tks * global_bkt_tck_ns) / global_info_bkt_tck_ns)
+       ceil((double)(tks * global_bkt_tck_ns) / global_info_bkt_tck_ns)
 
 
 static bool using_services;