Skip to contentSkip to conversation

Do dome cleanups at IGT doc tools

PATCH In review Mauro Carvalho Chehab 3 participants 11 messages Nov 28, 2023

lore
Share & tools
lore
#0 lore raw

cover Do dome cleanups at IGT doc tools

From: Mauro Carvalho Chehab <[email protected]>

This series is aimed to do some cleanup at documentation testlist scripts, solving some issues pointed by pylint and reorganizing the code.

The first two patches were already reviewed. This series have them at the beginning, untouched.

Mauro Carvalho Chehab (5):
scripts/test_list.py: better expand subtests scripts/test_list.py: don't add a blank description scripts/test_list.py: Fix trivial pylint issues scripts/test_list.py: fix indent at get_subtests() igt_doc.py: move the main code to a main() function

 scripts/igt_doc.py   | 122 +++++++++++++++++++++++--------------------
 scripts/test_list.py |  95 +++++++++++++++++----------------
 2 files changed, 114 insertions(+), 103 deletions(-)
Signature · 1 line
2.42.0
#1 lore raw

PATCH 1/5 scripts/test_list.py: better expand subtests

From: Mauro Carvalho Chehab <[email protected]>

Use a better regex when splitting subtests, as used when reading testlists.

---
 scripts/test_list.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
scripts/test_list.py +5 -3
index 13f788783483..5ff2b18c2dd8 100644
@@ -1010,6 +1010,9 @@ class TestList:
 
         order = None
 
+        if expand:
+            expand = re.compile(expand)
+
         if sort_field:
             if sort_field.lower() not in self.field_list:
                 sys.exit(f"Field '{sort_field}' is not defined")
@@ -1039,8 +1042,7 @@ class TestList:
             if sort_field:
                 if sort_field in subtest:
                     if expand:
-                        test_list = subtest[sort_field].split(expand)
-                        test_list = [s.strip() for s in test_list]
+                        test_list = expand.split(subtest[sort_field])
 
                         for test_elem in test_list:
                             if test_elem not in subtests:
@@ -1407,7 +1409,7 @@ class TestList:
 
 
         # NOTE: currently, it uses a comma for multi-value delimitter
-        test_subtests = self.get_subtests(sort_field, ",", with_order = True)
+        test_subtests = self.get_subtests(sort_field, ",\s*", with_order = True)
 
         if not os.path.exists(directory):
             os.makedirs(directory)
Signature · 1 line
2.42.0
#2 lore raw

PATCH 2/5 scripts/test_list.py: don't add a blank description

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

At the first versions, it was assumed that a Description field would always exist. This is not true anymore.

Stop artificially creating one with an empty value by default.

---
 scripts/test_list.py | 1 -
 1 file changed, 1 deletion(-)
scripts/test_list.py +0 -1
index 5ff2b18c2dd8..20377b708f83 100644
@@ -1270,7 +1270,6 @@ class TestList:
                         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]["Description"] = ''
                     self.doc[current_test]["_subtest_line_"][current_subtest] = file_ln
 
                     if not arg_ref:
Signature · 1 line
2.42.0
#3 lore raw

Re: [igt-dev] [PATCH i-g-t 2/5] scripts/test_list.py: don't add a blank description

Hi Mauro,

Quoted 8 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

At the first versions, it was assumed that a Description field would always exist. This is not true anymore.

Stop artificially creating one with an empty value by default.

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

Quoted 2 lines

- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Duplicate signature, please leave only one.

Regards,
Kamil

Quoted 19 lines
---
 scripts/test_list.py | 1 -
 1 file changed, 1 deletion(-)
scripts/test_list.py +0 -1
index 5ff2b18c2dd8..20377b708f83 100644
@@ -1270,7 +1270,6 @@ class TestList:
                         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]["Description"] = ''
                     self.doc[current_test]["_subtest_line_"][current_subtest] = file_ln
 
                     if not arg_ref:
Signature · 1 line
2.42.0
#4 lore raw

PATCH 3/5 scripts/test_list.py: Fix trivial pylint issues

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

There are a couple of small issues pointed by pylint. Address them.

---
 scripts/test_list.py | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)
scripts/test_list.py +19 -17
index 20377b708f83..79b48813171b 100644
@@ -14,7 +14,6 @@ import glob
 import json
 import os
 import re
-import subprocess
 import sys
 
 MIN_PYTHON = (3, 6)
@@ -337,7 +336,7 @@ class TestList:
                         for name in value.keys():
                             match_type = update.get("include-type", "subtest-match")
 
-                            self.read_testlist(update, match_type, field, item, testlist, name, cfg_path + value[name])
+                            self.read_testlist(match_type, field, testlist, name, cfg_path + value[name])
 
                     update["include"] = testlist
 
@@ -348,7 +347,7 @@ class TestList:
                         for name in value.keys():
                             match_type = update.get("exclude-type", "subtest-match")
 
