From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 82FE7469EC; Wed, 18 Jun 2025 14:40:11 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1227A427E6; Wed, 18 Jun 2025 14:40:11 +0200 (CEST) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by mails.dpdk.org (Postfix) with ESMTP id B54FB40E1C for ; Wed, 18 Jun 2025 14:40:09 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4bMjrJ3K7Lz6L62C; Wed, 18 Jun 2025 20:35:28 +0800 (CST) Received: from frapeml500002.china.huawei.com (unknown [7.182.85.205]) by mail.maildlp.com (Postfix) with ESMTPS id 8DC651402EF; Wed, 18 Jun 2025 20:40:08 +0800 (CST) Received: from localhost.localdomain (10.220.239.45) by frapeml500002.china.huawei.com (7.182.85.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 18 Jun 2025 14:40:08 +0200 From: Marat Khalili To: CC: Subject: [PATCH] buildtools/get-test-suites.py: muti-line macros Date: Wed, 18 Jun 2025 13:39:46 +0100 Message-ID: <20250618123946.66915-1-marat.khalili@huawei.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.220.239.45] X-ClientProxiedBy: frapeml100002.china.huawei.com (7.182.85.26) To frapeml500002.china.huawei.com (7.182.85.205) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- 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