DPDK patches and discussions
 help / color / mirror / Atom feed
From: Marat Khalili <marat.khalili@huawei.com>
To: <bruce.richardson@intel.com>
Cc: <dev@dpdk.org>
Subject: [PATCH] buildtools/get-test-suites.py: muti-line macros
Date: Wed, 18 Jun 2025 13:39:46 +0100	[thread overview]
Message-ID: <20250618123946.66915-1-marat.khalili@huawei.com> (raw)

Test list is currently generated by scanning all files for macros
starting with `REGISTER_` and ending with `_TEST`. Unfortunately, this
was done line-by-line, and macros split into several lines were silently
ignored resulting in tests being excluded from test suites without any
warning.

Make regular expression multiline, capturing everything until the
closing parenthesis. (There should be no nested parentheses due to the
nature of the arguments these macros accept.)

The rest of the functionality stays the same. The result was manually
compared to be identical to the previous version.

Signed-off-by: Marat Khalili <marat.khalili@huawei.com>
---

MAINTAINERS file does not list any maintainers for the Unit tests
framework, so addressing Bruce Richardson who maintains other build
tools. Apologies in advance, feel free to ignore or redirect.

 buildtools/get-test-suites.py | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/buildtools/get-test-suites.py b/buildtools/get-test-suites.py
index fd22d25f36..c3a99a862e 100644
--- a/buildtools/get-test-suites.py
+++ b/buildtools/get-test-suites.py
@@ -6,10 +6,12 @@
 import re
 
 input_list = sys.argv[1:]
-test_def_regex = re.compile(r"REGISTER_([A-Z]+)_TEST\s*\(\s*([a-z0-9_]+)")
+test_def_regex = re.compile(
+        r"^\s*REGISTER_([A-Z]+)_TEST\s*\(\s*([a-z0-9_]+)[^)]*\)", re.MULTILINE)
 test_suites = {}
 # track tests not in any test suite.
-non_suite_regex = re.compile(r"REGISTER_TEST_COMMAND\s*\(\s*([a-z0-9_]+)")
+non_suite_regex = re.compile(
+        r"^\s*REGISTER_TEST_COMMAND\s*\(\s*([a-z0-9_]+)[^)]*\)", re.MULTILINE)
 non_suite_tests = []
 
 def get_fast_test_params(test_name, ln):
@@ -20,19 +22,19 @@ def get_fast_test_params(test_name, ln):
 
 for fname in input_list:
     with open(fname, "r", encoding="utf-8") as f:
-        contents = [ln.strip() for ln in f.readlines()]
-        test_lines = [ln for ln in contents if test_def_regex.match(ln)]
-        non_suite_tests.extend([non_suite_regex.match(ln).group(1)
-                for ln in contents if non_suite_regex.match(ln)])
-    for ln in test_lines:
-        (test_suite, test_name) = test_def_regex.match(ln).group(1, 2)
+        contents = f.read()
+    non_suite_tests.extend(
+            match.group(1) for match in non_suite_regex.finditer(contents))
+    for match in test_def_regex.finditer(contents):
+        (test_suite, test_name) = match.group(1, 2)
         suite_name = f"{test_suite.lower()}-tests"
         if suite_name in test_suites:
             test_suites[suite_name].append(test_name)
         else:
             test_suites[suite_name] = [test_name]
         if suite_name == "fast-tests":
-            test_suites["fast-tests"][-1] += get_fast_test_params(test_name, ln)
+            test_suites["fast-tests"][-1] += get_fast_test_params(
+                    test_name, match.group(0))
 
 for suite in test_suites.keys():
     print(f"{suite}={','.join(test_suites[suite])}")
-- 
2.43.0


                 reply	other threads:[~2025-06-18 12:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250618123946.66915-1-marat.khalili@huawei.com \
    --to=marat.khalili@huawei.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).