diff mbox series

[03/13] selftest: resulttooltests.py: add report-log Time(s) column test

Message ID 20260923190419.353493-4-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.parse_report_log(), covering
correct Time(s) column extraction from a 'resulttool report' text log,
and confirming the unrelated percentage-based status summary table
above it is not mistaken for a Time(s) table.

AI-Generated: Uses Claude Sonnet 5

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
---
 .../oeqa/selftest/cases/resulttooltests.py    | 33 +++++++++++++++++++
 1 file changed, 33 insertions(+)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/selftest/cases/resulttooltests.py b/meta/lib/oeqa/selftest/cases/resulttooltests.py
index a380d08156..b3c6f3329b 100644
--- a/meta/lib/oeqa/selftest/cases/resulttooltests.py
+++ b/meta/lib/oeqa/selftest/cases/resulttooltests.py
@@ -697,3 +697,36 @@  class ResultToolTests(OESelftestTestCase):
         self.assertNotIn('test.Foo.test_no_duration', flattened[path])
         self.assertEqual(flattened[path]['ptestresult.sections.bash'], 5.0)
         self.assertEqual(flattened[path]['ptestresult.sections.timedout'], 30.0)
+
+    def test_durations_parse_report_log_extracts_time_column(self):
+        content = (
+            "==============================================================================================================\n"
+            "Test Result Status Summary (Counts/Percentages sorted by testseries, ID)\n"
+            "==============================================================================================================\n"
+            "qemux86 | someresultid | 6 (86%) | 0 (0%) | 1 (14%)\n"
+            "\n"
+            "==============================================================================================================\n"
+            "qemux86 PTest Result Summary (Libc: glibc)\n"
+            "==============================================================================================================\n"
+            "--------------------------------------------------------------------------------------------------------------\n"
+            "Recipe                       | Passed       | Failed | Skipped   | Time(s)   \n"
+            "--------------------------------------------------------------------------------------------------------------\n"
+            "acl                          | 1            | 0      | 0         | 1\n"
+            "bash                         | 43           | 0      | 0         | 48\n"
+            "timedout-suite               | 1            | 0      | 0         | 30 T\n"
+            "--------------------------------------------------------------------------------------------------------------\n"
+        )
+        with tempfile.NamedTemporaryFile(mode='w', suffix='.log', delete=False) as f:
+            f.write(content)
+            logpath = f.name
+        try:
+            parsed = durations.parse_report_log(logpath)
+        finally:
+            os.remove(logpath)
+        section = 'qemux86 PTest Result Summary (Libc: glibc)'
+        self.assertIn(section, parsed)
+        self.assertEqual(parsed[section]['acl'], 1.0)
+        self.assertEqual(parsed[section]['bash'], 48.0)
+        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))