From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3469210E7B3 for ; Thu, 7 Sep 2023 10:19:04 +0000 (UTC) From: Mauro Carvalho Chehab To: igt-dev@lists.freedesktop.org Date: Thu, 7 Sep 2023 12:17:32 +0200 Message-ID: <20230907101852.522819-2-mauro.chehab@linux.intel.com> In-Reply-To: <20230907101852.522819-1-mauro.chehab@linux.intel.com> References: <20230907101852.522819-1-mauro.chehab@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [igt-dev] [PATCH i-g-t v3 1/7] test_list.py: add support for reading testlist regular expressions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tomasz.mistat@intel.com, jari.tahvanainen@intel.com Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: From: Mauro Carvalho Chehab If defined, use testlist and blocklist files to update the fields that use it. Signed-off-by: Mauro Carvalho Chehab --- scripts/test_list.py | 75 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/scripts/test_list.py b/scripts/test_list.py index 2171f8b50617..c1518a904baf 100644 --- a/scripts/test_list.py +++ b/scripts/test_list.py @@ -260,6 +260,8 @@ class TestList: self.igt_build_path = igt_build_path self.level_count = 0 self.field_list = {} + self.testlist = {} + self.blocklist = {} self.title = None self.filters = {} self.subtest_separator = subtest_separator @@ -327,6 +329,23 @@ class TestList: if sublevel_count[level - 1] == 1: del item["_properties_"]["level"] del item["_properties_"]["sublevel"] + + # Read testlist files if any + if "testlists" in item["_properties_"]: + testlist = {} + for name in item["_properties_"]["testlists"].keys(): + self.read_testlist(testlist, name, cfg_path + item["_properties_"]["testlists"][name]) + + item["_properties_"]["testlist"] = testlist + + # Read blocklist files if any + if "blocklists" in item["_properties_"]: + blocklist = {} + for name in item["_properties_"]["blocklists"].keys(): + self.read_testlist(blocklist, name, cfg_path + item["_properties_"]["blocklists"][name]) + + item["_properties_"]["blocklist"] = blocklist + if "_properties_" in self.props: del self.props["_properties_"] @@ -427,6 +446,19 @@ class TestList: self.__add_field(key, sublevel, hierarchy_level, field[key]) + def read_testlist(self, testlist, name, filename): + base = r"^\s*({}[^\s\{}]+)(\S*)\s*(\#.*)?$" + regex = re.compile(base.format(self.main_name, self.subtest_separator)) + + testlist[name] = [] + with open(filename, 'r', newline = '', encoding = 'utf8') as fp: + for line in fp: + match = regex.match(line) + if match: + test = match.group(1) + subtest = match.group(2) + testlist[name].append(re.compile(f"{test}{subtest}")) + def __filter_subtest(self, test, subtest, field_not_found_value): """ Apply filter criteria to subtests """ @@ -444,6 +476,45 @@ class TestList: # None of the filtering rules were applied return False + def update_testlist_field(self, subtest_dict): + for field in self.props.keys(): + if "_properties_" not in self.props[field]: + continue + + if "testlist" not in self.props[field]["_properties_"]: + continue + + testname = subtest_dict["_summary_"] + + value = subtest_dict.get(field) + if value: + values = set(re.split(",\s*", value)) + else: + values = set() + + for names, regex_array in self.props[field]["_properties_"]["testlist"].items(): + name = set(re.split(",\s*", names)) + for regex in regex_array: + if regex.match(testname): + values.update(name) + break + + # If test is at a global blocklist, ignore it + set_full_if_empty = True + if "blocklist" in self.props[field]["_properties_"]: + for names, regex_array in self.props[field]["_properties_"]["testlist"].items(): + deleted_names = set(re.split(",\s*", names)) + for regex in regex_array: + if regex.match(testname): + if sorted(deleted_names) == sorted(values): + set_full_if_empty = False + values.discard(deleted_names) + + if set_full_if_empty and not values: + values = set(["FULL"]) + + subtest_dict[field] = ", ".join(sorted(values)) + def expand_subtest(self, fname, test_name, test, allow_inherit, with_lines = False, with_subtest_nr = False): """Expand subtest wildcards providing an array with subtests""" @@ -476,6 +547,8 @@ class TestList: subtest_dict[k] = self.doc[test]["subtest"][subtest][k] + self.update_testlist_field(subtest_dict) + if with_lines: subtest_dict["line"] = file_ln @@ -549,6 +622,8 @@ class TestList: subtest_dict[field] = sub_field + self.update_testlist_field(subtest_dict) + if with_lines: subtest_dict["line"] = file_ln -- 2.41.0