Skip to contentSkip to conversation

Make test_list.py more generic

PATCH Superseded Mauro Carvalho Chehab 3 participants 21 messages Jul 13, 2023 Arm/Amlogic Meson SoC support

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Make test_list.py more generic

From: Mauro Carvalho Chehab <[email protected]>

While most of the code at test_list.py is generic, it contains a couple of IGT-specific stuff on it.

I'm planning to make it more generic, as we also need to document in-kernel tests (KUnit).

So, let's remove what's specific to IGT to the main logic. This way, the same code can be sent to the Linux Kernel upstream, to be used to document kunit and kselftests there.

---

v3:
- fixed dependencies for built_script target;
- added an extra cleanup patch to better handle internal fields.

Mauro Carvalho Chehab (14):
tests/intel-ci/meson.build: Generate and store an intel-ci.testlist scripts/test_list.py: make the class more generic scripts/test_list.py: rename the internal summary value scripts/igt_doc.py: pass a single file when checking docs scripts/test_list.py: document what BAT stands for scripts/test_list.py: close config file before start processing scripts/test_list.py: don't rely on file name to parse config scripts/test_list.py: allow passing a config dict directly scripts/igt_doc.py: use field names when create a TestList instance scripts/test_list.py: add a check before deleting properties scripts/test_list.py: filename arguments for print_ methods are
optional
scripts/test_list.py: skip some internal fields scripts/test_list.py: add support to return a string instead of print scripts/test_list.py: better handle internal fields

 docs/testplan/meson.build  |   2 +-
 scripts/igt_doc.py         |  10 +-
 scripts/test_list.py       | 419 ++++++++++++++++++++-----------------
 tests/intel-ci/meson.build |   9 +
 4 files changed, 238 insertions(+), 202 deletions(-)
 mode change 100755 => 100644 scripts/test_list.py
Signature · 1 line
2.40.1
#1 lore raw

PATCH v3 1/14 tests/intel-ci/meson.build: Generate and store an intel-ci.testlist

From: Mauro Carvalho Chehab <[email protected]>

Store a sorted testlist with tests that could be used to test the DRM core and the Intel drivers in a format that it would be expected by igt_runner.

This is a preparation to simplify test_list.py checks to make it more generic.

---
 tests/intel-ci/meson.build | 9 +++++++++
 1 file changed, 9 insertions(+)
tests/intel-ci/meson.build +9 -0
index d5a6e4f47203..076f74d6b5d0 100644
@@ -9,4 +9,13 @@ intelci_files = [
   'xe.blocklist.txt',
 ]
 
+built_testlist = custom_target('intel-ci.testlist',
+              build_by_default : true,
+              command : ['sort', testlist_files],
+              install : true,
+              install_dir : datadir,
+              depends : testlist_files,
+              capture : true,
+              output : 'intel-ci.testlist')
+
 install_data(sources : intelci_files, install_dir : datadir)
Signature · 1 line
2.40.1
#2 lore raw

PATCH v3 2/14 scripts/test_list.py: make the class more generic

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Currently, the class is meant to be used only on IGT. However, it could also be used on other projects. It actually makes sense to port it to the Kernel, in order to document KUnit and Kselftests.

Make the class more generic by allowing the constructor to pass three additional arguments:
- The tag name for the test group ("TEST");
- The tag name for the subtest group ("SUBTEST");
- the prefix name for the tests;
- the separator between testa and subtests.

---
 scripts/test_list.py | 43 ++++++++++++++++++++++++++++---------------
 1 file changed, 28 insertions(+), 15 deletions(-)
scripts/test_list.py +28 -15
index 4f580fb3de58..3fcf0900c0e5 100755
@@ -101,8 +101,8 @@ class TestList:
 
     """
     Parse and handle test lists with test/subtest documentation, in the
-    form of C comments, with two meta-tags (TEST and SUBTEST), and a set of
-    `field: value` items:
+    form of C comments, with two meta-tags (by default, TEST and SUBTEST),
+    and a set of `field: value` items:
 
         /**
          * TEST: Check if new IGT test documentation logic functionality is working
@@ -246,7 +246,9 @@ class TestList:
     """
 
     def __init__(self, config_fname, include_plan = False, file_list = False,
-                 igt_build_path = None):
+                 igt_build_path = None,
+                 test_tag = "TEST", subtest_tag = "SUBTESTS?",
+                 main_name = "igt", subtest_separator = "@"):
         self.doc = {}
         self.test_number = 0
         self.config = None
@@ -259,6 +261,11 @@ class TestList:
         self.field_list = {}
         self.title = None
         self.filters = {}
+        self.subtest_separator = subtest_separator
+        self.main_name = main_name
+
+        if self.main_name:
+            self.main_name += subtest_separator
 
         driver_name = re.sub(r'(.*/)?([^\/]+)/.*', r'\2', config_fname).capitalize()
 
@@ -355,11 +362,13 @@ class TestList:
             if fname == '':
                 continue
 
-            self.__add_file_documentation(fname, implemented_class, field_re)
+            self.__add_file_documentation(fname, implemented_class, field_re,
+                                          test_tag, subtest_tag)
 
         if include_plan:
             for fname in self.plan_filenames:
-                self.__add_file_documentation(fname, planned_class, field_re)
+                self.__add_file_documentation(fname, planned_class, field_re,
+                                              test_tag, subtest_tag)
 
     #
     # ancillary methods
@@ -421,7 +430,7 @@ class TestList:
         for subtest in self.doc[test]["subtest"].keys():
             summary = test_name
             if self.doc[test]["subtest"][subtest]["Summary"] != '':
-                summary += '@' + self.doc[test]["subtest"][subtest]["Summary"]
+                summary += self.subtest_separator + self.doc[test]["subtest"][subtest]["Summary"]
             if not summary:
                 continue
 
@@ -551,7 +560,7 @@ class TestList:
 
             name = re.sub(r'.*/', '', fname)
             name = re.sub(r'\.[\w+]$', '', name)
-            name = "igt@" + name
+            name = self.main_name + name
 
             if not subtest_only:
                 test_dict[name] = {}
@@ -606,7 +615,7 @@ class TestList:
 
             name = re.sub(r'.*/', '', fname)
             name = re.sub(r'\.[ch]', '', name)
-            name = "igt@" + name
+            name = self.main_name + name
 
             tmp_subtest = self.expand_subtest(fname, name, test, False)
 
@@ -844,7 +853,7 @@ class TestList:
 
             test_name = re.sub(r'.*/', '', fname)
             test_name = re.sub(r'\.[ch]', '', test_name)
-            test_name = "igt@" + test_name
+            test_name = self.main_name + test_name
 
             subtest_array += self.expand_subtest(fname, test_name, test, True)
 
@@ -941,8 +950,8 @@ class TestList:
         args_regex = re.compile(r'\<[^\>]+\>')
 
         for subtest in self.get_subtests()[""]:
-            subtest = "@".join(subtest.split("@")[:3])
-            subtest = args_regex.sub(r'\\d+', subtest)
+            subtest = self.subtest_separator.join(subtest.split(self.subtest_separator)[:3])
+            subtest = re.sub(r'\<[^\>]+\>', r'\\d+', subtest)
             doc_subtests.add(subtest)
 
         doc_subtests = list(sorted(doc_subtests))
@@ -993,7 +1002,8 @@ class TestList:
     # File handling methods
     #
 
-    def __add_file_documentation(self, fname, implemented_class, field_re):
+    def __add_file_documentation(self, fname, implemented_class, field_re,
+                                 test_tag, subtest_tag):
 
         """Adds the contents of test/subtest documentation form a file"""
 
@@ -1007,6 +1017,9 @@ class TestList:
         cur_arg_element = 0
         has_test_or_subtest = 0
 
+        test_regex = re.compile(test_tag + r':\s*(.*)')
+        subtest_regex = re.compile('^' + subtest_tag + r':\s*(.*)')
+
         with open(fname, 'r', encoding='utf8') as handle:
             arg_ref = None
             current_test = ''
@@ -1041,7 +1054,7 @@ class TestList:
                     current_field = ''
 
                     # Check if it is a new TEST section
-                    match = re.match(r'^TEST:\s*(.*)', file_line)
+                    match = test_regex.match(file_line)
                     if match:
                         has_test_or_subtest = 1
                         current_test = self.test_number
@@ -1063,7 +1076,7 @@ class TestList:
                         continue
 
                 # Check if it is a new SUBTEST section
-                match = re.match(r'^SUBTESTS?:\s*(.*)', file_line)
+                match = subtest_regex.match(file_line)
                 if match:
                     has_test_or_subtest = 1
                     current_subtest = subtest_number
@@ -1228,7 +1241,7 @@ class TestList:
         """Generate testlists from the test documentation"""
 
         test_prefix = os.path.commonprefix(self.get_subtests()[""])
-        test_prefix = re.sub(r'^igt@', '', test_prefix)
+        test_prefix = re.sub(r'^' + self.main_name, '', test_prefix)
 
         # NOTE: currently, it uses a comma for multi-value delimitter
         test_subtests = self.get_subtests(sort_field, ",", with_order = True)
Signature · 1 line
2.40.1
#3 lore raw

PATCH v3 3/14 scripts/test_list.py: rename the internal summary value

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

The sumary is used internally. So, it is not meant to be used as a normal field. To avoid possible clashes in the future, rename the internal usage to _summary_, as we're using _foo_ for internal properties.

---
 scripts/test_list.py | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)
scripts/test_list.py +22 -22
index 3fcf0900c0e5..330ad95231fa 100755
@@ -429,8 +429,8 @@ class TestList:
 
         for subtest in self.doc[test]["subtest"].keys():
             summary = test_name
-            if self.doc[test]["subtest"][subtest]["Summary"] != '':
-                summary += self.subtest_separator + self.doc[test]["subtest"][subtest]["Summary"]
+            if self.doc[test]["subtest"][subtest]["_summary_"] != '':
+                summary += self.subtest_separator + self.doc[test]["subtest"][subtest]["_summary_"]
             if not summary:
                 continue
 
@@ -441,10 +441,10 @@ class TestList:
             if num_vars == 0:
                 subtest_dict = {}
 
