[RFC] test/latencystats: loosen requirements on measured latency

Message ID 20251128190228.64278-1-stephen@networkplumber.org (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series [RFC] test/latencystats: loosen requirements on measured latency |

Checks

Context Check Description
ci/loongarch-compilation success Compilation OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-compile-arm64-testing pending Testing pending
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/aws-unit-testing success Unit Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Stephen Hemminger Nov. 28, 2025, 7:02 p.m. UTC
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(-)
  

Patch

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;
 }