-                            self.read_testlist(update, match_type, field, item, testlist, name, cfg_path + value[name])
+                            self.read_testlist(match_type, field, testlist, name, cfg_path + value[name])
 
                     update["exclude"] = testlist
 
@@ -452,7 +451,9 @@ class TestList:
 
             self.__add_field(key, sublevel, hierarchy_level, field[key])
 
-    def read_testlist(self, update, match_type, field, item, testlist, name, filename):
+    def read_testlist(self, match_type, field, testlist, name, filename):
+
+        """ Read a list of tests with a common value from a file"""
 
         match_type_regex = set(["regex", "regex-ignorecase"])
         match_type_str = set(["subtest-match"])
@@ -514,9 +515,12 @@ class TestList:
         return False
 
     def update_testlist_field(self, subtest_dict):
-        expand = re.compile(",\s*")
 
-        for field in self.props.keys():
+        """process include and exclude rules used by test lists read from files"""
+
+        expand = re.compile(r",\s*")
+
+        for field in self.props.keys(): # pylint: disable=C0201,C0206
             if "_properties_" not in self.props[field]:
                 continue
 
@@ -524,7 +528,6 @@ class TestList:
             if not update:
                 continue
 
-            match_type = update.get("type", "subtest-match")
             default_value = update.get("default--if-not-excluded")
             append_value = update.get("append-value-if-not-excluded")
 
@@ -739,7 +742,7 @@ class TestList:
     # Output methods
     #
 
-    def print_rest_flat(self, filename = None, return_string = False):
+    def print_rest_flat(self, filename = None, return_string = False): # pylint: disable=R1710
 
         """Print tests and subtests ordered by tests"""
 
@@ -802,7 +805,7 @@ class TestList:
         else:
             return out
 
-    def get_spreadsheet(self, expand_fields = {}):
+    def get_spreadsheet(self, expand_fields = None):
 
         """
         Return a bidimentional array with the test contents.
@@ -811,6 +814,9 @@ class TestList:
         separate python file that would create a workbook's sheet.
         """
 
+        if not expand_fields:
+            expand_fields = {}
+
         expand_field_name = {}
         sheet = []
         row = 0
@@ -880,13 +886,12 @@ class TestList:
 
         return sheet
 
-    def print_nested_rest(self, filename = None, return_string = False):
+    def print_nested_rest(self, filename = None, return_string = False):  # pylint: disable=R1710
 
         """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
 
@@ -1127,14 +1132,12 @@ class TestList:
         mandatory_fields = set()
         for field, item in self.props.items():
             if item["_properties_"].get("mandatory"):
-                    mandatory_fields.add(field)
+                mandatory_fields.add(field)
 
         doc_subtests = set()
 
         args_regex = re.compile(r'\<[^\>]+\>')
 
-        missing_mandatory_fields = False
-
         subtests = self.expand_dictionary(True)
         for subtest, data in sorted(subtests.items()):
             subtest = self.subtest_separator.join(subtest.split(self.subtest_separator)[:3])
@@ -1143,7 +1146,6 @@ class TestList:
             for field in mandatory_fields:
                 if field not in data:
                     print(f"Warning: {subtest} {field} documentation is missing")
-                    missing_mandatory_fields = True
 
             doc_subtests.add(subtest)
 
@@ -1162,7 +1164,7 @@ class TestList:
         if run_missing:
             for test_name in run_missing:
                 print(f'Warning: Missing documentation for {test_name}')
-            print(f'Please refer: docs/test_documentation.md for more details')
+            print('Please refer: docs/test_documentation.md for more details')
 
         if doc_uneeded or run_missing:
             sys.exit(1)
@@ -1408,7 +1410,7 @@ class TestList:
 
 
         # NOTE: currently, it uses a comma for multi-value delimitter
-        test_subtests = self.get_subtests(sort_field, ",\s*", with_order = True)
+        test_subtests = self.get_subtests(sort_field, r",\s*", with_order = True)
 
         if not os.path.exists(directory):
             os.makedirs(directory)
Signature · 1 line
2.42.0
Reviewed-by on v1 3/5
#5 lore raw

Re: [igt-dev] [PATCH i-g-t 3/5] scripts/test_list.py: Fix trivial pylint issues

Hi Mauro,

Quoted 6 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

There are a couple of small issues pointed by pylint. Address them.

Quoted 156 lines
---
 scripts/test_list.py | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)
scripts/test_list.py +19 -17
index 20377b708f83..79b48813171b 100644
@@ -14,7 +14,6 @@ import glob
 import json
 import os
 import re
-import subprocess
 import sys
 
 MIN_PYTHON = (3, 6)
@@ -337,7 +336,7 @@ class TestList:
                         for name in value.keys():
                             match_type = update.get("include-type", "subtest-match")
 
-                            self.read_testlist(update, match_type, field, item, testlist, name, cfg_path + value[name])
+                            self.read_testlist(match_type, field, testlist, name, cfg_path + value[name])
 
                     update["include"] = testlist
 
@@ -348,7 +347,7 @@ class TestList:
                         for name in value.keys():
                             match_type = update.get("exclude-type", "subtest-match")
 
-                            self.read_testlist(update, match_type, field, item, testlist, name, cfg_path + value[name])
+                            self.read_testlist(match_type, field, testlist, name, cfg_path + value[name])
 
                     update["exclude"] = testlist
 
@@ -452,7 +451,9 @@ class TestList:
 
             self.__add_field(key, sublevel, hierarchy_level, field[key])
 
-    def read_testlist(self, update, match_type, field, item, testlist, name, filename):
+    def read_testlist(self, match_type, field, testlist, name, filename):
+
+        """ Read a list of tests with a common value from a file"""
 
         match_type_regex = set(["regex", "regex-ignorecase"])
         match_type_str = set(["subtest-match"])
@@ -514,9 +515,12 @@ class TestList:
         return False
 
     def update_testlist_field(self, subtest_dict):
-        expand = re.compile(",\s*")
 
-        for field in self.props.keys():
+        """process include and exclude rules used by test lists read from files"""
+
+        expand = re.compile(r",\s*")
+
+        for field in self.props.keys(): # pylint: disable=C0201,C0206
             if "_properties_" not in self.props[field]:
                 continue
 
@@ -524,7 +528,6 @@ class TestList:
             if not update:
                 continue
 
-            match_type = update.get("type", "subtest-match")
             default_value = update.get("default--if-not-excluded")
             append_value = update.get("append-value-if-not-excluded")
 
@@ -739,7 +742,7 @@ class TestList:
     # Output methods
     #
 
-    def print_rest_flat(self, filename = None, return_string = False):
+    def print_rest_flat(self, filename = None, return_string = False): # pylint: disable=R1710
 
         """Print tests and subtests ordered by tests"""
 
@@ -802,7 +805,7 @@ class TestList:
         else:
             return out
 
-    def get_spreadsheet(self, expand_fields = {}):
+    def get_spreadsheet(self, expand_fields = None):
 
         """
         Return a bidimentional array with the test contents.