-                subtest_dict["Summary"] = summary
+                subtest_dict["_summary_"] = summary
 
                 for k in sorted(self.doc[test]["subtest"][subtest].keys()):
-                    if k in [ 'Summary', 'arg', 'subtest_line' ]:
+                    if k in [ '_summary_', 'arg', 'subtest_line' ]:
                         continue
 
                     if not allow_inherit:
@@ -510,10 +510,10 @@ class TestList:
 
                 # Store the element
                 subtest_dict = {}
-                subtest_dict["Summary"] = arg_summary
+                subtest_dict["_summary_"] = arg_summary
 
                 for field in sorted(self.doc[test]["subtest"][subtest].keys()):
-                    if field in [ 'Summary', 'arg', 'subtest_line' ]:
+                    if field in [ '_summary_', 'arg', 'subtest_line' ]:
                         continue
 
                     sub_field = self.doc[test]["subtest"][subtest][field]
@@ -581,11 +581,11 @@ class TestList:
                 if self.__filter_subtest(self.doc[test], subtest, True):
                     continue
 
-                summary = subtest["Summary"]
+                summary = subtest["_summary_"]
 
                 dic[summary] = {}
                 for field in sorted(subtest.keys()):
-                    if field in [ 'Summary', 'arg', 'subtest_line' ]:
+                    if field in [ '_summary_', 'arg', 'subtest_line' ]:
                         continue
                     dic[summary][field] = subtest[field]
 
@@ -646,12 +646,12 @@ class TestList:
             for subtest in subtest_array:
 
                 print()
-                print(subtest["Summary"])
-                print(len(subtest["Summary"]) * '=')
+                print(subtest["_summary_"])
+                print(len(subtest["_summary_"]) * '=')
                 print("")
 
                 for field in sorted(subtest.keys()):
-                    if field in [ 'Summary', 'arg', 'subtest_line' ]:
+                    if field in [ '_summary_', 'arg', 'subtest_line' ]:
                         continue
 
                     print(f":{field}:", subtest[field])
@@ -857,7 +857,7 @@ class TestList:
 
             subtest_array += self.expand_subtest(fname, test_name, test, True)
 
-        subtest_array.sort(key = lambda x : x.get('Summary'))
+        subtest_array.sort(key = lambda x : x.get('_summary_'))
 
         for subtest in subtest_array:
             if self.__filter_subtest(self.doc[test], subtest, True):
@@ -873,27 +873,27 @@ class TestList:
                             if test_elem not in subtests:
                                 subtests[test_elem] = []
                             if order:
-                                subtests[test_elem].append((subtest["Summary"], test_list))
+                                subtests[test_elem].append((subtest["_summary_"], test_list))
                             else:
-                                subtests[test_elem].append(subtest["Summary"])
+                                subtests[test_elem].append(subtest["_summary_"])
                     else:
                         if subtest[sort_field] not in subtests:
                             subtests[subtest[sort_field]] = []
                             if order:
-                                subtests[test_elem].append((subtest["Summary"], [subtest[sort_field]]))
+                                subtests[test_elem].append((subtest["_summary_"], [subtest[sort_field]]))
                             else:
-                                subtests[subtest[sort_field]].append(subtest["Summary"])
+                                subtests[subtest[sort_field]].append(subtest["_summary_"])
                 else:
                     if order:
-                        subtests[test_elem].append((subtest["Summary"], [subtest[sort_field]]))
+                        subtests[test_elem].append((subtest["_summary_"], [subtest[sort_field]]))
                     else:
-                        subtests[""].append(subtest["Summary"])
+                        subtests[""].append(subtest["_summary_"])
 
             else:
                 if order:
-                    subtests[test_elem].append((subtest["Summary"], [subtest[sort_field]]))
+                    subtests[test_elem].append((subtest["_summary_"], [subtest[sort_field]]))
                 else:
-                    subtests[""].append(subtest["Summary"])
+                    subtests[""].append(subtest["_summary_"])
 
         if order:
             for group, tests in subtests.items():
@@ -1064,7 +1064,7 @@ class TestList:
 
                         self.doc[current_test] = {}
                         self.doc[current_test]["arg"] = {}
-                        self.doc[current_test]["Summary"] = match.group(1)
+                        self.doc[current_test]["_summary_"] = match.group(1)
                         self.doc[current_test]["File"] = fname
                         self.doc[current_test]["subtest"] = {}
                         self.doc[current_test]["subtest_line"] = {}
@@ -1102,7 +1102,7 @@ class TestList:
                             continue
                         self.doc[current_test]["subtest"][current_subtest][field] = self.doc[current_test][field]
 
-                    self.doc[current_test]["subtest"][current_subtest]["Summary"] = match.group(1)
+                    self.doc[current_test]["subtest"][current_subtest]["_summary_"] = match.group(1)
                     self.doc[current_test]["subtest"][current_subtest]["Description"] = ''
                     self.doc[current_test]["subtest_line"][current_subtest] = file_ln
 
Signature · 1 line
2.40.1
#4 lore raw

PATCH v3 4/14 scripts/igt_doc.py: pass a single file when checking docs

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Instead of passing a directory with several *.testlist files, pass intel-ci.testlist, which should contain already everything.

That makes the script a lot more generic, as there won't be any real dependencies from IGT related to the check logic.

---
 docs/testplan/meson.build |  2 +-
 scripts/igt_doc.py        |  6 +++---
 scripts/test_list.py      | 42 +++++++++++++++++++--------------------
 3 files changed, 25 insertions(+), 25 deletions(-)
 mode change 100755 => 100644 scripts/test_list.py
docs/testplan/meson.build +1 -1
index e838f2eb1540..b388a04b20ea 100644
@@ -16,7 +16,7 @@ if build_tests
 	# Check if documentation matches the actual tests and tests can run
 	if not meson.is_cross_build()
 		build_info += 'Will Check if documentation is in sync with testlist'
-		check_testlist = [ '--check-testlist', '--igt-build-path', build_root ]
+		check_testlist = [ '--check-testlist', '--built-testlist', built_testlist.full_path() ]
 	else
 		warning('WARNING: Will not check if documentation is in sync with testlist')
 	endif
scripts/igt_doc.py +3 -3
index 38e2bdee4f2a..c02029e03a31 100755
@@ -38,8 +38,8 @@ parser.add_argument("--check-testlist", action="store_true",
                     help="Compare documentation against IGT built tests.")
 parser.add_argument("--include-plan", action="store_true",
                     help="Include test plans, if any.")
