10aeaf75dSBruce Richardson#! /usr/bin/env python3 20aeaf75dSBruce Richardson# SPDX-License-Identifier: BSD-3-Clause 30aeaf75dSBruce Richardson# Copyright(c) 2023 Intel Corporation 40aeaf75dSBruce Richardson 50aeaf75dSBruce Richardsonimport sys 60aeaf75dSBruce Richardsonimport re 70aeaf75dSBruce Richardson 80aeaf75dSBruce Richardsoninput_list = sys.argv[1:] 90aeaf75dSBruce Richardsontest_def_regex = re.compile("REGISTER_([A-Z]+)_TEST\s*\(\s*([a-z0-9_]+)") 100aeaf75dSBruce Richardsontest_suites = {} 1125065ef1SBruce Richardson# track tests not in any test suite. 1225065ef1SBruce Richardsonnon_suite_regex = re.compile("REGISTER_TEST_COMMAND\s*\(\s*([a-z0-9_]+)") 1325065ef1SBruce Richardsonnon_suite_tests = [] 140aeaf75dSBruce Richardson 150aeaf75dSBruce Richardsondef get_fast_test_params(test_name, ln): 160aeaf75dSBruce Richardson "Extract the extra fast-test parameters from the line" 170aeaf75dSBruce Richardson (_, rest_of_line) = ln.split(test_name, 1) 180aeaf75dSBruce Richardson (_, nohuge, asan, _func) = rest_of_line.split(',', 3) 190aeaf75dSBruce Richardson return f":{nohuge.strip().lower()}:{asan.strip().lower()}" 200aeaf75dSBruce Richardson 210aeaf75dSBruce Richardsonfor fname in input_list: 22*39846d56SRobin Jarry with open(fname, "r", encoding="utf-8") as f: 2325065ef1SBruce Richardson contents = [ln.strip() for ln in f.readlines()] 2425065ef1SBruce Richardson test_lines = [ln for ln in contents if test_def_regex.match(ln)] 2525065ef1SBruce Richardson non_suite_tests.extend([non_suite_regex.match(ln).group(1) 2625065ef1SBruce Richardson for ln in contents if non_suite_regex.match(ln)]) 2725065ef1SBruce Richardson for ln in test_lines: 280aeaf75dSBruce Richardson (test_suite, test_name) = test_def_regex.match(ln).group(1, 2) 290aeaf75dSBruce Richardson suite_name = f"{test_suite.lower()}-tests" 300aeaf75dSBruce Richardson if suite_name in test_suites: 310aeaf75dSBruce Richardson test_suites[suite_name].append(test_name) 320aeaf75dSBruce Richardson else: 330aeaf75dSBruce Richardson test_suites[suite_name] = [test_name] 340aeaf75dSBruce Richardson if suite_name == "fast-tests": 350aeaf75dSBruce Richardson test_suites["fast-tests"][-1] += get_fast_test_params(test_name, ln) 360aeaf75dSBruce Richardson 370aeaf75dSBruce Richardsonfor suite in test_suites.keys(): 380aeaf75dSBruce Richardson print(f"{suite}={','.join(test_suites[suite])}") 3925065ef1SBruce Richardsonprint(f"non_suite_tests={','.join(non_suite_tests)}") 40