Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mauro.chehab@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 5/7] scripts/test_list.py: better handle list of tests
Date: Tue, 24 Oct 2023 16:11:08 +0200	[thread overview]
Message-ID: <20231024141855.160633-6-mauro.chehab@linux.intel.com> (raw)
In-Reply-To: <20231024141855.160633-1-mauro.chehab@linux.intel.com>

From: Mauro Carvalho Chehab <mchehab@kernel.org>

Not all test lists are regular expressions. Some are just
names. That's the case of IGT runner testlist files.

Add support for that.

In practice, this change will produce the same testlists
as before, but using a logic closer to what igt_runner()
does.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
 scripts/test_list.py             | 54 +++++++++++++++++++++++---------
 tests/intel/kms_test_config.json |  2 +-
 tests/intel/xe_test_config.json  |  1 +
 3 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/scripts/test_list.py b/scripts/test_list.py
index e54873f07e20..06215242107a 100644
--- a/scripts/test_list.py
+++ b/scripts/test_list.py
@@ -319,10 +319,6 @@ class TestList:
             self.props["Class"]["_properties_"]["level"] = 1
             self.props["Class"]["_properties_"]["sublevel"] = sublevel_count[0] + 1
 
-        flags = 0
-        if self.config.get("case_insensitive_testlist", False):
-            flags |= re.IGNORECASE
-
         # Remove non-multilevel items, as we're only interested on
         # hierarchical item levels here
         for field, item in self.props.items():
@@ -337,7 +333,7 @@ class TestList:
                 testlist = {}
                 for value in item["_properties_"]["include"]:
                     for name in value.keys():
-                        self.read_testlist(testlist, name, cfg_path + value[name], flags)
+                        self.read_testlist(field, item, testlist, name, cfg_path + value[name])
 
                 item["_properties_"]["include"] = testlist
 
@@ -346,7 +342,7 @@ class TestList:
                 testlist = {}
                 for value in item["_properties_"]["exclude"]:
                     for name in value.keys():
-                        self.read_testlist(testlist, name, cfg_path + value[name], flags)
+                        self.read_testlist(field, item, testlist, name, cfg_path + value[name])
 
                 item["_properties_"]["exclude"] = testlist
 
@@ -450,7 +446,22 @@ class TestList:
 
             self.__add_field(key, sublevel, hierarchy_level, field[key])
 
-    def read_testlist(self, testlist, name, filename, flags):
+    def read_testlist(self, field, item, testlist, name, filename):
+
+        match_type = item["_properties_"].get("match-type", "subtest-match")
+
+        match_type_regex = set(["regex", "regex-ignorecase"])
+        match_type_str = set(["subtest-match"])
+        match_types = match_type_regex | match_type_str
+
+        if match_type not in match_types:
+            sys.exit(f"Error: invalid match type '{match_type}' for {field}")
+
+        if match_type == "regex":
+            flags = 0
+        elif match_type == "regex-ignorecase":
+            flags = re.IGNORECASE
+
         base = r"^\s*({}[^\s\{}]+)(\S*)\s*(\#.*)?$"
         regex = re.compile(base.format(self.main_name, self.subtest_separator))
 
@@ -459,12 +470,25 @@ class TestList:
         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)
-                    if not subtest.endswith("$"):
-                        subtest += r"(\@.*)?$"
-                    testlist[name].append(re.compile(f"{test}{subtest}", flags))
+                if not match:
+                    continue
+
+                test = match.group(1)
+                subtest = match.group(2)
+                test_name = f"{test}{subtest}"
+
+                if match_type in match_type_regex:
+                    testlist[name].append(re.compile(test_name, flags))
+                    continue
+
+                subtests = test_name.split(self.subtest_separator)[:3]
+
+                prefix=""
+                for subtest in subtests:
+                    subtest = prefix + subtest
+                    prefix = subtest + self.subtest_separator
+
+                testlist[name].append(re.compile(f"{subtest}(@.*)?"))
 
     def __filter_subtest(self, test, subtest, field_not_found_value):
 
@@ -504,7 +528,7 @@ class TestList:
             for names, regex_array in self.props[field]["_properties_"]["include"].items():
                 name = set(re.split(",\s*", names))
                 for regex in regex_array:
-                    if regex.match(testname):
+                    if regex.fullmatch(testname):
                         values.update(name)
                         break
 
@@ -514,7 +538,7 @@ class TestList:
                 for names, regex_array in self.props[field]["_properties_"]["exclude"].items():
                     deleted_names = set(re.split(",\s*", names))
                     for regex in regex_array:
-                        if regex.match(testname):
+                        if regex.fullmatch(testname):
                             if sorted(deleted_names) == sorted(values):
                                 set_full_if_empty = False
                             values.discard(deleted_names)
diff --git a/tests/intel/kms_test_config.json b/tests/intel/kms_test_config.json
index 40cf69dd0904..837380ee7fae 100644
--- a/tests/intel/kms_test_config.json
+++ b/tests/intel/kms_test_config.json
@@ -4,7 +4,6 @@
     "files": [ "../chamelium/kms_*.c", "../kms_*.c", "../testdisplay.c", "kms_*.c" ],
     "exclude_files": [ "../chamelium/kms_chamelium_helper.c", "../kms_color_helper.c",
                        "kms_dsc_helper.c" ],
-    "case_insensitive_testlist": true,
     "fields": {
         "Category": {
             "_properties_": {
@@ -24,6 +23,7 @@
                 "_properties_": {
                     "description": "Defines what category of testlist it belongs",
                     "default-testlist": "FULL",
+                    "match-type": "subtest-match",
                     "include": [
                         { "i915 BAT": "../intel-ci/fast-feedback.testlist" },
                         { "i915 BAT chamelium": "../intel-ci/fast-feedback-chamelium-only.testlist" },
diff --git a/tests/intel/xe_test_config.json b/tests/intel/xe_test_config.json
index 20faf73b7270..5fd7c888f274 100644
--- a/tests/intel/xe_test_config.json
+++ b/tests/intel/xe_test_config.json
@@ -33,6 +33,7 @@
                             "mandatory": true,
                             "description": "Defines what category of testlist it belongs",
                             "default-testlist": "FULL",
+                            "match-type": "subtest-match",
                             "include": [
                                 { "Xe BAT": "../intel-ci/xe-fast-feedback.testlist" }
                             ],
-- 
2.41.0

  parent reply	other threads:[~2023-10-24 14:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-24 14:11 [igt-dev] [PATCH i-g-t 0/7] better sync test_list.py with igt_runner Mauro Carvalho Chehab
2023-10-24 14:11 ` [igt-dev] [PATCH i-g-t 1/7] runner: Normalize testlist entries that don't list subtests Mauro Carvalho Chehab
2023-10-24 14:11 ` [igt-dev] [PATCH i-g-t 2/7] runner/runner_tests: Unit tests for binary-name-only testlist entries Mauro Carvalho Chehab
2023-10-24 14:11 ` [igt-dev] [PATCH i-g-t 3/7] runner/runner_tests: Fix name of no-subtests in unit tests Mauro Carvalho Chehab
2023-10-24 14:11 ` [igt-dev] [PATCH i-g-t 4/7] igt_runner: don't require root for dry_run Mauro Carvalho Chehab
2023-10-25  7:53   ` Kamil Konieczny
2023-10-24 14:11 ` Mauro Carvalho Chehab [this message]
2023-10-25  7:54   ` [igt-dev] [PATCH i-g-t 5/7] scripts/test_list.py: better handle list of tests Kamil Konieczny
2023-10-24 14:11 ` [igt-dev] [PATCH i-g-t 6/7] runner/job_list: use case-insensitive regular expressions Mauro Carvalho Chehab
2023-10-25  7:56   ` Kamil Konieczny
2023-10-24 14:11 ` [igt-dev] [PATCH i-g-t 7/7] runner/runner_tests: change a regex to match case-insensitive Mauro Carvalho Chehab
2023-10-25  9:56   ` Kamil Konieczny
2023-10-30  9:56     ` Mauro Carvalho Chehab
2023-10-24 15:45 ` [igt-dev] ✓ Fi.CI.BAT: success for better sync test_list.py with igt_runner Patchwork
2023-10-24 15:46 ` [igt-dev] ✗ GitLab.Pipeline: warning " Patchwork
2023-10-25  4:17 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

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=20231024141855.160633-6-mauro.chehab@linux.intel.com \
    --to=mauro.chehab@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.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