@@ -811,6 +814,9 @@ class TestList:
         separate python file that would create a workbook's sheet.
         """
 
+        if not expand_fields:
+            expand_fields = {}
+
         expand_field_name = {}
         sheet = []
         row = 0
@@ -880,13 +886,12 @@ class TestList:
 
         return sheet
 
-    def print_nested_rest(self, filename = None, return_string = False):
+    def print_nested_rest(self, filename = None, return_string = False):  # pylint: disable=R1710
 
         """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
 
@@ -1127,14 +1132,12 @@ class TestList:
         mandatory_fields = set()
         for field, item in self.props.items():
             if item["_properties_"].get("mandatory"):
-                    mandatory_fields.add(field)
+                mandatory_fields.add(field)
 
         doc_subtests = set()
 
         args_regex = re.compile(r'\<[^\>]+\>')
 
-        missing_mandatory_fields = False
-
         subtests = self.expand_dictionary(True)
         for subtest, data in sorted(subtests.items()):
             subtest = self.subtest_separator.join(subtest.split(self.subtest_separator)[:3])
@@ -1143,7 +1146,6 @@ class TestList:
             for field in mandatory_fields:
                 if field not in data:
                     print(f"Warning: {subtest} {field} documentation is missing")
-                    missing_mandatory_fields = True
 
             doc_subtests.add(subtest)
 
@@ -1162,7 +1164,7 @@ class TestList:
         if run_missing:
             for test_name in run_missing:
                 print(f'Warning: Missing documentation for {test_name}')
-            print(f'Please refer: docs/test_documentation.md for more details')
+            print('Please refer: docs/test_documentation.md for more details')
 
         if doc_uneeded or run_missing:
             sys.exit(1)
@@ -1408,7 +1410,7 @@ class TestList:
 
 
         # NOTE: currently, it uses a comma for multi-value delimitter
-        test_subtests = self.get_subtests(sort_field, ",\s*", with_order = True)
+        test_subtests = self.get_subtests(sort_field, r",\s*", with_order = True)
 
         if not os.path.exists(directory):
             os.makedirs(directory)
Signature · 1 line
2.42.0
#6 lore raw

PATCH 4/5 scripts/test_list.py: fix indent at get_subtests()

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

The indent there is wrong, causing this warning:

scripts/test_list.py:1041:46: W0631: Using possibly undefined loop variable 'test' (undefined-loop-variable)

This issue also affects testlist generation, as tests will be missing there.

---
 scripts/test_list.py | 54 ++++++++++++++++++++++----------------------
 1 file changed, 27 insertions(+), 27 deletions(-)
scripts/test_list.py +27 -27
index 79b48813171b..3954e883ada3 100644
@@ -1038,43 +1038,43 @@ 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):
-                continue
+            for subtest in subtest_array:
+                if self.__filter_subtest(self.doc[test], subtest, True):
+                    continue
 
