[igt-dev] [PATCH i-g-t v4 10/11] scripts/test_list.py: allow passing a config dict directly
Mauro Carvalho Chehab
mauro.chehab at linux.intel.com
Thu Aug 31 14:52:12 UTC 2023
From: Mauro Carvalho Chehab <mchehab at kernel.org>
Make the logic more generic by allowing to pass a config dict
directly.
Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab at 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 962dbbadeeee..b99e53dccc79 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,
igt_build_path = None,
+ config_dict = None, sources_path = None,
test_tag = "TEST", subtest_tag = "SUBTESTS?",
main_name = "igt", subtest_separator = "@"):
self.doc = {}
@@ -265,18 +267,34 @@ class TestList:
self.internal_fields = [ '_summary_', '_arg_', '_subtest_line_' ]
+ # 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.41.0
More information about the igt-dev
mailing list