diff options
author | Malvika Gupta <Malvika.Gupta@arm.com> | 2021-02-23 13:32:50 -0600 |
---|---|---|
committer | Petri Savolainen <petri.savolainen@nokia.com> | 2021-03-12 10:17:07 +0200 |
commit | c13760d158b8d62da0e6613170611364006b75d0 (patch) | |
tree | 7e7a57a896822d032d0fff1a0c8ecf1357e46f28 /test/validation | |
parent | 9802fd591cfca55d0292abde96a19f094d36b4bc (diff) |
validation: pktio: correct tolerance in odp_pktio_ts_from_ns() test
odp_pktio_ts_from_ns() test uses PKTIO_TS_CMP_RES to check the arithmetic
tolerance which is incorrect. The time, in nanoseconds, reported from the
clock resolution API should be used instead. The resolution API accurately
represents the granularity in which packet IO timestamp is able to measure
the time.
Signed-off-by: Malvika Gupta <Malvika.Gupta@arm.com>
Reviewed-by: Govindarajan Mohandoss <govindarajan.mohandoss@arm.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Diffstat (limited to 'test/validation')
-rw-r--r-- | test/validation/api/pktio/pktio.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c index 3f8df07f3..91b0caf71 100644 --- a/test/validation/api/pktio/pktio.c +++ b/test/validation/api/pktio/pktio.c @@ -33,7 +33,6 @@ #define PKTIO_TS_INTERVAL (50 * ODP_TIME_MSEC_IN_NS) #define PKTIO_TS_MIN_RES 1000 #define PKTIO_TS_MAX_RES 10000000000 -#define PKTIO_TS_CMP_RES 1 #define PKTIO_SRC_MAC {1, 2, 3, 4, 5, 6} #define PKTIO_DST_MAC {6, 5, 4, 3, 2, 1} @@ -2310,7 +2309,7 @@ static void pktio_test_pktin_ts(void) odp_packet_t pkt_tbl[TX_BATCH_LEN]; uint32_t pkt_seq[TX_BATCH_LEN]; uint64_t ns1, ns2; - uint64_t res; + uint64_t res, res_ns; odp_time_t ts_prev; odp_time_t ts; int num_rx = 0; @@ -2351,9 +2350,11 @@ static void pktio_test_pktin_ts(void) ns1 = 100; ts = odp_pktio_ts_from_ns(pktio_tx, ns1); ns2 = odp_time_to_ns(ts); + res_ns = ODP_TIME_SEC_IN_NS / res; + if (ODP_TIME_SEC_IN_NS % res) + res_ns++; /* Allow some arithmetic tolerance */ - CU_ASSERT((ns2 <= (ns1 + PKTIO_TS_CMP_RES)) && - (ns2 >= (ns1 - PKTIO_TS_CMP_RES))); + CU_ASSERT((ns2 <= (ns1 + res_ns)) && (ns2 >= (ns1 - res_ns))); ret = create_packets(pkt_tbl, pkt_seq, TX_BATCH_LEN, pktio_tx, pktio_rx); |