-            if sort_field:
-                if sort_field in subtest:
-                    if expand:
-                        test_list = expand.split(subtest[sort_field])
+                if sort_field:
+                    if sort_field in subtest:
+                        if expand:
+                            test_list = expand.split(subtest[sort_field])
 
-                        for test_elem in test_list:
-                            if test_elem not in subtests:
-                                subtests[test_elem] = []
-                            if order:
-                                subtests[test_elem].append((subtest["_summary_"], test_list))
-                            else:
-                                subtests[test_elem].append(subtest["_summary_"])
+                            for test_elem in test_list:
+                                if test_elem not in subtests:
+                                    subtests[test_elem] = []
+                                if order:
+                                    subtests[test_elem].append((subtest["_summary_"], test_list))
+                                else:
+                                    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]]))
+                                else:
+                                    subtests[subtest[sort_field]].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]]))
-                            else:
-                                subtests[subtest[sort_field]].append(subtest["_summary_"])
+                        if order:
+                            subtests[test_elem].append((subtest["_summary_"], [subtest[sort_field]]))
+                        else:
+                            subtests[""].append(subtest["_summary_"])
+
                 else:
                     if order:
                         subtests[test_elem].append((subtest["_summary_"], [subtest[sort_field]]))
                     else:
                         subtests[""].append(subtest["_summary_"])
 
-            else:
-                if order:
-                    subtests[test_elem].append((subtest["_summary_"], [subtest[sort_field]]))
-                else:
-                    subtests[""].append(subtest["_summary_"])
-
         if order:
             for group, tests in subtests.items():
                 prefix_tests = []
Signature · 1 line
2.42.0
Acked-by on v1 4/5
#7 lore raw

Re: [igt-dev] [PATCH i-g-t 4/5] scripts/test_list.py: fix indent at get_subtests()

Hi Mauro,

Quoted 10 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

The indent there is wrong, causing this warning:

scripts/test_list.py:1041:46: W0631: Using possibly undefined loop variable 'test' (undefined-loop-variable)

This issue also affects testlist generation, as tests will be missing there.

Quoted 82 lines
---
 scripts/test_list.py | 54 ++++++++++++++++++++++----------------------
 1 file changed, 27 insertions(+), 27 deletions(-)
scripts/test_list.py +27 -27
index 79b48813171b..3954e883ada3 100644
@@ -1038,43 +1038,43 @@ 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):
-                continue
+            for subtest in subtest_array:
+                if self.__filter_subtest(self.doc[test], subtest, True):
+                    continue
 
-            if sort_field:
-                if sort_field in subtest:
-                    if expand:
-                        test_list = expand.split(subtest[sort_field])
+                if sort_field:
+                    if sort_field in subtest:
+                        if expand:
+                            test_list = expand.split(subtest[sort_field])
 
-                        for test_elem in test_list:
-                            if test_elem not in subtests:
-                                subtests[test_elem] = []
-                            if order:
-                                subtests[test_elem].append((subtest["_summary_"], test_list))
-                            else:
-                                subtests[test_elem].append(subtest["_summary_"])
+                            for test_elem in test_list:
+                                if test_elem not in subtests:
+                                    subtests[test_elem] = []
+                                if order:
+                                    subtests[test_elem].append((subtest["_summary_"], test_list))
+                                else:
+                                    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]]))
+                                else:
+                                    subtests[subtest[sort_field]].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]]))
-                            else:
-                                subtests[subtest[sort_field]].append(subtest["_summary_"])
+                        if order:
+                            subtests[test_elem].append((subtest["_summary_"], [subtest[sort_field]]))
+                        else:
+                            subtests[""].append(subtest["_summary_"])
+
                 else:
                     if order:
                         subtests[test_elem].append((subtest["_summary_"], [subtest[sort_field]]))
                     else:
                         subtests[""].append(subtest["_summary_"])
 
-            else:
-                if order:
-                    subtests[test_elem].append((subtest["_summary_"], [subtest[sort_field]]))
-                else:
-                    subtests[""].append(subtest["_summary_"])
-
         if order:
             for group, tests in subtests.items():
                 prefix_tests = []
Signature · 1 line
2.42.0
#8 lore raw

PATCH 5/5 igt_doc.py: move the main code to a main() function

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

That avoids having global variables inside the script and makes easier to add IGT-specific classes there.

No functional changes.

---
 scripts/igt_doc.py | 122 ++++++++++++++++++++++++---------------------
 1 file changed, 65 insertions(+), 57 deletions(-)
scripts/igt_doc.py +65 -57
index 86e49970ea28..ab6179366831 100755
@@ -15,69 +15,77 @@ import sys
 
 from test_list import TestList
 
-IGT_BUILD_PATH = 'build'
+def main():
+    """
+    Main logic
+    """
 
