diff mbox series

[04/13] selftest: resulttooltests.py: add zero-round pct suppression test

Message ID 20260923190419.353493-5-tgamblin@baylibre.com
State New
Headers show
Series resulttool: add 'durations' subcommand and selftests | expand

Commit Message

Trevor Gamblin Sept. 23, 2026, 7:04 p.m. UTC
Add a test for resulttool.durations.build_rows(), covering suppression
of delta/percentage reporting when durations round to zero. Times are
reported in seconds and fractional times can be calculated, so we
don't want to show (for example) RUN1 = RUN2 = 0 but a large delta
because one run was many fractions of a second faster.

AI-Generated: Uses Claude Sonnet 5
---
 meta/lib/oeqa/selftest/cases/resulttooltests.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/selftest/cases/resulttooltests.py b/meta/lib/oeqa/selftest/cases/resulttooltests.py
index b3c6f3329b..dfaa4edbba 100644
--- a/meta/lib/oeqa/selftest/cases/resulttooltests.py
+++ b/meta/lib/oeqa/selftest/cases/resulttooltests.py
@@ -730,3 +730,15 @@  class ResultToolTests(OESelftestTestCase):
         self.assertEqual(parsed[section]['timedout-suite'], 30.0)
         # the status-summary table above (percentages, not a Time(s) table) must not be picked up
         self.assertNotIn('someresultid', str(parsed))
+
+    def test_durations_build_rows_suppresses_pct_when_both_runs_round_to_zero(self):
+        alldurations = [
+            {'path': {'tiny': 0.2, 'big': 100.0}},
+            {'path': {'tiny': 0.4, 'big': 150.0}},
+        ]
+        rows = durations.build_rows(['tiny', 'big'], 'path', alldurations)
+        rowmap = {k: deltas for k, vals, deltas in rows}
+        # both runs round to 0s: no meaningful percentage to report
+        self.assertEqual(rowmap['tiny'], [(0.2, None)])
+        # normal case: delta and percentage both reported
+        self.assertEqual(rowmap['big'], [(50.0, 50.0)])