Skip to contentSkip to conversation

Make test_list.py more generic

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

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 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.

Mauro Carvalho Chehab (13):
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

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

PATCH v2 1/13 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 | 8 ++++++++
 1 file changed, 8 insertions(+)
tests/intel-ci/meson.build +8 -0
index d5a6e4f47203..a1ec517f8da1 100644
@@ -9,4 +9,12 @@ intelci_files = [
   'xe.blocklist.txt',
 ]
 
+custom_target('intel-ci.testlist',
+              build_by_default : true,
+              command : ['sort', testlist_files],
+              install : true,
+              install_dir : datadir,
+              capture : true,
+              output : 'intel-ci.testlist')
+
 install_data(sources : intelci_files, install_dir : datadir)
Signature · 1 line
2.40.1
#2 lore raw

Re: [igt-dev] [PATCH i-g-t v2 01/13] tests/intel-ci/meson.build: Generate and store an intel-ci.testlist

Hi Mauro,

Quoted 21 lines · Mauro Carvalho Chehab

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 | 8 ++++++++
 1 file changed, 8 insertions(+)
tests/intel-ci/meson.build +0 -0
index d5a6e4f47203..a1ec517f8da1 100644
@@ -9,4 +9,12 @@ intelci_files = [
   'xe.blocklist.txt',
 ]