-parser = argparse.ArgumentParser(description = "Print formatted kernel documentation to stdout.",
-                                 formatter_class = argparse.ArgumentDefaultsHelpFormatter,
-                                 epilog = 'If no action specified, assume --rest.')
-parser.add_argument("--config", required = True,
-                    help="JSON file describing the test plan template")
-parser.add_argument("--rest",
-                    help="Output documentation from the source files in REST file.")
-parser.add_argument("--per-test", action="store_true",
-                    help="Modifies ReST output to print subtests per test.")
-parser.add_argument("--to-json",
-                    help="Output test documentation in JSON format as TO_JSON file")
-parser.add_argument("--show-subtests", action="store_true",
-                    help="Shows the name of the documented subtests in alphabetical order.")
-parser.add_argument("--sort-field",
-                    help="modify --show-subtests to sort output based on SORT_FIELD value")
-parser.add_argument("--filter-field", nargs='*',
-                    help="filter subtests based on regular expressions given by FILTER_FIELD=~'regex'")
-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.",
-                    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.")
-parser.add_argument('--files', nargs='+',
-                    help="File name(s) to be processed")
+    igt_build_path = 'build'
 
-parse_args = parser.parse_args()
+    parser = argparse.ArgumentParser(description = "Print formatted kernel documentation to stdout.",
+                                    formatter_class = argparse.ArgumentDefaultsHelpFormatter,
+                                    epilog = 'If no action specified, assume --rest.')
+    parser.add_argument("--config", required = True,
+                        help="JSON file describing the test plan template")
+    parser.add_argument("--rest",
+                        help="Output documentation from the source files in REST file.")
+    parser.add_argument("--per-test", action="store_true",
+                        help="Modifies ReST output to print subtests per test.")
+    parser.add_argument("--to-json",
+                        help="Output test documentation in JSON format as TO_JSON file")
+    parser.add_argument("--show-subtests", action="store_true",
+                        help="Shows the name of the documented subtests in alphabetical order.")
+    parser.add_argument("--sort-field",
+                        help="modify --show-subtests to sort output based on SORT_FIELD value")
+    parser.add_argument("--filter-field", nargs='*',
+                        help="filter subtests based on regular expressions given by FILTER_FIELD=~'regex'")
+    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.",
+                        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.")
+    parser.add_argument('--files', nargs='+',
+                        help="File name(s) to be processed")
 
-tests = TestList(config_fname = parse_args.config,
-                 include_plan = parse_args.include_plan,
-                 file_list = parse_args.files,
-                 igt_build_path = parse_args.igt_build_path)
+    parse_args = parser.parse_args()
 
-if parse_args.filter_field:
-    for filter_expr in parse_args.filter_field:
-        tests.add_filter(filter_expr)
+    tests = TestList(config_fname = parse_args.config,
+                        include_plan = parse_args.include_plan,
+                        file_list = parse_args.files,
+                        igt_build_path = parse_args.igt_build_path)
 
-RUN = 0
-if parse_args.show_subtests:
-    RUN = 1
-    tests.show_subtests(parse_args.sort_field)
+    if parse_args.filter_field:
+        for filter_expr in parse_args.filter_field:
+            tests.add_filter(filter_expr)
 
-if parse_args.check_testlist:
-    RUN = 1
-    tests.check_tests()
+    run = False
+    if parse_args.show_subtests:
+        run = True
+        tests.show_subtests(parse_args.sort_field)
 
-if parse_args.gen_testlist:
-    RUN = 1
-    if not parse_args.sort_field:
-        sys.exit("Need a field to split the testlists")
-    tests.gen_testlist(parse_args.gen_testlist, parse_args.sort_field)
+    if parse_args.check_testlist:
+        run = True
+        tests.check_tests()
 
-if parse_args.to_json:
-    RUN = 1
-    tests.print_json(parse_args.to_json)
+    if parse_args.gen_testlist:
+        run = True
+        if not parse_args.sort_field:
+            sys.exit("Need a field to split the testlists")
+        tests.gen_testlist(parse_args.gen_testlist, parse_args.sort_field)
 
-if not RUN or parse_args.rest:
-    if parse_args.per_test:
-        tests.print_rest_flat(parse_args.rest)
-    else:
-        tests.print_nested_rest(parse_args.rest)
+    if parse_args.to_json:
+        run = True
+        tests.print_json(parse_args.to_json)
+
+    if not run or parse_args.rest:
+        if parse_args.per_test:
+            tests.print_rest_flat(parse_args.rest)
+        else:
+            tests.print_nested_rest(parse_args.rest)
+
+if __name__ == '__main__':
+    main()
Signature · 1 line
2.42.0
Reviewed-by on v1 5/5
#9 lore raw

Re: [igt-dev] [PATCH i-g-t 5/5] igt_doc.py: move the main code to a main() function

Hi Mauro,

Quoted 8 lines · Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

That avoids having global variables inside the script and makes easier to add IGT-specific classes there.

No functional changes.

Quoted 146 lines
---
 scripts/igt_doc.py | 122 ++++++++++++++++++++++++---------------------
 1 file changed, 65 insertions(+), 57 deletions(-)
