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: [PATCH i-g-t 7/8] scripts/igt_doc.py: use an ancillary function to simplify the code
Date: Fri,  9 Feb 2024 12:17:05 +0100	[thread overview]
Message-ID: <20240209111925.271717-8-mauro.chehab@linux.intel.com> (raw)
In-Reply-To: <20240209111925.271717-1-mauro.chehab@linux.intel.com>

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

The code inside gen_intelci_testlist() is too complex, and currently
buggy.

Basically, if we have two testlists with driver name + name, like
"Xe BAT" and "i915 BAT", the current logic picks just one
(randomly), which produce different results on each run.

Simplify the logic by moving the routine which fills the run_type
set to a separate function, fixing the bug.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
 scripts/igt_doc.py | 72 ++++++++++++++++++++++++++++------------------
 1 file changed, 44 insertions(+), 28 deletions(-)

diff --git a/scripts/igt_doc.py b/scripts/igt_doc.py
index 1b4f7eafd135..3a45371a27e7 100755
--- a/scripts/igt_doc.py
+++ b/scripts/igt_doc.py
@@ -18,6 +18,40 @@ import sys
 from test_list import TestList
 
 class IgtTestList(TestList):
+    def __init__(self, *args, **kwargs):
+        self.split_regex = re.compile(r",\s*")
+
+        super().__init__(*args, **kwargs)
+
+    def _get_run_type_drivers(self, run_types):
+        """
+            Ancillary routine to return drivers and run type set from
+            a run type string.
+        """
+
+        run_type_dict = {}
+        for run_type in set(self.split_regex.split(run_types)):
+            driver_set = set()
+            if not run_type:
+                run_type = "other"
+            else:
+                for driver in self.drivers:
+                    result = re.sub(r"^" + driver + r"[\W_]*", "", run_type, re.IGNORECASE)
+                    if result != run_type:
+                        driver_set = set([driver])
+                        run_type = result
+                        break
+
+            if not driver_set:
+                driver_set = set(self.drivers)
+
+            if run_type in run_type_dict:
+                run_type_dict[run_type].update(driver_set)
+            else:
+                run_type_dict[run_type] = driver_set
+
+        return run_type_dict
+
     """
         This class implements testlist generation as expected by Intel CI.
         It does that by handling test lists split by "Run type" and
@@ -50,7 +84,7 @@ class IgtTestList(TestList):
         - if "GPU excluded platform" exists, for each GPU listed on
           the list, it will block the test.
     """
-    def gen_intelci_testlist(self): #pylint: disable=R0912
+    def gen_intelci_testlist(self):
         """Return a list of gpu configs and testlists."""
 
         subtest_dict = self.expand_dictionary(True)
@@ -58,48 +92,30 @@ class IgtTestList(TestList):
         # Create a tests_per_list dict
         gpu_set = set()
         tests_per_list = {}
-        split_regex = re.compile(r",\s*")
+
+        for driver in set(self.drivers):
+            tests_per_list[driver] = {}
 
         for subname, subtest in subtest_dict.items():
             run_types = subtest.get("Run type", "other").lower()
-            drivers = set()
-            run_type_set = set()
-            for run_type in set(split_regex.split(run_types)):
 
-                for driver in self.drivers:
-                    if run_type.startswith(driver):
-                        run_type = re.sub(r"^" + driver + r"[\W_]*", "", run_type)
-                        drivers = set([driver])
-                        break
+            run_type_dict = self._get_run_type_drivers(run_types)
 
-                if not drivers:
-                    drivers.update(self.drivers)
-
-                if not run_type:
-                    run_type = "other"
-
-                run_type_set.add(run_type)
-
-            if not drivers:
-                drivers = set(self.drivers)
-
-            for driver in drivers:
-                if driver not in tests_per_list:
-                    tests_per_list[driver] = {}
-
-                for run_type in run_type_set:
+            for run_type, drivers in run_type_dict.items():
+                for driver in drivers:
                     if run_type not in tests_per_list[driver]:
                         tests_per_list[driver][run_type] = {}
+
                     if subname not in tests_per_list[driver][run_type]:
                         tests_per_list[driver][run_type][subname] = {}
 
                     if "GPU" in subtest:
-                        for gpu in split_regex.split(subtest["GPU"]):
+                        for gpu in self.split_regex.split(subtest["GPU"]):
                             gpu_set.add(gpu)
                             tests_per_list[driver][run_type][subname][gpu] = True
 
                     if "GPU excluded platform" in subtest:
-                        for gpu in split_regex.split(subtest["GPU excluded platform"]):
+                        for gpu in self.split_regex.split(subtest["GPU excluded platform"]):
                             gpu_set.add(gpu)
                             tests_per_list[driver][run_type][subname][gpu] = False
 
-- 
2.43.0


  parent reply	other threads:[~2024-02-09 11:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-09 11:16 [PATCH i-g-t 0/8] Fix several issues when producing Intel CI testlists Mauro Carvalho Chehab
2024-02-09 11:16 ` [PATCH i-g-t 1/8] scripts/test_list.py: fix a typo on default-if-not-excluded Mauro Carvalho Chehab
2024-02-09 11:17 ` [PATCH i-g-t 2/8] scripts/igt_doc.py: better handle issues with empty testlists Mauro Carvalho Chehab
2024-02-09 11:17 ` [PATCH i-g-t 3/8] scripts/igt_doc.py: handle empty run_type Mauro Carvalho Chehab
2024-02-09 11:17 ` [PATCH i-g-t 4/8] scripts/igt_doc.py: only create dict if subtest will be added Mauro Carvalho Chehab
2024-02-09 11:17 ` [PATCH i-g-t 5/8] scripts/igt_doc.py: better handle default gpu Mauro Carvalho Chehab
2024-02-09 11:17 ` [PATCH i-g-t 6/8] scripts/igt_doc.py: remove some unused logic Mauro Carvalho Chehab
2024-02-09 11:17 ` Mauro Carvalho Chehab [this message]
2024-02-09 11:17 ` [PATCH i-g-t 8/8] scripts/igt_doc.py: simplify and cleanup tests_per_list logic Mauro Carvalho Chehab
2024-02-09 11:37 ` ✗ Fi.CI.BUILD: failure for Fix several issues when producing Intel CI testlists 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=20240209111925.271717-8-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