From c32598fe48a09abf8891ff056dbdcab4eb1b677a Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Mon, 1 Jul 2024 00:34:45 -0600 Subject: [PATCH] twister: Fix gTest harness The gTest harness asssumed that the lines end with the test name, but some gTest implementations include the test duration in the line. Update both the tests and regex to allow this and also avoid capturing characters into the `test_name` that cannot be valid test name chars. Fixes #72318 (cherry picked from commit 1b51740fa3b91af9b874e7d07f6bd2c8a8978956) Original-Signed-off-by: Yuval Peress GitOrigin-RevId: 1b51740fa3b91af9b874e7d07f6bd2c8a8978956 Change-Id: Ie03b5687c09bfd054b79253bcbc5e4b081e8aa3c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5675559 Tested-by: ChromeOS Prod (Robot) Reviewed-by: Fabio Baltieri Commit-Queue: Fabio Baltieri Reviewed-by: Eric Yilun Lin --- scripts/pylib/twister/twisterlib/harness.py | 10 +++++----- scripts/tests/twister/test_harness.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/pylib/twister/twisterlib/harness.py b/scripts/pylib/twister/twisterlib/harness.py index c25b7fcf421a..6c132a10d4e9 100644 --- a/scripts/pylib/twister/twisterlib/harness.py +++ b/scripts/pylib/twister/twisterlib/harness.py @@ -570,11 +570,11 @@ def _parse_report_file(self, report): class Gtest(Harness): ANSI_ESCAPE = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])') - TEST_START_PATTERN = r".*\[ RUN \] (?P.*)\.(?P.*)$" - TEST_PASS_PATTERN = r".*\[ OK \] (?P.*)\.(?P.*)$" - TEST_SKIP_PATTERN = r".*\[ DISABLED \] (?P.*)\.(?P.*)$" - TEST_FAIL_PATTERN = r".*\[ FAILED \] (?P.*)\.(?P.*)$" - FINISHED_PATTERN = r".*\[==========\] Done running all tests\.$" + TEST_START_PATTERN = r".*\[ RUN \] (?P[a-zA-Z_][a-zA-Z0-9_]*)\.(?P[a-zA-Z_][a-zA-Z0-9_]*)" + TEST_PASS_PATTERN = r".*\[ OK \] (?P[a-zA-Z_][a-zA-Z0-9_]*)\.(?P[a-zA-Z_][a-zA-Z0-9_]*)" + TEST_SKIP_PATTERN = r".*\[ DISABLED \] (?P[a-zA-Z_][a-zA-Z0-9_]*)\.(?P[a-zA-Z_][a-zA-Z0-9_]*)" + TEST_FAIL_PATTERN = r".*\[ FAILED \] (?P[a-zA-Z_][a-zA-Z0-9_]*)\.(?P[a-zA-Z_][a-zA-Z0-9_]*)" + FINISHED_PATTERN = r".*\[==========\] Done running all tests\." def __init__(self): super().__init__() diff --git a/scripts/tests/twister/test_harness.py b/scripts/tests/twister/test_harness.py index 57e68f9deb70..116d4bf50fb3 100644 --- a/scripts/tests/twister/test_harness.py +++ b/scripts/tests/twister/test_harness.py @@ -33,7 +33,7 @@ SAMPLE_GTEST_START = ( "[00:00:00.000,000]  label: [==========] Running all tests." ) -SAMPLE_GTEST_FMT = "[00:00:00.000,000]  label: [{state}] {suite}.{test}" +SAMPLE_GTEST_FMT = "[00:00:00.000,000]  label: [{state}] {suite}.{test} (0ms)" SAMPLE_GTEST_END = ( "[00:00:00.000,000]  label: [==========] Done running all tests." )