scripts/igt_doc.py +65 -57
index 86e49970ea28..ab6179366831 100755
@@ -15,69 +15,77 @@ import sys
 
 from test_list import TestList
 
-IGT_BUILD_PATH = 'build'
+def main():
+    """
+    Main logic
+    """
 
-parser = argparse.ArgumentParser(description = "Print formatted kernel documentation to stdout.",
-                                 formatter_class = argparse.ArgumentDefaultsHelpFormatter,
-                                 epilog = 'If no action specified, assume --rest.')
-parser.add_argument("--config", required = True,
-                    help="JSON file describing the test plan template")
-parser.add_argument("--rest",
-                    help="Output documentation from the source files in REST file.")
-parser.add_argument("--per-test", action="store_true",
-                    help="Modifies ReST output to print subtests per test.")
-parser.add_argument("--to-json",
-                    help="Output test documentation in JSON format as TO_JSON file")
-parser.add_argument("--show-subtests", action="store_true",
-                    help="Shows the name of the documented subtests in alphabetical order.")
-parser.add_argument("--sort-field",
-                    help="modify --show-subtests to sort output based on SORT_FIELD value")
-parser.add_argument("--filter-field", nargs='*',
-                    help="filter subtests based on regular expressions given by FILTER_FIELD=~'regex'")
-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.",
-                    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.")
-parser.add_argument('--files', nargs='+',
-                    help="File name(s) to be processed")
+    igt_build_path = 'build'
 
-parse_args = parser.parse_args()
+    parser = argparse.ArgumentParser(description = "Print formatted kernel documentation to stdout.",
+                                    formatter_class = argparse.ArgumentDefaultsHelpFormatter,
+                                    epilog = 'If no action specified, assume --rest.')
+    parser.add_argument("--config", required = True,
+                        help="JSON file describing the test plan template")
+    parser.add_argument("--rest",
+                        help="Output documentation from the source files in REST file.")
+    parser.add_argument("--per-test", action="store_true",
+                        help="Modifies ReST output to print subtests per test.")
+    parser.add_argument("--to-json",
+                        help="Output test documentation in JSON format as TO_JSON file")
+    parser.add_argument("--show-subtests", action="store_true",
+                        help="Shows the name of the documented subtests in alphabetical order.")
+    parser.add_argument("--sort-field",
+                        help="modify --show-subtests to sort output based on SORT_FIELD value")
+    parser.add_argument("--filter-field", nargs='*',
+                        help="filter subtests based on regular expressions given by FILTER_FIELD=~'regex'")
+    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.",
+                        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.")
+    parser.add_argument('--files', nargs='+',
+                        help="File name(s) to be processed")
 
-tests = TestList(config_fname = parse_args.config,
-                 include_plan = parse_args.include_plan,
-                 file_list = parse_args.files,
-                 igt_build_path = parse_args.igt_build_path)
+    parse_args = parser.parse_args()
 
-if parse_args.filter_field:
-    for filter_expr in parse_args.filter_field:
-        tests.add_filter(filter_expr)
+    tests = TestList(config_fname = parse_args.config,
+                        include_plan = parse_args.include_plan,
+                        file_list = parse_args.files,
+                        igt_build_path = parse_args.igt_build_path)
 
-RUN = 0
-if parse_args.show_subtests:
-    RUN = 1
-    tests.show_subtests(parse_args.sort_field)
+    if parse_args.filter_field:
+        for filter_expr in parse_args.filter_field:
+            tests.add_filter(filter_expr)
 
-if parse_args.check_testlist:
-    RUN = 1
-    tests.check_tests()
+    run = False
+    if parse_args.show_subtests:
+        run = True
+        tests.show_subtests(parse_args.sort_field)
 
-if parse_args.gen_testlist:
-    RUN = 1
-    if not parse_args.sort_field:
-        sys.exit("Need a field to split the testlists")
-    tests.gen_testlist(parse_args.gen_testlist, parse_args.sort_field)
+    if parse_args.check_testlist:
+        run = True
+        tests.check_tests()
 
-if parse_args.to_json:
-    RUN = 1
-    tests.print_json(parse_args.to_json)
+    if parse_args.gen_testlist:
+        run = True
+        if not parse_args.sort_field:
+            sys.exit("Need a field to split the testlists")
+        tests.gen_testlist(parse_args.gen_testlist, parse_args.sort_field)
 
-if not RUN or parse_args.rest:
-    if parse_args.per_test:
-        tests.print_rest_flat(parse_args.rest)
-    else:
-        tests.print_nested_rest(parse_args.rest)
+    if parse_args.to_json:
+        run = True
+        tests.print_json(parse_args.to_json)
+
+    if not run or parse_args.rest:
+        if parse_args.per_test:
+            tests.print_rest_flat(parse_args.rest)
+        else:
+            tests.print_nested_rest(parse_args.rest)
+
+if __name__ == '__main__':
+    main()
Signature · 1 line
2.42.0
#10 lore raw

[igt-dev] ✓ CI.xeBAT: success for Do dome cleanups at IGT doc tools

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