-parser.add_argument("--igt-build-path",
-                    help="Path to the IGT build directory. Used by --check-testlist.",
+parser.add_argument("--built-testlist",
+                    help="Testlist generated at build time. Used by --check-testlist.",
                     default=IGT_BUILD_PATH)
 parser.add_argument("--gen-testlist",
                     help="Generate documentation at the GEN_TESTLIST directory, using SORT_FIELD to split the tests. Requires --sort-field.")
@@ -49,7 +49,7 @@ parser.add_argument('--files', nargs='+',
 parse_args = parser.parse_args()
 
 tests = TestList(parse_args.config, parse_args.include_plan, parse_args.files,
-                 parse_args.igt_build_path)
+                 parse_args.built_testlist)
 
 if parse_args.filter_field:
     for filter_expr in parse_args.filter_field:
scripts/test_list.py +21 -21

78 lines not on this page · raw message

Signature · 1 line
2.40.1
#5 lore raw

Re: [igt-dev] [PATCH i-g-t v3 04/14] scripts/igt_doc.py: pass a single file when checking docs

Hi Mauro,

Quoted 128 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Instead of passing a directory with several *.testlist files, pass intel-ci.testlist, which should contain already everything.

That makes the script a lot more generic, as there won't be any real dependencies from IGT related to the check logic.

---
 docs/testplan/meson.build |  2 +-
 scripts/igt_doc.py        |  6 +++---
 scripts/test_list.py      | 42 +++++++++++++++++++--------------------
 3 files changed, 25 insertions(+), 25 deletions(-)
 mode change 100755 => 100644 scripts/test_list.py
docs/testplan/meson.build +1 -1
index e838f2eb1540..b388a04b20ea 100644
@@ -16,7 +16,7 @@ if build_tests
 	# Check if documentation matches the actual tests and tests can run
 	if not meson.is_cross_build()
 		build_info += 'Will Check if documentation is in sync with testlist'
-		check_testlist = [ '--check-testlist', '--igt-build-path', build_root ]
+		check_testlist = [ '--check-testlist', '--built-testlist', built_testlist.full_path() ]
 	else
 		warning('WARNING: Will not check if documentation is in sync with testlist')
 	endif
scripts/igt_doc.py +3 -3
index 38e2bdee4f2a..c02029e03a31 100755
@@ -38,8 +38,8 @@ parser.add_argument("--check-testlist", action="store_true",
                     help="Compare documentation against IGT built tests.")
 parser.add_argument("--include-plan", action="store_true",
                     help="Include test plans, if any.")
-parser.add_argument("--igt-build-path",
-                    help="Path to the IGT build directory. Used by --check-testlist.",
+parser.add_argument("--built-testlist",
+                    help="Testlist generated at build time. Used by --check-testlist.",
                     default=IGT_BUILD_PATH)
 parser.add_argument("--gen-testlist",
                     help="Generate documentation at the GEN_TESTLIST directory, using SORT_FIELD to split the tests. Requires --sort-field.")
@@ -49,7 +49,7 @@ parser.add_argument('--files', nargs='+',
 parse_args = parser.parse_args()
 
 tests = TestList(parse_args.config, parse_args.include_plan, parse_args.files,
-                 parse_args.igt_build_path)
+                 parse_args.built_testlist)
 
 if parse_args.filter_field:
     for filter_expr in parse_args.filter_field:
scripts/test_list.py +10 -21
old mode 100755
new mode 100644
index 330ad95231fa..cfff4153b8d9
@@ -246,7 +246,7 @@ class TestList:
     """
 
     def __init__(self, config_fname, include_plan = False, file_list = False,
-                 igt_build_path = None,
+                 built_testlist = None,
                  test_tag = "TEST", subtest_tag = "SUBTESTS?",
                  main_name = "igt", subtest_separator = "@"):
         self.doc = {}
@@ -256,7 +256,7 @@ class TestList:
         self.plan_filenames = []
         self.props = {}
         self.config_fname = config_fname
-        self.igt_build_path = igt_build_path
+        self.built_testlist = built_testlist
         self.level_count = 0
         self.field_list = {}
         self.title = None
@@ -852,7 +852,7 @@ class TestList:
             fname = self.doc[test]["File"]
 
             test_name = re.sub(r'.*/', '', fname)
-            test_name = re.sub(r'\.[ch]', '', test_name)
+            test_name = re.sub(r'\.[ch]\s*', '', test_name)
             test_name = self.main_name + test_name
 
             subtest_array += self.expand_subtest(fname, test_name, test, True)
@@ -918,29 +918,15 @@ class TestList:
 
         return subtests
 
-    def get_testlist(self):
-
-        """ Return a list of tests as reported by --list-subtests """
-        tests = []
-        for name in self.filenames:
-            fname = re.sub(r"\.c$", ".testlist", name.split('/')[-1])
-            fname = os.path.join(self.igt_build_path, "tests", fname)
-
-            with open(fname, 'r', encoding='utf8') as handle:
-                for line in handle:
-                    tests.append(line.rstrip("\n"))
-
-        return sorted(tests)
-
     #
     # Validation methods
     #
     def check_tests(self):
 
-        """Compare documented subtests with the IGT test list"""
+        """Compare documented subtests with the test list"""
 
-        if not self.igt_build_path:
-            sys.exit("Need the IGT build path")
+        if not self.built_testlist:
+            sys.exit("Need the build path where the exec files are located")
 
         if self.filters:
             print("NOTE: test checks are affected by filters")
@@ -957,7 +943,21 @@ class TestList:
         doc_subtests = list(sorted(doc_subtests))
 
         # Get a list of tests from
-        run_subtests = self.get_testlist()
+        tests = set()
+        for name in self.filenames:
+            test = self.main_name + re.sub(r"\.c$", "", name.split('/')[-1])
+            tests.add(test)

scripts/test_list.py class TestList: · line 959

Quoted 10 lines
scripts/test_list.py +10 -0
+
+        run_subtests = []
+        with open(self.built_testlist, 'r', encoding='utf8') as handle:
+            for line in handle:
+                name = line.rstrip("\n")
+                if name in tests:
+                    run_subtests.append(name)
+                else:
+                    result = name.rsplit(self.subtest_separator, 1)[0]
+                    if name in tests:

------------------------- ^

scripts/test_list.py class TestList: · line 960

Quoted 1 line
scripts/test_list.py +1 -0
+                        run_subtests.append(name)

---------------------------------------------- ^
imho s/name/result/

Regards,
Kamil

Quoted 6 lines
scripts/test_list.py +0 -0
         # Compare arrays
 
Signature · 1 line
2.40.1
#6 lore raw

PATCH v3 5/14 scripts/test_list.py: document what BAT stands for

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

BAT means Basic Accetance Test, which is a set of tests that are meant to test basic functionalities and provide a fast feedback. Add some documentation where the term is present at the code.

---
 scripts/test_list.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/test_list.py +1 -1
index cfff4153b8d9..565760dc0201 100644
@@ -1256,7 +1256,7 @@ class TestList:
             testlist = test.lower()
             if testlist == "":
                 fname = "other"
-            elif testlist == "bat":
+            elif testlist == "bat":         # Basic Acceptance Test
                 fname = "fast-feedback"
             else:
                 fname = testlist
Signature · 1 line
2.40.1
#7 lore raw

PATCH v3 6/14 scripts/test_list.py: close config file before start processing

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Reduce the identation level of the code which parses the config file, as this can be done after closing the file.

This is a preparation for the next patch that will offer a different way to pass the configuration.

---
 scripts/test_list.py | 114 +++++++++++++++++++++----------------------
 1 file changed, 57 insertions(+), 57 deletions(-)
scripts/test_list.py +57 -57
index 565760dc0201..ac77d6523672 100644
@@ -274,71 +274,71 @@ class TestList:
         with open(config_fname, 'r', encoding='utf8') as handle:
             self.config = json.load(handle)
 
-            self.__add_field(None, 0, 0, self.config["fields"])
+        self.__add_field(None, 0, 0, self.config["fields"])
 
-            sublevel_count = [ 0 ] * self.level_count
+        sublevel_count = [ 0 ] * self.level_count
 
-            for field, item in self.props.items():
-                if "sublevel" in item["_properties_"]:
-                    level = item["_properties_"]["level"]
-                    sublevel = item["_properties_"]["sublevel"]
-                    if sublevel > sublevel_count[level - 1]:
-                        sublevel_count[level - 1] = sublevel
+        for field, item in self.props.items():
+            if "sublevel" in item["_properties_"]:
+                level = item["_properties_"]["level"]
+                sublevel = item["_properties_"]["sublevel"]
+                if sublevel > sublevel_count[level - 1]:
+                    sublevel_count[level - 1] = sublevel
 
-                field_lc = field.lower()
-                self.field_list[field_lc] = field
-                field_plural = _plural(field_lc)
-                if field_lc != field_plural:
-                    self.field_list[field_plural] = field
+            field_lc = field.lower()
+            self.field_list[field_lc] = field
+            field_plural = _plural(field_lc)
+            if field_lc != field_plural:
+                self.field_list[field_plural] = field
 
-            if include_plan:
-                self.props["Class"] = {}
-                self.props["Class"]["_properties_"] = {}
-                self.props["Class"]["_properties_"]["level"] = 1
-                self.props["Class"]["_properties_"]["sublevel"] = sublevel_count[0] + 1
+        if include_plan:
+            self.props["Class"] = {}
+            self.props["Class"]["_properties_"] = {}
+            self.props["Class"]["_properties_"]["level"] = 1
+            self.props["Class"]["_properties_"]["sublevel"] = sublevel_count[0] + 1
 
-            # Remove non-multilevel items, as we're only interested on
-            # hierarchical item levels here
-            for field, item in self.props.items():
-                if "sublevel" in item["_properties_"]:
-                    level = item["_properties_"]["level"]
-                    if sublevel_count[level - 1] == 1:
-                        del item["_properties_"]["level"]
-                        del item["_properties_"]["sublevel"]
-            del self.props["_properties_"]
+        # Remove non-multilevel items, as we're only interested on
+        # hierarchical item levels here
+        for field, item in self.props.items():
+            if "sublevel" in item["_properties_"]:
+                level = item["_properties_"]["level"]
+                if sublevel_count[level - 1] == 1:
+                    del item["_properties_"]["level"]
+                    del item["_properties_"]["sublevel"]
+        del self.props["_properties_"]
 
-            has_implemented = False
-            if not self.filenames:
-                self.filenames = []
-                exclude_files = []
-                files = self.config["files"]
-                exclude_file_glob = self.config.get("exclude_files", [])
-                for cfg_file in exclude_file_glob:
-                    cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
-                    for fname in glob.glob(cfg_file):
-                        exclude_files.append(fname)
+        has_implemented = False
+        if not self.filenames:
+            self.filenames = []
+            exclude_files = []
+            files = self.config["files"]
+            exclude_file_glob = self.config.get("exclude_files", [])
+            for cfg_file in exclude_file_glob:
+                cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
+                for fname in glob.glob(cfg_file):
+                    exclude_files.append(fname)
 
-                for cfg_file in files:
-                    cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
-                    for fname in glob.glob(cfg_file):
-                        if fname in exclude_files:
-                            continue
-                        self.filenames.append(fname)
-                        has_implemented = True
-            else:
-                for cfg_file in self.filenames:
-                    if cfg_file:
-                        has_implemented = True
+            for cfg_file in files:
+                cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
+                for fname in glob.glob(cfg_file):
+                    if fname in exclude_files:
+                        continue
+                    self.filenames.append(fname)
+                    has_implemented = True
+        else:
+            for cfg_file in self.filenames:
+                if cfg_file:
+                    has_implemented = True
 
-            has_planned = False
-            if include_plan and "planning_files" in self.config:
-                implemented_class = "Implemented"
-                files = self.config["planning_files"]
-                for cfg_file in files:
-                    cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
-                    for fname in glob.glob(cfg_file):
-                        self.plan_filenames.append(fname)
-                        has_planned = True
+        has_planned = False
+        if include_plan and "planning_files" in self.config:
+            implemented_class = "Implemented"
+            files = self.config["planning_files"]
+            for cfg_file in files:
+                cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
+                for fname in glob.glob(cfg_file):
+                    self.plan_filenames.append(fname)
+                    has_planned = True
 
         planned_class = None
         if has_implemented:
Signature · 1 line
2.40.1
Reviewed-by on v3 6/14
#8 lore raw

Re: [igt-dev] [PATCH i-g-t v3 06/14] scripts/test_list.py: close config file before start processing

Hi Mauro,

Quoted 9 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Reduce the identation level of the code which parses the config file, as this can be done after closing the file.

This is a preparation for the next patch that will offer a different way to pass the configuration.

Quoted 140 lines
---
 scripts/test_list.py | 114 +++++++++++++++++++++----------------------
 1 file changed, 57 insertions(+), 57 deletions(-)
scripts/test_list.py +57 -57
index 565760dc0201..ac77d6523672 100644
@@ -274,71 +274,71 @@ class TestList:
         with open(config_fname, 'r', encoding='utf8') as handle:
             self.config = json.load(handle)
 
-            self.__add_field(None, 0, 0, self.config["fields"])
+        self.__add_field(None, 0, 0, self.config["fields"])
 
-            sublevel_count = [ 0 ] * self.level_count
+        sublevel_count = [ 0 ] * self.level_count
 
-            for field, item in self.props.items():
-                if "sublevel" in item["_properties_"]:
-                    level = item["_properties_"]["level"]
-                    sublevel = item["_properties_"]["sublevel"]
-                    if sublevel > sublevel_count[level - 1]:
-                        sublevel_count[level - 1] = sublevel
+        for field, item in self.props.items():
+            if "sublevel" in item["_properties_"]:
+                level = item["_properties_"]["level"]
+                sublevel = item["_properties_"]["sublevel"]
+                if sublevel > sublevel_count[level - 1]:
+                    sublevel_count[level - 1] = sublevel
 
-                field_lc = field.lower()
-                self.field_list[field_lc] = field
-                field_plural = _plural(field_lc)
-                if field_lc != field_plural:
-                    self.field_list[field_plural] = field
+            field_lc = field.lower()
+            self.field_list[field_lc] = field
+            field_plural = _plural(field_lc)
+            if field_lc != field_plural:
+                self.field_list[field_plural] = field
 
-            if include_plan:
-                self.props["Class"] = {}
-                self.props["Class"]["_properties_"] = {}
-                self.props["Class"]["_properties_"]["level"] = 1
-                self.props["Class"]["_properties_"]["sublevel"] = sublevel_count[0] + 1
+        if include_plan:
+            self.props["Class"] = {}
+            self.props["Class"]["_properties_"] = {}
+            self.props["Class"]["_properties_"]["level"] = 1
+            self.props["Class"]["_properties_"]["sublevel"] = sublevel_count[0] + 1
 
-            # Remove non-multilevel items, as we're only interested on
-            # hierarchical item levels here
-            for field, item in self.props.items():
-                if "sublevel" in item["_properties_"]:
-                    level = item["_properties_"]["level"]
-                    if sublevel_count[level - 1] == 1:
-                        del item["_properties_"]["level"]
-                        del item["_properties_"]["sublevel"]
-            del self.props["_properties_"]
+        # Remove non-multilevel items, as we're only interested on
+        # hierarchical item levels here
+        for field, item in self.props.items():
+            if "sublevel" in item["_properties_"]:
+                level = item["_properties_"]["level"]
+                if sublevel_count[level - 1] == 1:
+                    del item["_properties_"]["level"]
+                    del item["_properties_"]["sublevel"]
+        del self.props["_properties_"]
 
-            has_implemented = False
-            if not self.filenames:
-                self.filenames = []
-                exclude_files = []
-                files = self.config["files"]
-                exclude_file_glob = self.config.get("exclude_files", [])
-                for cfg_file in exclude_file_glob:
-                    cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
-                    for fname in glob.glob(cfg_file):
-                        exclude_files.append(fname)
+        has_implemented = False
+        if not self.filenames:
+            self.filenames = []
+            exclude_files = []
+            files = self.config["files"]
+            exclude_file_glob = self.config.get("exclude_files", [])
+            for cfg_file in exclude_file_glob:
+                cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
+                for fname in glob.glob(cfg_file):
+                    exclude_files.append(fname)
 
-                for cfg_file in files:
-                    cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
-                    for fname in glob.glob(cfg_file):
-                        if fname in exclude_files:
-                            continue
-                        self.filenames.append(fname)
-                        has_implemented = True
-            else:
-                for cfg_file in self.filenames:
-                    if cfg_file:
-                        has_implemented = True
+            for cfg_file in files:
+                cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
+                for fname in glob.glob(cfg_file):
+                    if fname in exclude_files:
+                        continue
+                    self.filenames.append(fname)
+                    has_implemented = True
+        else:
+            for cfg_file in self.filenames:
+                if cfg_file:
+                    has_implemented = True
 
-            has_planned = False
-            if include_plan and "planning_files" in self.config:
-                implemented_class = "Implemented"
-                files = self.config["planning_files"]
-                for cfg_file in files:
-                    cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
-                    for fname in glob.glob(cfg_file):
-                        self.plan_filenames.append(fname)
-                        has_planned = True
+        has_planned = False
+        if include_plan and "planning_files" in self.config:
+            implemented_class = "Implemented"
+            files = self.config["planning_files"]
+            for cfg_file in files:
+                cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
+                for fname in glob.glob(cfg_file):
+                    self.plan_filenames.append(fname)
+                    has_planned = True
 
         planned_class = None
         if has_implemented:
Signature · 1 line
2.40.1
#9 lore raw

PATCH v3 7/14 scripts/test_list.py: don't rely on file name to parse config

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Currently, config_fname should not be empty, as the class init will fail. Make the logic more generic to prepare to optionally pass the configuration dict directly.

---
 scripts/test_list.py | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
scripts/test_list.py +10 -8
index ac77d6523672..465c73c3bdef 100644
@@ -255,7 +255,6 @@ class TestList:
         self.filenames = file_list
         self.plan_filenames = []
         self.props = {}
-        self.config_fname = config_fname
         self.built_testlist = built_testlist
         self.level_count = 0
         self.field_list = {}
@@ -274,6 +273,9 @@ class TestList:
         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)) + "/"
+
         self.__add_field(None, 0, 0, self.config["fields"])
 
         sublevel_count = [ 0 ] * self.level_count
@@ -314,12 +316,12 @@ class TestList:
             files = self.config["files"]
             exclude_file_glob = self.config.get("exclude_files", [])
             for cfg_file in exclude_file_glob:
-                cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
+                cfg_file = cfg_path + cfg_file
                 for fname in glob.glob(cfg_file):
                     exclude_files.append(fname)
 
             for cfg_file in files:
-                cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
+                cfg_file = cfg_path + cfg_file
                 for fname in glob.glob(cfg_file):
                     if fname in exclude_files:
                         continue
@@ -335,7 +337,7 @@ class TestList:
             implemented_class = "Implemented"
             files = self.config["planning_files"]
             for cfg_file in files:
-                cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
+                cfg_file = cfg_path + cfg_file
                 for fname in glob.glob(cfg_file):
                     self.plan_filenames.append(fname)
                     has_planned = True
@@ -363,12 +365,12 @@ class TestList:
                 continue
 
             self.__add_file_documentation(fname, implemented_class, field_re,
-                                          test_tag, subtest_tag)
+                                          test_tag, subtest_tag, config_origin)
 
         if include_plan:
             for fname in self.plan_filenames:
                 self.__add_file_documentation(fname, planned_class, field_re,
-                                              test_tag, subtest_tag)
+                                              test_tag, subtest_tag, config_origin)
 
     #
     # ancillary methods
@@ -1003,7 +1005,7 @@ class TestList:
     #
 
     def __add_file_documentation(self, fname, implemented_class, field_re,
-                                 test_tag, subtest_tag):
+                                 test_tag, subtest_tag, config_origin):
 
         """Adds the contents of test/subtest documentation form a file"""
 
@@ -1215,7 +1217,7 @@ class TestList:
 
                 file_line.rstrip(r"\n")
                 sys.exit(f"{fname}:{file_ln + 1}: Error: unrecognized line. Need to add field at %s?\n\t==> %s" %
-                         (self.config_fname, file_line))
+                         (config_origin, file_line))
 
     def show_subtests(self, sort_field):
 
Signature · 1 line
2.40.1
#10 lore raw

PATCH v3 8/14 scripts/test_list.py: allow passing a config dict directly

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

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

---
 scripts/test_list.py | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)
scripts/test_list.py +25 -7
index 465c73c3bdef..27434a6d7471 100644
@@ -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"])
 
Signature · 1 line
2.40.1
#11 lore raw

PATCH v3 9/14 scripts/igt_doc.py: use field names when create a TestList instance

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Makes the caller more generic by explicitly passing the field name when calling TestList. This allows updating the class and eventually re-ordering fields without the need of changes on igt_doc.py.

---
 scripts/igt_doc.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/igt_doc.py +4 -2
index c02029e03a31..4f4c5c755c44 100755
@@ -48,8 +48,10 @@ parser.add_argument('--files', nargs='+',
 
 parse_args = parser.parse_args()
 
-tests = TestList(parse_args.config, parse_args.include_plan, parse_args.files,
-                 parse_args.built_testlist)
+tests = TestList(config_fname = parse_args.config,
+                 include_plan = parse_args.include_plan,
+                 file_list = parse_args.files,
+                 built_testlist = parse_args.built_testlist)
 
 if parse_args.filter_field:
     for filter_expr in parse_args.filter_field:
Signature · 1 line
2.40.1
#12 lore raw

PATCH v3 10/14 scripts/test_list.py: add a check before deleting properties

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

If the config file doesn't have empty _properties_, the current logic causes an error. Well, if one is passing a dictionary via config_dict, it may end using a simplified dict without any _properties_ on it.

Add an extra check to avoid an error.

---
 scripts/test_list.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/test_list.py +2 -1
index 27434a6d7471..a9b0dffaf8d5 100644
@@ -325,7 +325,8 @@ class TestList:
                 if sublevel_count[level - 1] == 1:
                     del item["_properties_"]["level"]
                     del item["_properties_"]["sublevel"]
-        del self.props["_properties_"]
+        if "_properties_" in self.props:
+            del self.props["_properties_"]
 
         has_implemented = False
         if not self.filenames:
Signature · 1 line
2.40.1
#13 lore raw

PATCH v3 11/14 scripts/test_list.py: filename arguments for print_ methods are optional

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Add a default to those, as the code doesn't need any arguments.

---
 scripts/test_list.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/test_list.py +2 -2
index a9b0dffaf8d5..6b0893a6da95 100644
@@ -616,7 +616,7 @@ class TestList:
     # Output methods
     #
 
-    def print_rest_flat(self, filename):
+    def print_rest_flat(self, filename = None):
 
         """Print tests and subtests ordered by tests"""
 
@@ -728,7 +728,7 @@ class TestList:
                     sheet[row].append('')
         return sheet
 
-    def print_nested_rest(self, filename):
+    def print_nested_rest(self, filename = None):
 
         """Print tests and subtests ordered by tests"""
 
Signature · 1 line
2.40.1
#14 lore raw

PATCH v3 12/14 scripts/test_list.py: skip some internal fields

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

both subtest_line and _summary_ are used internally at the script logic. They shouldn't be part of the output.

---
 scripts/test_list.py | 4 ++++
 1 file changed, 4 insertions(+)
scripts/test_list.py +4 -0
index 6b0893a6da95..8e7ddef2bfb4 100644
@@ -661,6 +661,10 @@ class TestList:
                     continue
                 if field == "arg":
                     continue
+                if field == "_summary_":
+                    continue
+                if field == "subtest_line":
+                    continue
 
                 print(f":{field}: {self.doc[test][field]}")
 
Signature · 1 line
2.40.1
#15 lore raw

PATCH v3 13/14 scripts/test_list.py: add support to return a string instead of print

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Sometimes, we don't want to print a testlist, but instead to return it for post-processing. One such example is to add a Sphinx extension to parse it and place the results on some existing ReST file.

Add support for it.

A side effect is that we don't need to redirect capture anymore to to store the output on a file.

---
 scripts/test_list.py | 79 ++++++++++++++++++++------------------------
 1 file changed, 36 insertions(+), 43 deletions(-)
scripts/test_list.py +36 -43
index 8e7ddef2bfb4..8c45a8f2aaeb 100644
@@ -616,20 +616,13 @@ class TestList:
     # Output methods
     #
 
-    def print_rest_flat(self, filename = None):
+    def print_rest_flat(self, filename = None, return_string = False):
 
         """Print tests and subtests ordered by tests"""
 
-        handler = None
-        if filename:
-            original_stdout = sys.stdout
-            handler = open(filename, "w", encoding='utf8') # pylint: disable=R1732
-            sys.stdout = handler
-
-        print("=" * len(self.title))
-        print(self.title)
-        print("=" * len(self.title))
-        print()
+        out = "=" * len(self.title) + "\n"
+        out += self.title + "\n"
+        out += "=" * len(self.title) + "\n\n"
 
         for test in sorted(self.doc.keys()):
             fname = self.doc[test]["File"]
@@ -651,10 +644,9 @@ class TestList:
             if not subtest_array:
                 continue
 
-            print(len(name) * '=')
-            print(name)
-            print(len(name) * '=')
-            print()
+            out += len(name) * '=' + "\n"
+            out += name + "\n"
+            out += len(name) * '=' + "\n\n"
 
             for field in sorted(self.doc[test].keys()):
                 if field == "subtest":
@@ -666,29 +658,30 @@ class TestList:
                 if field == "subtest_line":
                     continue
 
-                print(f":{field}: {self.doc[test][field]}")
+                out += f":{field}: {self.doc[test][field]}\n"
 
             for subtest in subtest_array:
 
-                print()
-                print(subtest["_summary_"])
-                print(len(subtest["_summary_"]) * '=')
-                print("")
+                out += "\n" + subtest["_summary_"] + "\n"
+                out += len(subtest["_summary_"]) * '=' + "\n\n"
 
                 for field in sorted(subtest.keys()):
                     if field in [ '_summary_', 'arg', 'subtest_line' ]:
                         continue
 
-                    print(f":{field}:", subtest[field])
+                    out += f":{field}:" + subtest[field] + "\n"
 
-                print()
+                out += "\n"
 
-            print()
-            print()
+            out += "\n\n"
 
-        if handler:
-            handler.close()
-            sys.stdout = original_stdout
+        if filename:
+            with open(filename, "w", encoding='utf8') as handle:
+                handle.write(out)
+        elif not return_string:
+            print(out)
+        else:
+            return out
 
     def get_spreadsheet(self):
 
@@ -732,7 +725,7 @@ class TestList:
                     sheet[row].append('')
         return sheet
 
-    def print_nested_rest(self, filename = None):
+    def print_nested_rest(self, filename = None, return_string = False):
 
         """Print tests and subtests ordered by tests"""
 
@@ -742,10 +735,9 @@ class TestList:
             handler = open(filename, "w", encoding='utf8') # pylint: disable=R1732
             sys.stdout = handler
 
-        print("=" * len(self.title))
-        print(self.title)
-        print("=" * len(self.title))
-        print()
+        out = "=" * len(self.title) + "\n"
+        out += self.title + "\n"
+        out += "=" * len(self.title) + "\n\n"
 
         # Identify the sort order for the fields
         fields_order = []
@@ -789,14 +781,11 @@ class TestList:
 
                 title_str = fields_order[i] + ": " + fields[fields_order[i]]
 
-                print(title_str)
-                print(level_markers[marker] * len(title_str))
-                print()
+                out += title_str + "\n"
+                out += level_markers[marker] * len(title_str) + "\n\n"
                 marker += 1
 
-            print()
-            print("``" + subtest + "``")
-            print()
+            out += "\n``" + subtest + "``" + "\n\n"
 
             # print non-hierarchy fields
             for field in fields_order:
@@ -804,7 +793,7 @@ class TestList:
                     continue
 
                 if field in fields:
-                    print(f":{field}: {fields[field]}")
+                    out += f":{field}: {fields[field]}" + "\n"
 
             # Store current values
             for i in range(cur_level, len(fields_order)):
@@ -816,11 +805,15 @@ class TestList:
                 else:
                     old_fields[i] = ''
 
-            print()
+            out += "\n"
 
-        if handler:
-            handler.close()
-            sys.stdout = original_stdout
+        if filename:
+            with open(filename, "w", encoding='utf8') as handle:
+                handle.write(out)
+        elif not return_string:
+            print(out)
+        else:
+            return out
 
     def print_json(self, out_fname):
 
Signature · 1 line
2.40.1
Reviewed-by on v3 13/14
#16 lore raw

Re: [igt-dev] [PATCH i-g-t v3 13/14] scripts/test_list.py: add support to return a string instead of print

Hi Mauro,

Quoted 6 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Sometimes, we don't want to print a testlist, but instead to return it for post-processing. One such example is to add a Sphinx extension to parse it and place the results on some existing ReST file.

Quoted 6 lines

Add support for it.

A side effect is that we don't need to redirect capture anymore to to store the output on a file.

Quoted 163 lines
---
 scripts/test_list.py | 79 ++++++++++++++++++++------------------------
 1 file changed, 36 insertions(+), 43 deletions(-)
scripts/test_list.py +36 -43
index 8e7ddef2bfb4..8c45a8f2aaeb 100644
@@ -616,20 +616,13 @@ class TestList:
     # Output methods
     #
 
-    def print_rest_flat(self, filename = None):
+    def print_rest_flat(self, filename = None, return_string = False):
 
         """Print tests and subtests ordered by tests"""
 
-        handler = None
-        if filename:
-            original_stdout = sys.stdout
-            handler = open(filename, "w", encoding='utf8') # pylint: disable=R1732
-            sys.stdout = handler
-
-        print("=" * len(self.title))
-        print(self.title)
-        print("=" * len(self.title))
-        print()
+        out = "=" * len(self.title) + "\n"
+        out += self.title + "\n"
+        out += "=" * len(self.title) + "\n\n"
 
         for test in sorted(self.doc.keys()):
             fname = self.doc[test]["File"]
@@ -651,10 +644,9 @@ class TestList:
             if not subtest_array:
                 continue
 
-            print(len(name) * '=')
-            print(name)
-            print(len(name) * '=')
-            print()
+            out += len(name) * '=' + "\n"
+            out += name + "\n"
+            out += len(name) * '=' + "\n\n"
 
             for field in sorted(self.doc[test].keys()):
                 if field == "subtest":
@@ -666,29 +658,30 @@ class TestList:
                 if field == "subtest_line":
                     continue
 
-                print(f":{field}: {self.doc[test][field]}")
+                out += f":{field}: {self.doc[test][field]}\n"
 
             for subtest in subtest_array:
 
-                print()
-                print(subtest["_summary_"])
-                print(len(subtest["_summary_"]) * '=')
-                print("")
+                out += "\n" + subtest["_summary_"] + "\n"
+                out += len(subtest["_summary_"]) * '=' + "\n\n"
 
                 for field in sorted(subtest.keys()):
                     if field in [ '_summary_', 'arg', 'subtest_line' ]:
                         continue
 
-                    print(f":{field}:", subtest[field])
+                    out += f":{field}:" + subtest[field] + "\n"
 
-                print()
+                out += "\n"
 
-            print()
-            print()
+            out += "\n\n"
 
-        if handler:
-            handler.close()
-            sys.stdout = original_stdout
+        if filename:
+            with open(filename, "w", encoding='utf8') as handle:
+                handle.write(out)
+        elif not return_string:
+            print(out)
+        else:
+            return out
 
     def get_spreadsheet(self):
 
@@ -732,7 +725,7 @@ class TestList:
                     sheet[row].append('')
         return sheet
 
-    def print_nested_rest(self, filename = None):
+    def print_nested_rest(self, filename = None, return_string = False):
 
         """Print tests and subtests ordered by tests"""
 
@@ -742,10 +735,9 @@ class TestList:
             handler = open(filename, "w", encoding='utf8') # pylint: disable=R1732
             sys.stdout = handler
 
-        print("=" * len(self.title))
-        print(self.title)
-        print("=" * len(self.title))
-        print()
+        out = "=" * len(self.title) + "\n"
+        out += self.title + "\n"
+        out += "=" * len(self.title) + "\n\n"
 
         # Identify the sort order for the fields
         fields_order = []
@@ -789,14 +781,11 @@ class TestList:
 
                 title_str = fields_order[i] + ": " + fields[fields_order[i]]
 
-                print(title_str)
-                print(level_markers[marker] * len(title_str))
-                print()
+                out += title_str + "\n"
+                out += level_markers[marker] * len(title_str) + "\n\n"
                 marker += 1
 
-            print()
-            print("``" + subtest + "``")
-            print()
+            out += "\n``" + subtest + "``" + "\n\n"
 
             # print non-hierarchy fields
             for field in fields_order:
@@ -804,7 +793,7 @@ class TestList:
                     continue
 
                 if field in fields:
-                    print(f":{field}: {fields[field]}")
+                    out += f":{field}: {fields[field]}" + "\n"
 
             # Store current values
             for i in range(cur_level, len(fields_order)):
@@ -816,11 +805,15 @@ class TestList:
                 else:
                     old_fields[i] = ''
 
-            print()
+            out += "\n"
 
-        if handler:
-            handler.close()
-            sys.stdout = original_stdout
+        if filename:
+            with open(filename, "w", encoding='utf8') as handle:
+                handle.write(out)
+        elif not return_string:
+            print(out)
+        else:
+            return out
 
     def print_json(self, out_fname):
 
Signature · 1 line
2.40.1
#17 lore raw

PATCH v3 14/14 scripts/test_list.py: better handle internal fields

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Be more consistent when dealing with internal fields:
- use _foo_ notation for them;
- skip them using a list instead of hardcoding values.

This should help maintaining this file, if we need to add more internal fields.

PS.: I opted to use a list for the internal fields, even checking if an element there takes O(n), as the number of internal fields is very small. We could instead use a set(), which is O(1) at the average case, but, as the number of elements is really small, it won't bring any real benefit.

---
 scripts/test_list.py | 72 ++++++++++++++++++++------------------------
 1 file changed, 33 insertions(+), 39 deletions(-)
scripts/test_list.py +33 -39
index 8c45a8f2aaeb..50724435b7c5 100644
@@ -265,6 +265,8 @@ class TestList:
         self.subtest_separator = subtest_separator
         self.main_name = main_name
 
+        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")
@@ -456,7 +458,7 @@ class TestList:
                 continue
 
             num_vars = summary.count('%')
-            file_ln = self.doc[test]["subtest_line"][subtest]
+            file_ln = self.doc[test]["_subtest_line_"][subtest]
 
             # Handle trivial case: no wildcards
             if num_vars == 0:
@@ -465,7 +467,7 @@ class TestList:
                 subtest_dict["_summary_"] = summary
 
                 for k in sorted(self.doc[test]["subtest"][subtest].keys()):
-                    if k in [ '_summary_', 'arg', 'subtest_line' ]:
+                    if k in self.internal_fields:
                         continue
 
                     if not allow_inherit:
@@ -488,14 +490,14 @@ class TestList:
 
             # Convert subtest arguments into an array
             arg_array = {}
-            arg_ref = self.doc[test]["subtest"][subtest]["arg"]
+            arg_ref = self.doc[test]["subtest"][subtest]["_arg_"]
 
-            for arg_k in self.doc[test]["arg"][arg_ref].keys():
+            for arg_k in self.doc[test]["_arg_"][arg_ref].keys():
                 arg_array[arg_k] = []
                 if int(arg_k) > num_vars:
                     continue
 
-                for arg_el in sorted(self.doc[test]["arg"][arg_ref][arg_k].keys()):
+                for arg_el in sorted(self.doc[test]["_arg_"][arg_ref][arg_k].keys()):
                     arg_array[arg_k].append(arg_el)
 
             size = len(arg_array)
@@ -520,9 +522,9 @@ class TestList:
                     arg_val = arg_array[j][pos[j]]
                     args[j] = arg_val
 
-                    if arg_val in self.doc[test]["arg"][arg_ref][j]:
-                        arg_map[j] = self.doc[test]["arg"][arg_ref][j][arg_val]
-                        if re.match(r"\<.*\>", self.doc[test]["arg"][arg_ref][j][arg_val]):
+                    if arg_val in self.doc[test]["_arg_"][arg_ref][j]:
+                        arg_map[j] = self.doc[test]["_arg_"][arg_ref][j][arg_val]
+                        if re.match(r"\<.*\>", self.doc[test]["_arg_"][arg_ref][j][arg_val]):
                             args[j] = "<" + arg_val + ">"
                     else:
                         arg_map[j] = arg_val
@@ -534,7 +536,7 @@ class TestList:
                 subtest_dict["_summary_"] = arg_summary
 
                 for field in sorted(self.doc[test]["subtest"][subtest].keys()):
-                    if field in [ '_summary_', 'arg', 'subtest_line' ]:
+                    if field in self.internal_fields:
                         continue
 
                     sub_field = self.doc[test]["subtest"][subtest][field]
@@ -587,9 +589,7 @@ class TestList:
                 test_dict[name] = {}
 
                 for field in self.doc[test]:
-                    if field == "subtest":
-                        continue
-                    if field == "arg":
+                    if field in self.internal_fields:
                         continue
 
                     test_dict[name][field] = self.doc[test][field]
@@ -606,7 +606,7 @@ class TestList:
 
                 dic[summary] = {}
                 for field in sorted(subtest.keys()):
-                    if field in [ '_summary_', 'arg', 'subtest_line' ]:
+                    if field in self.internal_fields:
                         continue
                     dic[summary][field] = subtest[field]
 
@@ -651,11 +651,7 @@ class TestList:
             for field in sorted(self.doc[test].keys()):
                 if field == "subtest":
                     continue
-                if field == "arg":
-                    continue
-                if field == "_summary_":
-                    continue
-                if field == "subtest_line":
+                if field in self.internal_fields:
                     continue
 
                 out += f":{field}: {self.doc[test][field]}\n"
@@ -666,7 +662,7 @@ class TestList:
                 out += len(subtest["_summary_"]) * '=' + "\n\n"
 
                 for field in sorted(subtest.keys()):
-                    if field in [ '_summary_', 'arg', 'subtest_line' ]:
+                    if field in self.internal_fields:
                         continue
 
                     out += f":{field}:" + subtest[field] + "\n"
@@ -1081,11 +1077,11 @@ class TestList:
                         handle_section = 'test'
 
                         self.doc[current_test] = {}
-                        self.doc[current_test]["arg"] = {}
+                        self.doc[current_test]["_arg_"] = {}
                         self.doc[current_test]["_summary_"] = match.group(1)
                         self.doc[current_test]["File"] = fname
                         self.doc[current_test]["subtest"] = {}
-                        self.doc[current_test]["subtest_line"] = {}
+                        self.doc[current_test]["_subtest_line_"] = {}
 
                         if implemented_class:
                             self.doc[current_test]["Class"] = implemented_class
@@ -1106,9 +1102,7 @@ class TestList:
                     # subtests inherit properties from the tests
                     self.doc[current_test]["subtest"][current_subtest] = {}
                     for field in self.doc[current_test].keys():
-                        if field == "arg":
-                            continue
-                        if field == "summary":
+                        if field in self.internal_fields:
                             continue
                         if field == "File":
                             continue
@@ -1122,14 +1116,14 @@ class TestList:
 
                     self.doc[current_test]["subtest"][current_subtest]["_summary_"] = match.group(1)
                     self.doc[current_test]["subtest"][current_subtest]["Description"] = ''
-                    self.doc[current_test]["subtest_line"][current_subtest] = file_ln
+                    self.doc[current_test]["_subtest_line_"][current_subtest] = file_ln
 
                     if not arg_ref:
                         arg_ref = arg_number
                         arg_number += 1
-                        self.doc[current_test]["arg"][arg_ref] = {}
+                        self.doc[current_test]["_arg_"][arg_ref] = {}
 
-                    self.doc[current_test]["subtest"][current_subtest]["arg"] = arg_ref
+                    self.doc[current_test]["subtest"][current_subtest]["_arg_"] = arg_ref
 
                     continue
 
@@ -1159,14 +1153,14 @@ class TestList:
                         sys.exit(f"{fname}:{file_ln + 1}: arguments should be defined after one or more subtests, at the same comment")
 
                     cur_arg = int(match.group(1)) - 1
-                    if cur_arg not in self.doc[current_test]["arg"][arg_ref]:
-                        self.doc[current_test]["arg"][arg_ref][cur_arg] = {}
+                    if cur_arg not in self.doc[current_test]["_arg_"][arg_ref]:
+                        self.doc[current_test]["_arg_"][arg_ref][cur_arg] = {}
 
                     cur_arg_element = match.group(2)
 
                     if match.group(2):
                         # Should be used only for numeric values
-                        self.doc[current_test]["arg"][arg_ref][cur_arg][cur_arg_element] = "<" + match.group(2) + ">"
+                        self.doc[current_test]["_arg_"][arg_ref][cur_arg][cur_arg_element] = "<" + match.group(2) + ">"
 
                     continue
 
@@ -1178,7 +1172,7 @@ class TestList:
                             sys.exit(f"{fname}:{file_ln + 1}: arguments should be defined after one or more subtests, at the same comment")
 
                         cur_arg_element = match.group(1)
-                        self.doc[current_test]["arg"][arg_ref][cur_arg][cur_arg_element] = match.group(2)
+                        self.doc[current_test]["_arg_"][arg_ref][cur_arg][cur_arg_element] = match.group(2)
 
                     else:
                         print(f"{fname}:{file_ln + 1}: Warning: invalid argument: @%s: %s" %
@@ -1191,14 +1185,14 @@ class TestList:
                 if match:
                     cur_arg = int(match.group(1)) - 1
 
-                    if cur_arg not in self.doc[current_test]["arg"][arg_ref]:
-                        self.doc[current_test]["arg"][arg_ref][cur_arg] = {}
+                    if cur_arg not in self.doc[current_test]["_arg_"][arg_ref]:
+                        self.doc[current_test]["_arg_"][arg_ref][cur_arg] = {}
 
                     values = match.group(2).replace(" ", "").split(",")
                     for split_val in values:
                         if split_val == "":
                             continue
-                        self.doc[current_test]["arg"][arg_ref][cur_arg][split_val] = split_val
+                        self.doc[current_test]["_arg_"][arg_ref][cur_arg][split_val] = split_val
 
                     continue
 
@@ -1222,13 +1216,13 @@ class TestList:
                     if match:
                         match_val = match.group(1)
 
-                        match = re.match(r'^(\<.*)\>$',self.doc[current_test]["arg"][arg_ref][cur_arg][cur_arg_element])
+                        match = re.match(r'^(\<.*)\>$',self.doc[current_test]["_arg_"][arg_ref][cur_arg][cur_arg_element])
                         if match:
-                            self.doc[current_test]["arg"][arg_ref][cur_arg][cur_arg_element] = match.group(1) + ' ' + match_val + ">"
+                            self.doc[current_test]["_arg_"][arg_ref][cur_arg][cur_arg_element] = match.group(1) + ' ' + match_val + ">"
                         else:
-                            if self.doc[current_test]["arg"][arg_ref][cur_arg][cur_arg_element] != '':
-                                self.doc[current_test]["arg"][arg_ref][cur_arg][cur_arg_element] += ' '
-                            self.doc[current_test]["arg"][arg_ref][cur_arg][cur_arg_element] += match_val
+                            if self.doc[current_test]["_arg_"][arg_ref][cur_arg][cur_arg_element] != '':
+                                self.doc[current_test]["_arg_"][arg_ref][cur_arg][cur_arg_element] += ' '
+                            self.doc[current_test]["_arg_"][arg_ref][cur_arg][cur_arg_element] += match_val
                     continue
 
                 file_line.rstrip(r"\n")
Signature · 1 line
2.40.1
Reviewed-by on v3 14/14
#18 lore raw

Re: [igt-dev] [PATCH i-g-t v3 14/14] scripts/test_list.py: better handle internal fields

Hi Mauro,

Quoted 10 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

Be more consistent when dealing with internal fields:
- use _foo_ notation for them;
- skip them using a list instead of hardcoding values.

This should help maintaining this file, if we need to add more internal fields.

PS.: I opted to use a list for the internal fields, even

- ^^^^^
Either "PS:" or "P.S.:" or just drop this "PS.: "?

With that

Regards,
Kamil

Quoted 233 lines

checking if an element there takes O(n), as the number of internal fields is very small. We could instead use a set(), which is O(1) at the average case, but, as the number of elements is really small, it won't bring any real benefit.

---
 scripts/test_list.py | 72 ++++++++++++++++++++------------------------
 1 file changed, 33 insertions(+), 39 deletions(-)
scripts/test_list.py +33 -39
index 8c45a8f2aaeb..50724435b7c5 100644
@@ -265,6 +265,8 @@ class TestList:
         self.subtest_separator = subtest_separator
         self.main_name = main_name
 
+        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")
@@ -456,7 +458,7 @@ class TestList:
                 continue
 
             num_vars = summary.count('%')
-            file_ln = self.doc[test]["subtest_line"][subtest]
+            file_ln = self.doc[test]["_subtest_line_"][subtest]
 
             # Handle trivial case: no wildcards
             if num_vars == 0:
@@ -465,7 +467,7 @@ class TestList:
                 subtest_dict["_summary_"] = summary
 
                 for k in sorted(self.doc[test]["subtest"][subtest].keys()):
-                    if k in [ '_summary_', 'arg', 'subtest_line' ]:
+                    if k in self.internal_fields:
                         continue
 
                     if not allow_inherit:
@@ -488,14 +490,14 @@ class TestList:
 
             # Convert subtest arguments into an array
             arg_array = {}
-            arg_ref = self.doc[test]["subtest"][subtest]["arg"]
+            arg_ref = self.doc[test]["subtest"][subtest]["_arg_"]
 
-            for arg_k in self.doc[test]["arg"][arg_ref].keys():
+            for arg_k in self.doc[test]["_arg_"][arg_ref].keys():
                 arg_array[arg_k] = []
                 if int(arg_k) > num_vars:
                     continue
 
-                for arg_el in sorted(self.doc[test]["arg"][arg_ref][arg_k].keys()):
+                for arg_el in sorted(self.doc[test]["_arg_"][arg_ref][arg_k].keys()):
                     arg_array[arg_k].append(arg_el)
 
             size = len(arg_array)
@@ -520,9 +522,9 @@ class TestList:
                     arg_val = arg_array[j][pos[j]]
                     args[j] = arg_val
 
-                    if arg_val in self.doc[test]["arg"][arg_ref][j]:
-                        arg_map[j] = self.doc[test]["arg"][arg_ref][j][arg_val]
-                        if re.match(r"\<.*\>", self.doc[test]["arg"][arg_ref][j][arg_val]):
+                    if arg_val in self.doc[test]["_arg_"][arg_ref][j]:
+                        arg_map[j] = self.doc[test]["_arg_"][arg_ref][j][arg_val]
+                        if re.match(r"\<.*\>", self.doc[test]["_arg_"][arg_ref][j][arg_val]):
                             args[j] = "<" + arg_val + ">"
                     else:
                         arg_map[j] = arg_val
@@ -534,7 +536,7 @@ class TestList:
                 subtest_dict["_summary_"] = arg_summary
 
                 for field in sorted(self.doc[test]["subtest"][subtest].keys()):
-                    if field in [ '_summary_', 'arg', 'subtest_line' ]:
+                    if field in self.internal_fields:
                         continue
 
                     sub_field = self.doc[test]["subtest"][subtest][field]
@@ -587,9 +589,7 @@ class TestList:
                 test_dict[name] = {}
 
                 for field in self.doc[test]:
-                    if field == "subtest":
-                        continue
-                    if field == "arg":
+                    if field in self.internal_fields:
                         continue
 
                     test_dict[name][field] = self.doc[test][field]
@@ -606,7 +606,7 @@ class TestList:
 
                 dic[summary] = {}
                 for field in sorted(subtest.keys()):
-                    if field in [ '_summary_', 'arg', 'subtest_line' ]:
+                    if field in self.internal_fields:
                         continue
                     dic[summary][field] = subtest[field]
 
@@ -651,11 +651,7 @@ class TestList:
             for field in sorted(self.doc[test].keys()):
                 if field == "subtest":
                     continue
-                if field == "arg":
-                    continue
-                if field == "_summary_":
-                    continue
-                if field == "subtest_line":
+                if field in self.internal_fields:
                     continue
 
                 out += f":{field}: {self.doc[test][field]}\n"
@@ -666,7 +662,7 @@ class TestList:
                 out += len(subtest["_summary_"]) * '=' + "\n\n"
 
                 for field in sorted(subtest.keys()):
-                    if field in [ '_summary_', 'arg', 'subtest_line' ]:
+                    if field in self.internal_fields:
                         continue
 
                     out += f":{field}:" + subtest[field] + "\n"
@@ -1081,11 +1077,11 @@ class TestList:
                         handle_section = 'test'
 
                         self.doc[current_test] = {}
-                        self.doc[current_test]["arg"] = {}
+                        self.doc[current_test]["_arg_"] = {}
                         self.doc[current_test]["_summary_"] = match.group(1)
                         self.doc[current_test]["File"] = fname
                         self.doc[current_test]["subtest"] = {}
-                        self.doc[current_test]["subtest_line"] = {}
+                        self.doc[current_test]["_subtest_line_"] = {}
 
                         if implemented_class:
                             self.doc[current_test]["Class"] = implemented_class
@@ -1106,9 +1102,7 @@ class TestList:
                     # subtests inherit properties from the tests
                     self.doc[current_test]["subtest"][current_subtest] = {}
                     for field in self.doc[current_test].keys():
-                        if field == "arg":
-                            continue
-                        if field == "summary":
+                        if field in self.internal_fields:
                             continue
                         if field == "File":
                             continue
@@ -1122,14 +1116,14 @@ class TestList:
 
                     self.doc[current_test]["subtest"][current_subtest]["_summary_"] = match.group(1)
                     self.doc[current_test]["subtest"][current_subtest]["Description"] = ''
-                    self.doc[current_test]["subtest_line"][current_subtest] = file_ln
+                    self.doc[current_test]["_subtest_line_"][current_subtest] = file_ln
 
                     if not arg_ref:
                         arg_ref = arg_number
                         arg_number += 1
-                        self.doc[current_test]["arg"][arg_ref] = {}
+                        self.doc[current_test]["_arg_"][arg_ref] = {}
 
-                    self.doc[current_test]["subtest"][current_subtest]["arg"] = arg_ref
+                    self.doc[current_test]["subtest"][current_subtest]["_arg_"] = arg_ref
 
                     continue
 
@@ -1159,14 +1153,14 @@ class TestList:
                         sys.exit(f"{fname}:{file_ln + 1}: arguments should be defined after one or more subtests, at the same comment")
 
                     cur_arg = int(match.group(1)) - 1
-                    if cur_arg not in self.doc[current_test]["arg"][arg_ref]:
-                        self.doc[current_test]["arg"][arg_ref][cur_arg] = {}
+                    if cur_arg not in self.doc[current_test]["_arg_"][arg_ref]:
+                        self.doc[current_test]["_arg_"][arg_ref][cur_arg] = {}
 
                     cur_arg_element = match.group(2)
 
                     if match.group(2):
                         # Should be used only for numeric values
-                        self.doc[current_test]["arg"][arg_ref][cur_arg][cur_arg_element] = "<" + match.group(2) + ">"
+                        self.doc[current_test]["_arg_"][arg_ref][cur_arg][cur_arg_element] = "<" + match.group(2) + ">"
 
                     continue
 
@@ -1178,7 +1172,7 @@ class TestList:
                             sys.exit(f"{fname}:{file_ln + 1}: arguments should be defined after one or more subtests, at the same comment")
 
                         cur_arg_element = match.group(1)
-                        self.doc[current_test]["arg"][arg_ref][cur_arg][cur_arg_element] = match.group(2)
+                        self.doc[current_test]["_arg_"][arg_ref][cur_arg][cur_arg_element] = match.group(2)
 
                     else:
                         print(f"{fname}:{file_ln + 1}: Warning: invalid argument: @%s: %s" %
@@ -1191,14 +1185,14 @@ class TestList:
                 if match:
                     cur_arg = int(match.group(1)) - 1
 
-                    if cur_arg not in self.doc[current_test]["arg"][arg_ref]:
-                        self.doc[current_test]["arg"][arg_ref][cur_arg] = {}
+                    if cur_arg not in self.doc[current_test]["_arg_"][arg_ref]:
+                        self.doc[current_test]["_arg_"][arg_ref][cur_arg] = {}
 
                     values = match.group(2).replace(" ", "").split(",")
                     for split_val in values:
                         if split_val == "":
                             continue
-                        self.doc[current_test]["arg"][arg_ref][cur_arg][split_val] = split_val
+                        self.doc[current_test]["_arg_"][arg_ref][cur_arg][split_val] = split_val
 
                     continue
 
@@ -1222,13 +1216,13 @@ class TestList:
                     if match:
                         match_val = match.group(1)
 
-                        match = re.match(r'^(\<.*)\>$',self.doc[current_test]["arg"][arg_ref][cur_arg][cur_arg_element])
+                        match = re.match(r'^(\<.*)\>$',self.doc[current_test]["_arg_"][arg_ref][cur_arg][cur_arg_element])
                         if match:
-                            self.doc[current_test]["arg"][arg_ref][cur_arg][cur_arg_element] = match.group(1) + ' ' + match_val + ">"
+                            self.doc[current_test]["_arg_"][arg_ref][cur_arg][cur_arg_element] = match.group(1) + ' ' + match_val + ">"
                         else:
-                            if self.doc[current_test]["arg"][arg_ref][cur_arg][cur_arg_element] != '':
-                                self.doc[current_test]["arg"][arg_ref][cur_arg][cur_arg_element] += ' '
-                            self.doc[current_test]["arg"][arg_ref][cur_arg][cur_arg_element] += match_val
+                            if self.doc[current_test]["_arg_"][arg_ref][cur_arg][cur_arg_element] != '':
+                                self.doc[current_test]["_arg_"][arg_ref][cur_arg][cur_arg_element] += ' '
+                            self.doc[current_test]["_arg_"][arg_ref][cur_arg][cur_arg_element] += match_val
                     continue
 
                 file_line.rstrip(r"\n")
Signature · 1 line
2.40.1
#19 lore raw

[igt-dev] ✗ Fi.CI.BUILD: failure for Make test_list.py more generic

In reply to Mauro Carvalho Chehab
== Series Details ==

== Series Details ==

Series: Make test_list.py more generic
URL : https://patchwork.freedesktop.org/series/120655/
State : failure

== Summary ==

IGT patchset build failed on latest successful build
39f5aba75797f2c00a93ff9ee22cafd5526457cf test/i915/gem_create: Skip the test if the PAT index is set on a non MTL device

Installing tools/i915-perf/i915-perf-recorder to /opt/igt/bin
Installing tools/i915-perf/i915-perf-control to /opt/igt/bin
Installing tools/i915-perf/i915-perf-reader to /opt/igt/bin
Installing runner/igt_runner to /opt/igt/bin
Installing runner/igt_resume to /opt/igt/bin
Installing runner/igt_results to /opt/igt/bin
Installing runner/igt_comms_decoder to /opt/igt/bin
Installing assembler/intel-gen4asm to /opt/igt/bin
Installing assembler/intel-gen4disasm to /opt/igt/bin
Installing overlay/intel-gpu-overlay to /opt/igt/bin
Installing man/intel_audio_dump.1.gz to /opt/igt/share/man/man1
Installing man/intel_bios_dumper.1.gz to /opt/igt/share/man/man1
Installing man/intel_error_decode.1.gz to /opt/igt/share/man/man1
Installing man/intel_gpu_frequency.1.gz to /opt/igt/share/man/man1
Installing man/intel_gpu_top.1.gz to /opt/igt/share/man/man1
Installing man/intel_gtt.1.gz to /opt/igt/share/man/man1
Installing man/intel_infoframes.1.gz to /opt/igt/share/man/man1
Installing man/intel_lid.1.gz to /opt/igt/share/man/man1
Installing man/intel_panel_fitter.1.gz to /opt/igt/share/man/man1
Installing man/intel_reg.1.gz to /opt/igt/share/man/man1
Installing man/intel_stepping.1.gz to /opt/igt/share/man/man1
Installing man/intel_upload_blit_large.1.gz to /opt/igt/share/man/man1
Installing man/intel_upload_blit_large_gtt.1.gz to /opt/igt/share/man/man1
Installing man/intel_upload_blit_large_map.1.gz to /opt/igt/share/man/man1
Installing man/intel_upload_blit_small.1.gz to /opt/igt/share/man/man1
Installing man/intel_vbt_decode.1.gz to /opt/igt/share/man/man1
Installing /usr/src/igt-gpu-tools/lib/igt_list.h to /opt/igt/include/i915-perf
Installing /usr/src/igt-gpu-tools/lib/intel_chipset.h to /opt/igt/include/i915-perf Installing /usr/src/igt-gpu-tools/lib/i915/perf.h to /opt/igt/include/i915-perf Installing /usr/src/igt-gpu-tools/lib/i915/perf_data.h to /opt/igt/include/i915-perf Installing /usr/src/igt-gpu-tools/lib/i915/perf_data_reader.h to /opt/igt/include/i915-perf Installing /opt/igt/build/lib/i915-perf.pc to /opt/igt/lib/x86_64-linux-gnu/pkgconfig Installing /usr/src/igt-gpu-tools/tests/1080p-left.png to /opt/igt/share/igt-gpu-tools Installing /usr/src/igt-gpu-tools/tests/1080p-right.png to /opt/igt/share/igt-gpu-tools Installing /usr/src/igt-gpu-tools/tests/pass.png to /opt/igt/share/igt-gpu-tools Installing /usr/src/igt-gpu-tools/tests/intel-ci/fast-feedback.testlist to /opt/igt/share/igt-gpu-tools Installing /usr/src/igt-gpu-tools/tests/intel-ci/meta.testlist to /opt/igt/share/igt-gpu-tools Installing /usr/src/igt-gpu-tools/tests/intel-ci/README to /opt/igt/share/igt-gpu-tools Installing /usr/src/igt-gpu-tools/tests/intel-ci/blacklist.txt to /opt/igt/share/igt-gpu-tools Installing /usr/src/igt-gpu-tools/tests/intel-ci/blacklist-pre-merge.txt to /opt/igt/share/igt-gpu-tools Installing /usr/src/igt-gpu-tools/tests/intel-ci/xe-fast-feedback.testlist to /opt/igt/share/igt-gpu-tools Installing /usr/src/igt-gpu-tools/tests/intel-ci/xe.blocklist.txt to /opt/igt/share/igt-gpu-tools Installing /usr/src/igt-gpu-tools/tools/intel_gpu_abrt to /opt/igt/bin
Installing /usr/src/igt-gpu-tools/tools/intel-gfx-fw-info to /opt/igt/bin
Installing /opt/igt/build/assembler/intel-gen4asm.pc to /opt/igt/lib/x86_64-linux-gnu/pkgconfig Installing /usr/src/igt-gpu-tools/scripts/code_cov_capture to /opt/igt/bin
Installing /usr/src/igt-gpu-tools/scripts/code_cov_gather_on_build to /opt/igt/bin Installing /usr/src/igt-gpu-tools/scripts/code_cov_gather_on_test to /opt/igt/bin Installing /usr/src/igt-gpu-tools/scripts/code_cov_gen_report to /opt/igt/bin
Installing /usr/src/igt-gpu-tools/scripts/code_cov_parse_info to /opt/igt/bin

#20 lore raw

[igt-dev] ✗ Fi.CI.BUILD: failure for Make test_list.py more generic (rev2)

In reply to Mauro Carvalho Chehab
== Series Details ==

== Series Details ==

Series: Make test_list.py more generic (rev2)
URL : https://patchwork.freedesktop.org/series/120655/
State : failure

== Summary ==

IGT patchset build failed on latest successful build 6f68af5bc4c508fee58b7eb8eae61c7463b521a3 tests/gem_ccs: Avoid writing png twice

Tail of build.log:
[1578/1614] Linking target tools/msm_dp_compliance.
[1579/1614] Linking target runner/testdata/no-subtests.
[1580/1614] Linking target runner/testdata/dynamic.
[1581/1614] Linking target runner/igt_resume.
[1582/1614] Linking target runner/igt_results.
[1583/1614] Linking target runner/testdata/abort-fixture.
[1584/1614] Linking target runner/testdata/skippers.
[1585/1614] Linking target runner/runner_json_test.
[1586/1614] Linking target runner/testdata/abort-simple.
[1587/1614] Linking target runner/testdata/abort-dynamic.
[1588/1614] Linking target runner/igt_runner.
[1589/1614] Linking target runner/igt_comms_decoder.
[1590/1614] Linking target runner/testdata/abort.
[1591/1614] Compiling C object 'lib/76b5a35@@i915_perf@sha/meson-generated_.._i915_perf_metrics_acmgt1.c.o'.
[1592/1614] Compiling C object 'runner/527aa9f@@runner_test@exe/runner_tests.c.o'.
[1593/1614] Linking target runner/runner_test.
[1594/1614] Compiling C object 'lib/76b5a35@@i915_perf@sha/meson-generated_.._i915_perf_metrics_acmgt2.c.o'.
[1595/1614] Compiling C object 'lib/76b5a35@@i915_perf@sha/meson-generated_.._i915_perf_metrics_acmgt3.c.o'.
[1596/1614] Linking target lib/libi915_perf.so.1.5.
[1597/1614] Generating symbol file 'lib/76b5a35@@i915_perf@sha/libi915_perf.so.1.5.symbols'.
[1598/1614] Linking target tools/i915-perf/i915-perf-configs.
[1599/1614] Linking target tools/i915-perf/i915-perf-recorder.
[1600/1614] Linking target tools/i915-perf/i915-perf-reader.
[1601/1614] Linking target tests/gem_barrier_race.
[1602/1614] Linking target tests/core_hotunplug.
[1603/1614] Linking target tests/perf.
[1604/1614] Generating core_hotunplug.testlist with a meson_exe.py custom command.
[1605/1614] Generating gem_barrier_race.testlist with a meson_exe.py custom command.
[1606/1614] Generating perf.testlist with a meson_exe.py custom command.
[1607/1614] Generating xe_tests.rst with a custom command.
FAILED: docs/testplan/xe_tests.rst
/usr/src/igt-gpu-tools/scripts/igt_doc.py --config /usr/src/igt-gpu-tools/tests/xe/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --built-testlist /opt/igt/build/tests/intel-ci/intel-ci.testlist Traceback (most recent call last):
File "/usr/src/igt-gpu-tools/scripts/igt_doc.py", line 67, in <module>
tests.check_tests()
File "/usr/src/igt-gpu-tools/scripts/test_list.py", line 966, in check_tests
with open(self.built_testlist, 'r', encoding='utf8') as handle:
FileNotFoundError: [Errno 2] No such file or directory: '/opt/igt/build/tests/intel-ci/intel-ci.testlist'
[1608/1614] Generating kms_tests.rst with a custom command.
[1609/1614] Generating i915_tests.rst with a custom command.
FAILED: docs/testplan/i915_tests.rst
/usr/src/igt-gpu-tools/scripts/igt_doc.py --config /usr/src/igt-gpu-tools/tests/i915/i915_test_config.json --rest docs/testplan/i915_tests.rst --check-testlist --built-testlist /opt/igt/build/tests/intel-ci/intel-ci.testlist Traceback (most recent call last):
File "/usr/src/igt-gpu-tools/scripts/igt_doc.py", line 67, in <module>
tests.check_tests()
File "/usr/src/igt-gpu-tools/scripts/test_list.py", line 966, in check_tests
with open(self.built_testlist, 'r', encoding='utf8') as handle:
FileNotFoundError: [Errno 2] No such file or directory: '/opt/igt/build/tests/intel-ci/intel-ci.testlist'
[1610/1614] Generating intel-ci.testlist with a meson_exe.py custom command.
ninja: build stopped: subcommand failed.