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 v2 08/13] scripts/test_list.py: allow passing a config dict directly
Date: Wed, 12 Jul 2023 15:58:49 +0200	[thread overview]
Message-ID: <20230712135854.957128-9-mauro.chehab@linux.intel.com> (raw)
In-Reply-To: <20230712135854.957128-1-mauro.chehab@linux.intel.com>

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

Make the logic more generic by allowing to pass a config dict
directly.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
 scripts/test_list.py | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/scripts/test_list.py b/scripts/test_list.py
index 5da471617268..9861306bd777 100644
--- a/scripts/test_list.py
+++ b/scripts/test_list.py
@@ -245,8 +245,10 @@ class TestList:
     Description: test ioctls
     """
 
-    def __init__(self, config_fname, include_plan = False, file_list = False,
+    def __init__(self, config_fname = None,
+                 include_plan = False, file_list = None,
                  built_testlist = None,
+                 config_dict = None, sources_path = None,
                  test_tag = "TEST", subtest_tag = "SUBTESTS?",
                  main_name = "igt", subtest_separator = "@"):
         self.doc = {}
@@ -263,18 +265,34 @@ class TestList:
         self.subtest_separator = subtest_separator
         self.main_name = main_name
 
+        # Exclusive or: either one is needed
+        if bool(config_fname) == bool(config_dict):
+            sys.exit("Error: either config filename or config dict shall be used")
+
         if self.main_name:
             self.main_name += subtest_separator
 
-        driver_name = re.sub(r'(.*/)?([^\/]+)/.*', r'\2', config_fname).capitalize()
-
         implemented_class = None
 
-        with open(config_fname, 'r', encoding='utf8') as handle:
-            self.config = json.load(handle)
+        if config_fname:
+            with open(config_fname, 'r', encoding='utf8') as handle:
+                self.config = json.load(handle)
 
-        config_origin = config_fname
-        cfg_path = os.path.realpath(os.path.dirname(config_fname)) + "/"
+            config_origin = config_fname
+            cfg_path = os.path.realpath(os.path.dirname(config_fname)) + "/"
+            driver_name = re.sub(r'(.*/)?([^\/]+)/.*', r'\2', config_fname).capitalize()
+
+        else:
+            self.config = config_dict
+            config_origin = "config dict"
+            cfg_path = "./"
+            driver_name = main_name
+
+        if sources_path:
+            cfg_path = os.path.realpath(sources_path) + "/"
+
+        if not self.config:
+            sys.exit("Error: configuration is empty!")
 
         self.__add_field(None, 0, 0, self.config["fields"])
 
-- 
2.40.1

  parent reply	other threads:[~2023-07-12 13:59 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-12 13:58 [igt-dev] [PATCH i-g-t v2 00/13] Make test_list.py more generic Mauro Carvalho Chehab
2023-07-12 13:58 ` [igt-dev] [PATCH i-g-t v2 01/13] tests/intel-ci/meson.build: Generate and store an intel-ci.testlist Mauro Carvalho Chehab
2023-07-12 17:22   ` Kamil Konieczny
2023-07-12 13:58 ` [igt-dev] [PATCH i-g-t v2 02/13] scripts/test_list.py: make the class more generic Mauro Carvalho Chehab
2023-07-12 17:29   ` Kamil Konieczny
2023-07-12 13:58 ` [igt-dev] [PATCH i-g-t v2 03/13] scripts/test_list.py: rename the internal summary value Mauro Carvalho Chehab
2023-07-12 17:31   ` Kamil Konieczny
2023-07-12 13:58 ` [igt-dev] [PATCH i-g-t v2 04/13] scripts/igt_doc.py: pass a single file when checking docs Mauro Carvalho Chehab
2023-07-12 13:58 ` [igt-dev] [PATCH i-g-t v2 05/13] scripts/test_list.py: document what BAT stands for Mauro Carvalho Chehab
2023-07-12 18:30   ` Kamil Konieczny
2023-07-12 13:58 ` [igt-dev] [PATCH i-g-t v2 06/13] scripts/test_list.py: close config file before start processing Mauro Carvalho Chehab
2023-07-12 18:38   ` Kamil Konieczny
2023-07-13  5:47     ` Mauro Carvalho Chehab
2023-07-13 10:20       ` Kamil Konieczny
2023-07-12 13:58 ` [igt-dev] [PATCH i-g-t v2 07/13] scripts/test_list.py: don't rely on file name to parse config Mauro Carvalho Chehab
2023-07-12 18:42   ` Kamil Konieczny
2023-07-12 13:58 ` Mauro Carvalho Chehab [this message]
2023-07-12 18:45   ` [igt-dev] [PATCH i-g-t v2 08/13] scripts/test_list.py: allow passing a config dict directly Kamil Konieczny
2023-07-12 13:58 ` [igt-dev] [PATCH i-g-t v2 09/13] scripts/igt_doc.py: use field names when create a TestList instance Mauro Carvalho Chehab
2023-07-12 18:50   ` Kamil Konieczny
2023-07-12 13:58 ` [igt-dev] [PATCH i-g-t v2 10/13] scripts/test_list.py: add a check before deleting properties Mauro Carvalho Chehab
2023-07-12 18:52   ` Kamil Konieczny
2023-07-12 13:58 ` [igt-dev] [PATCH i-g-t v2 11/13] scripts/test_list.py: filename arguments for print_ methods are optional Mauro Carvalho Chehab
2023-07-12 18:55   ` Kamil Konieczny
2023-07-12 13:58 ` [igt-dev] [PATCH i-g-t v2 12/13] scripts/test_list.py: skip some internal fields Mauro Carvalho Chehab
2023-07-12 19:12   ` Kamil Konieczny
2023-07-13  5:52     ` Mauro Carvalho Chehab
2023-07-12 13:58 ` [igt-dev] [PATCH i-g-t v2 13/13] scripts/test_list.py: add support to return a string instead of print Mauro Carvalho Chehab
2023-07-12 14:44 ` [igt-dev] ✗ Fi.CI.BUILD: failure for Make test_list.py more generic Patchwork
2023-07-13  9:12 ` [igt-dev] ✗ Fi.CI.BUILD: failure for Make test_list.py more generic (rev2) Patchwork
2023-07-13 11:32 ` [igt-dev] ✗ Fi.CI.BUILD: failure for Make test_list.py more generic (rev3) 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=20230712135854.957128-9-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