== Series Details ==

Series: Do dome cleanups at IGT doc tools
URL : https://patchwork.freedesktop.org/series/126972/
State : success

== Summary ==

CI Bug Log - changes from XEIGT_7605_BAT -> XEIGTPW_10279_BAT
====================================================

Summary
-------

**SUCCESS**

No regressions found.

Participating hosts (1 -> 4)
------------------------------

Additional (3): bat-pvc-2 bat-dg2-oem2 bat-atsm-2

Known issues
------------

Here are the changes found in XEIGTPW_10279_BAT that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@core_hotunplug@unbind-rebind:
- bat-atsm-2: NOTRUN -> [INCOMPLETE][1] ([Intel XE#764])
[1]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-atsm-2/igt@[email protected]

* igt@kms_addfb_basic@addfb25-x-tiled-legacy:
- bat-pvc-2: NOTRUN -> [SKIP][2] ([i915#6077]) +33 other tests skip
[2]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-pvc-2/igt@[email protected]

* igt@kms_addfb_basic@addfb25-y-tiled-small-legacy:
- bat-dg2-oem2: NOTRUN -> [SKIP][3] ([Intel XE#623])
[3]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-dg2-oem2/igt@[email protected]

* igt@kms_addfb_basic@basic-y-tiled-legacy:
- bat-dg2-oem2: NOTRUN -> [SKIP][4] ([Intel XE#388]) +2 other tests skip
[4]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-dg2-oem2/igt@[email protected]

* igt@kms_addfb_basic@invalid-set-prop-any:
- bat-atsm-2: NOTRUN -> [SKIP][5] ([i915#6077]) +33 other tests skip
[5]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-atsm-2/igt@[email protected]

* igt@kms_cursor_legacy@basic-flip-after-cursor-atomic:
- bat-pvc-2: NOTRUN -> [SKIP][6] ([Intel XE#782]) +5 other tests skip
[6]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-pvc-2/igt@[email protected]

* igt@kms_cursor_legacy@basic-flip-before-cursor-legacy:
- bat-atsm-2: NOTRUN -> [SKIP][7] ([Intel XE#782]) +5 other tests skip
[7]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-atsm-2/igt@[email protected]

* igt@kms_dsc@dsc-basic:
- bat-atsm-2: NOTRUN -> [SKIP][8] ([Intel XE#784])
[8]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-atsm-2/igt@[email protected]
- bat-pvc-2: NOTRUN -> [SKIP][9] ([Intel XE#784])
[9]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-pvc-2/igt@[email protected]
- bat-dg2-oem2: NOTRUN -> [SKIP][10] ([Intel XE#423])
[10]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-dg2-oem2/igt@[email protected]

* igt@kms_flip@basic-flip-vs-dpms:
- bat-pvc-2: NOTRUN -> [SKIP][11] ([Intel XE#947]) +3 other tests skip
[11]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-pvc-2/igt@[email protected]

* igt@kms_flip@basic-flip-vs-modeset:
- bat-atsm-2: NOTRUN -> [SKIP][12] ([Intel XE#947]) +3 other tests skip
[12]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-atsm-2/igt@[email protected]

* igt@kms_force_connector_basic@force-connector-state:
- bat-pvc-2: NOTRUN -> [SKIP][13] ([Intel XE#540]) +3 other tests skip
[13]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-pvc-2/igt@[email protected]
- bat-atsm-2: NOTRUN -> [SKIP][14] ([Intel XE#540]) +3 other tests skip
[14]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-atsm-2/igt@[email protected]

* igt@kms_force_connector_basic@prune-stale-modes:
- bat-dg2-oem2: NOTRUN -> [SKIP][15] ([i915#5274])
[15]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-dg2-oem2/igt@[email protected]

* igt@kms_frontbuffer_tracking@basic:
- bat-pvc-2: NOTRUN -> [SKIP][16] ([Intel XE#783])
[16]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-pvc-2/igt@[email protected]
- bat-dg2-oem2: NOTRUN -> [FAIL][17] ([Intel XE#608])
[17]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-dg2-oem2/igt@[email protected]
- bat-atsm-2: NOTRUN -> [SKIP][18] ([Intel XE#783])
[18]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-atsm-2/igt@[email protected]

* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-nv12:
- bat-dg2-oem2: NOTRUN -> [FAIL][19] ([Intel XE#400] / [Intel XE#616]) +2 other tests fail
[19]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-dg2-oem2/igt@[email protected]

* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-xr24:
- bat-atsm-2: NOTRUN -> [SKIP][20] ([i915#1836]) +6 other tests skip
[20]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-atsm-2/igt@[email protected]

* igt@kms_pipe_crc_basic@nonblocking-crc-frame-sequence:
- bat-pvc-2: NOTRUN -> [SKIP][21] ([Intel XE#829]) +6 other tests skip
[21]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-pvc-2/igt@[email protected]

* igt@kms_prop_blob@basic:
- bat-pvc-2: NOTRUN -> [SKIP][22] ([Intel XE#780])
[22]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-pvc-2/igt@[email protected]
- bat-atsm-2: NOTRUN -> [SKIP][23] ([Intel XE#780])
[23]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-atsm-2/igt@[email protected]

* igt@xe_compute@compute-square:
- bat-atsm-2: NOTRUN -> [SKIP][24] ([Intel XE#672])
[24]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-atsm-2/igt@[email protected]
- bat-dg2-oem2: NOTRUN -> [SKIP][25] ([Intel XE#672])
[25]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-dg2-oem2/igt@[email protected]

* igt@xe_evict@evict-beng-small-external:
- bat-pvc-2: NOTRUN -> [FAIL][26] ([Intel XE#936]) +3 other tests fail
[26]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-pvc-2/igt@[email protected]

* igt@xe_evict@evict-small-cm:
- bat-pvc-2: NOTRUN -> [DMESG-FAIL][27] ([Intel XE#482]) +3 other tests dmesg-fail
[27]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-pvc-2/igt@[email protected]

* igt@xe_exec_fault_mode@many-basic:
- bat-dg2-oem2: NOTRUN -> [SKIP][28] ([Intel XE#288]) +17 other tests skip
[28]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-dg2-oem2/igt@[email protected]

* igt@xe_guc_pc@freq_range_idle:
- bat-pvc-2: NOTRUN -> [SKIP][29] ([Intel XE#533]) +1 other test skip
[29]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-pvc-2/igt@xe_guc_pc@freq_range_idle.html

* igt@xe_huc_copy@huc_copy:
- bat-pvc-2: NOTRUN -> [SKIP][30] ([Intel XE#255])
[30]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-pvc-2/igt@xe_huc_copy@huc_copy.html
- bat-dg2-oem2: NOTRUN -> [SKIP][31] ([Intel XE#255])
[31]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-dg2-oem2/igt@xe_huc_copy@huc_copy.html
- bat-atsm-2: NOTRUN -> [SKIP][32] ([Intel XE#255])
[32]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-atsm-2/igt@xe_huc_copy@huc_copy.html

* igt@xe_intel_bb@render:
- bat-pvc-2: NOTRUN -> [SKIP][33] ([Intel XE#532])
[33]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-pvc-2/igt@[email protected]

* igt@xe_module_load@load:
- bat-pvc-2: NOTRUN -> [SKIP][34] ([Intel XE#378])
[34]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-pvc-2/igt@[email protected]

* igt@xe_pm_residency@gt-c6-on-idle:
- bat-pvc-2: NOTRUN -> [SKIP][35] ([Intel XE#531])
[35]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-pvc-2/igt@[email protected]

#### Possible fixes ####

* igt@kms_flip@basic-flip-vs-wf_vblank:
- bat-adlp-7: [FAIL][36] ([Intel XE#480]) -> [PASS][37] +1 other test pass
[36]: https://intel-gfx-ci.01.org/tree/intel-xe/IGT_7605/bat-adlp-7/igt@kms_flip@basic-flip-vs-wf_vblank.html
[37]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/bat-adlp-7/igt@kms_flip@basic-flip-vs-wf_vblank.html

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[Intel XE#255]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/255
[Intel XE#288]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/288
[Intel XE#378]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/378
[Intel XE#388]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/388
[Intel XE#392]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/392
[Intel XE#400]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/400
[Intel XE#423]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/423
[Intel XE#480]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/480
[Intel XE#482]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/482
[Intel XE#524]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/524
[Intel XE#531]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/531
[Intel XE#532]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/532
[Intel XE#533]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/533
[Intel XE#540]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/540
[Intel XE#608]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/608
[Intel XE#616]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/616
[Intel XE#623]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/623
[Intel XE#672]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/672
[Intel XE#764]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/764
[Intel XE#780]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/780
[Intel XE#782]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/782
[Intel XE#783]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/783
[Intel XE#784]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/784
[Intel XE#829]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/829
[Intel XE#926]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/926
[Intel XE#929]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/929
[Intel XE#936]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/936
[Intel XE#947]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/947
[i915#1836]: https://gitlab.freedesktop.org/drm/intel/issues/1836
[i915#5274]: https://gitlab.freedesktop.org/drm/intel/issues/5274
[i915#6077]: https://gitlab.freedesktop.org/drm/intel/issues/6077

Build changes
-------------

* IGT: IGT_7605 -> IGTPW_10279
* Linux: xe-520-7c4b213b5a33fc591a5c92910292aea30193f96c -> xe-525-417251e59231e74f32b995403a66588e6960da2b

IGTPW_10279: 10279
IGT_7605: 7605
xe-520-7c4b213b5a33fc591a5c92910292aea30193f96c: 7c4b213b5a33fc591a5c92910292aea30193f96c xe-525-417251e59231e74f32b995403a66588e6960da2b: 417251e59231e74f32b995403a66588e6960da2b

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10279/index.html