tests/intel-ci/meson.build intelci_files = [ · line 20

Quoted 10 lines
tests/intel-ci/meson.build +8 -0
 
+custom_target('intel-ci.testlist',
+              build_by_default : true,
+              command : ['sort', testlist_files],
+              install : true,
+              install_dir : datadir,
+              capture : true,
+              output : 'intel-ci.testlist')
+
 install_data(sources : intelci_files, install_dir : datadir)

This looks ok, you can add my r-b, but please fix compilation error (from local run, GitLab report is strange):

[305/310] Generating docs/testplan/xe_tests.rst with a custom command
FAILED: docs/testplan/xe_tests.rst
/home/kamil/ramdisk/tmp-build/scripts/igt_doc.py --config /home/kamil/ramdisk/tmp-build/tests/xe/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --built-testlist /home/kamil/ramdisk/tmp-build/build/tests/intel-ci/intel-ci.testlist Traceback (most recent call last):
File "/home/kamil/ramdisk/tmp-build/scripts/igt_doc.py", line 67, in <module>
tests.check_tests()
File "/home/kamil/ramdisk/tmp-build/scripts/test_list.py", line 970, in check_tests
with open(self.built_testlist, 'r', encoding='utf8') as handle:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/kamil/ramdisk/tmp-build/build/tests/intel-ci/intel-ci.testlist'

Regards,
Kamil

Quoted 3 lines
Signature · 1 line
2.40.1
#3 lore raw

PATCH v2 2/13 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..18fdd619211a 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
#4 lore raw

Re: [igt-dev] [PATCH i-g-t v2 02/13] scripts/test_list.py: make the class more generic

Hi Mauro,

Quoted 130 lines · 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 +22 -12
index 4f580fb3de58..18fdd619211a 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"""
 

scripts/test_list.py class TestList: · line 1020

Quoted 4 lines
scripts/test_list.py +1 -0
@@ -1007,6 +1017,9 @@ class TestList:
         cur_arg_element = 0
         has_test_or_subtest = 0
 
+        test_regex    = re.compile(test_tag    + r':\s*(.*)')

--------------------------------------------- ^^^^ Too many spaces.

With that fixed you can add my r-b.

Regards,
Kamil

Quoted 35 lines
scripts/test_list.py +5 -3
+        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
#5 lore raw

PATCH v2 3/13 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 18fdd619211a..8dca7fc7c49e 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
Reviewed-by on v2 3/13
#6 lore raw

Re: [igt-dev] [PATCH i-g-t v2 03/13] scripts/test_list.py: rename the internal summary value

Hi Mauro,

Quoted 8 lines · 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.

Quoted 141 lines
---
 scripts/test_list.py | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)
scripts/test_list.py +22 -22
index 18fdd619211a..8dca7fc7c49e 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
#7 lore raw

PATCH v2 4/13 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 +++++++++++++++++++-------------------
 tests/intel-ci/meson.build |  2 +-
 4 files changed, 26 insertions(+), 26 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

tests/intel-ci/meson.build +1 -1
index a1ec517f8da1..e984fcb817aa 100644
@@ -9,7 +9,7 @@ intelci_files = [
   'xe.blocklist.txt',
 ]
 
-custom_target('intel-ci.testlist',
+built_testlist = custom_target('intel-ci.testlist',
               build_by_default : true,
               command : ['sort', testlist_files],
               install : true,
Signature · 1 line
2.40.1
#8 lore raw

PATCH v2 5/13 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 1fd27ef560a7..0452be8d7994 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
Reviewed-by on v2 5/13
#9 lore raw

Re: [igt-dev] [PATCH i-g-t v2 05/13] scripts/test_list.py: document what BAT stands for

Hi Mauro,

Quoted 8 lines · 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.

Quoted 20 lines
---
 scripts/test_list.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/test_list.py +1 -1
index 1fd27ef560a7..0452be8d7994 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
#10 lore raw

PATCH v2 6/13 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 0452be8d7994..cfcf6712bdc0 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
#11 lore raw

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

Hi Mauro,

Quoted 4 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.

----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Where it is? Maybe should be dropped?

Quoted 3 lines

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

Could you change description? Now it is a little confusing, you only change indentation but it state:

v2 06/13 scripts/test_list.py: close config file before start processing ------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Maybe something like: change indentation of code

Regards,
Kamil

Quoted 142 lines
---
 scripts/test_list.py | 114 +++++++++++++++++++++----------------------
 1 file changed, 57 insertions(+), 57 deletions(-)
scripts/test_list.py +57 -57
index 0452be8d7994..cfcf6712bdc0 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
#12 lore raw

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

Quoted 14 lines · On Wed, 12 Jul 2023 20:38:59 +0200 Kamil Konieczny…

Hi Mauro,

Quoted 4 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.

----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Where it is? Maybe should be dropped?

Quoted 3 lines

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

Quoted 7 lines

Could you change description? Now it is a little confusing, you only change indentation but it state:

v2 06/13 scripts/test_list.py: close config file before start processing ------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Maybe something like: change indentation of code

I opted to describe the functional change, and not the physical one.

This is something I don't like on python: changing indentation actuall changes the code itself, as it doesn't have explicit block markups like C's { } or Pascal's begin ... end.

What was happening before was equivalent to this (in C code format):

	fp = fopen(...)
	if (!fp) exit();	// implicit, as this is python normal behavior
	{
		fread()
		// do a lot of things (unrelated to fp itself)
	}
	fclose(fp)

After the change, the code is it now:

	fp = fopen(...)
	if (!fp) exit();
	fread()
	fclose(fp)
	// do a lot of things

Yeah, as a side effect, we have one less level of indentation, which is indeed a good thing.

Regards,
Mauro

#13 lore raw

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

Hi Mauro,

Quoted 49 lines · Mauro Carvalho Chehab
Quoted 14 lines · On Wed, 12 Jul 2023 20:38:59 +0200 Kamil Konieczny…

Hi Mauro,

Quoted 4 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.

----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Where it is? Maybe should be dropped?

Quoted 3 lines

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

Quoted 7 lines

Could you change description? Now it is a little confusing, you only change indentation but it state:

v2 06/13 scripts/test_list.py: close config file before start processing ------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Maybe something like: change indentation of code

I opted to describe the functional change, and not the physical one.

This is something I don't like on python: changing indentation actuall changes the code itself, as it doesn't have explicit block markups like C's { } or Pascal's begin ... end.

What was happening before was equivalent to this (in C code format):

	fp = fopen(...)
	if (!fp) exit();	// implicit, as this is python normal behavior
	{
		fread()
		// do a lot of things (unrelated to fp itself)
	}
	fclose(fp)

After the change, the code is it now:

	fp = fopen(...)
	if (!fp) exit();
	fread()
	fclose(fp)
	// do a lot of things
Quoted 5 lines

Yeah, as a side effect, we have one less level of indentation, which is indeed a good thing.

Regards,
Mauro

Thank you for explanation, I missed this in those massive un-indentation.

Regards,
Kamil

#14 lore raw

PATCH v2 7/13 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 cfcf6712bdc0..5da471617268 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
Reviewed-by on v2 7/13
#15 lore raw

Re: [igt-dev] [PATCH i-g-t v2 07/13] scripts/test_list.py: don't rely on file name to parse config

Hi Mauro,

Quoted 7 lines · 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.

Quoted 86 lines
---
 scripts/test_list.py | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
scripts/test_list.py +10 -8
index cfcf6712bdc0..5da471617268 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
#16 lore raw

PATCH v2 8/13 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 5da471617268..9861306bd777 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
Reviewed-by on v2 8/13
#17 lore raw

Re: [igt-dev] [PATCH i-g-t v2 08/13] scripts/test_list.py: allow passing a config dict directly

Hi Mauro,

Quoted 6 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

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

Quoted 64 lines
---
 scripts/test_list.py | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)
scripts/test_list.py +25 -7
index 5da471617268..9861306bd777 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
#18 lore raw

PATCH v2 9/13 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
Reviewed-by on v2 9/13
#19 lore raw

Re: [igt-dev] [PATCH i-g-t v2 09/13] scripts/igt_doc.py: use field names when create a TestList instance

Hi Mauro,

Quoted 8 lines · 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.

Quoted 24 lines
---
 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
#20 lore raw

PATCH v2 10/13 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 9861306bd777..6e3cab206e82 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
Reviewed-by on v2 10/13
#21 lore raw

Re: [igt-dev] [PATCH i-g-t v2 10/13] scripts/test_list.py: add a check before deleting properties

Hi Mauro,

Quoted 10 lines · 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.

Quoted 21 lines
---
 scripts/test_list.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/test_list.py +2 -1
index 9861306bd777..6e3cab206e82 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
#22 lore raw

PATCH v2 11/13 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 6e3cab206e82..1551bc92c010 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
Reviewed-by on v2 11/13
#23 lore raw

Re: [igt-dev] [PATCH i-g-t v2 11/13] scripts/test_list.py: filename arguments for print_ methods are optional

Hi Mauro,

Quoted 5 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

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

Quoted 29 lines
---
 scripts/test_list.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/test_list.py +2 -2
index 6e3cab206e82..1551bc92c010 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
#24 lore raw

PATCH v2 12/13 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 1551bc92c010..11aed63cb67a 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
Reviewed-by on v2 12/13
#25 lore raw

Re: [igt-dev] [PATCH i-g-t v2 12/13] scripts/test_list.py: skip some internal fields

Hi Mauro,

Quoted 15 lines · 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 +0 -0
index 1551bc92c010..11aed63cb67a 100644

scripts/test_list.py class TestList: · line 666

Quoted 6 lines
scripts/test_list.py +3 -0
@@ -661,6 +661,10 @@ class TestList:
                     continue
                 if field == "arg":
                     continue
+                if field == "_summary_":
+                    continue
+                if field == "subtest_line":

Maybe also _subtest_line_?
With or without this,

Quoted 7 lines
scripts/test_list.py +1 -0
+                    continue
 
                 print(f":{field}: {self.doc[test][field]}")
 
Signature · 1 line
2.40.1
#26 lore raw

Re: [igt-dev] [PATCH i-g-t v2 12/13] scripts/test_list.py: skip some internal fields

Quoted 13 lines · On Wed, 12 Jul 2023 21:12:13 +0200 Kamil Konieczny…

Hi Mauro,

Quoted 10 lines · 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(+)
Quoted 13 lines

scripts/test_list.py class TestList: · line 666

Quoted 11 lines
scripts/test_list.py +3 -0
index 1551bc92c010..11aed63cb67a 100644
@@ -661,6 +661,10 @@ class TestList:
                     continue
                 if field == "arg":
                     continue
+                if field == "_summary_":
+                    continue
+                if field == "subtest_line":  

Maybe also _subtest_line_?

Not needed, but maybe I should rename:

	arg -> _arg_
	subtest_line -> _subtest_line_

and use a regex or add those internal fields into a list.

For now, I'll keep it as-is on this patch, but I think on a cleanup patch to handle those internal fields (either on this series or on a new one).

Quoted 11 lines

With or without this,

Quoted 7 lines
scripts/test_list.py +1 -0
+                    continue
 
                 print(f":{field}: {self.doc[test][field]}")
 
Signature · 1 line
2.40.1
#27 lore raw

PATCH v2 13/13 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 11aed63cb67a..402c69e93180 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
#28 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/120622/
State : failure

== Summary ==

IGT patchset build failed on latest successful build 1016723d49ff0ce3326af31468245f7b56930cc4 lib/intel_batchbuffer: Inform about unsupported bpp

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

#29 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/120622/
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

#30 lore raw

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

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

== Series Details ==

Series: Make test_list.py more generic (rev3)
URL : https://patchwork.freedesktop.org/series/120622/
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 runner/testdata/skippers.
[1579/1614] Linking target tools/intel_dp_compliance.
[1580/1614] Linking target tools/intel_l3_parity.
[1581/1614] Linking target tools/amd_hdmi_compliance.
[1582/1614] Linking target runner/igt_resume.
[1583/1614] Linking target runner/testdata/abort-dynamic.
[1584/1614] Linking target runner/testdata/abort-fixture.
[1585/1614] Linking target runner/testdata/dynamic.
[1586/1614] Linking target runner/igt_comms_decoder.
[1587/1614] Linking target runner/igt_runner.
[1588/1614] Linking target runner/igt_results.
[1589/1614] Linking target runner/runner_json_test.
[1590/1614] Compiling C object 'lib/76b5a35@@i915_perf@sha/meson-generated_.._i915_perf_metrics_mtlgt3.c.o'.
[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-reader.
[1600/1614] Linking target tools/i915-perf/i915-perf-recorder.
[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 970, 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 970, 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.