Skip to contentSkip to conversation

Make test_list.py more generic

PATCH Superseded Mauro Carvalho Chehab 2 participants 7 messages Jul 11, 2023 Arm/Amlogic Meson SoC support

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

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 class could some day be sent to Linux Kernel upstream, to be used to document tests contained on sources out there.

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

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

PATCH 1/5 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

PATCH 2/5 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

PATCH 4/5 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
#5 lore raw

PATCH 5/5 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
#3 lore raw

PATCH 3/5 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
#6 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/120529/
State : failure

== Summary ==

IGT patchset build failed on latest successful build 8e65f12de2fd52c05dc48fdbcb8cfe86f6de1a75 scripts/test_list.py: fix __filter_subtest() logic

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