DPDK patches and discussions
 help / color / mirror / Atom feed
* [RFC] test/latencystats: loosen requirements on measured latency
@ 2025-11-28 19:02 Stephen Hemminger
  0 siblings, 0 replies; only message in thread
From: Stephen Hemminger @ 2025-11-28 19:02 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Reshma Pattan, Bruce Richardson

On QEMU Arm there are failures because the minimum measured latency
was zero. This is likely because the TSC counter emulation is coarse
enough that successive measurements return same value.
Modify the test assertions to allow for TSC being slow (or even
constant).

Also, fix the test to cleanup before validating results
and print the values if a failure occurs. The field name values
printing loop was an earlier debug step not needed.

Fixes: b34508b9cbcd ("test/latency: update with more checks")

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_latencystats.c | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/app/test/test_latencystats.c b/app/test/test_latencystats.c
index 676a99d385..0907f3f5a6 100644
--- a/app/test/test_latencystats.c
+++ b/app/test/test_latencystats.c
@@ -142,7 +142,6 @@ static void test_latency_ring_free(void)
 
 static int test_latency_packet_forward(void)
 {
-	unsigned int i;
 	int ret;
 	struct rte_mbuf *pbuf[LATENCY_NUM_PACKETS] = { };
 	struct rte_mempool *mp;
@@ -184,23 +183,26 @@ static int test_latency_packet_forward(void)
 	ret = rte_latencystats_get(values, NUM_STATS);
 	TEST_ASSERT(ret == NUM_STATS, "Test failed to get results after forwarding");
 
-	for (i = 0; i < NUM_STATS; i++) {
-		uint16_t k = values[i].key;
-
-		printf("%s = %"PRIu64"\n",
-		       names[k].name, values[i].value);
-	}
+	rte_eth_dev_stop(portid);
+	test_put_mbuf_to_pool(mp, pbuf);
 
 	TEST_ASSERT(values[4].value > 0, "No samples taken");
-	TEST_ASSERT(values[0].value > 0, "Min latency should not be zero");
-	TEST_ASSERT(values[1].value > 0, "Avg latency should not be zero");
-	TEST_ASSERT(values[2].value > 0, "Max latency should not be zero");
-	TEST_ASSERT(values[0].value < values[1].value, "Min latency > Avg latency");
-	TEST_ASSERT(values[0].value < values[2].value, "Min latency > Max latency");
-	TEST_ASSERT(values[1].value < values[2].value, "Avg latency > Max latency");
 
-	rte_eth_dev_stop(portid);
-	test_put_mbuf_to_pool(mp, pbuf);
+	/*
+	 * Test maybe run in emulated environment where TSC is very coarse.
+	 * Therefore can't assume that min/max/avg not zero.
+	 * But we can check that Min <= Avg <= Max.
+	 */
+
+	TEST_ASSERT(values[0].value <= values[1].value,
+		    "Min latency %"PRIu64" > Avg latency %"PRIu64,
+		    values[0].value, values[1].value);
+	TEST_ASSERT(values[0].value <= values[2].value,
+		    "Min latency %"PRIu64" > Max latency %"PRIu64,
+		    values[0].value, values[2].value);
+	TEST_ASSERT(values[1].value <= values[2].value,
+		    "Avg latency %"PRIu64 "> Max latency %"PRIu64,
+		    values[1].value, values[2].value);
 
 	return (ret >= 0) ? TEST_SUCCESS : TEST_FAILED;
 }
-- 
2.51.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-11-28 19:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-28 19:02 [RFC] test/latencystats: loosen requirements on measured latency Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).