From: Mauro Carvalho Chehab <mauro.chehab@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v3 02/14] scripts/test_list.py: make the class more generic
Date: Thu, 13 Jul 2023 09:50:42 +0200 [thread overview]
Message-ID: <20230713075054.970457-3-mauro.chehab@linux.intel.com> (raw)
In-Reply-To: <20230713075054.970457-1-mauro.chehab@linux.intel.com>
From: Mauro Carvalho Chehab <mchehab@kernel.org>
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.
Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
scripts/test_list.py | 43 ++++++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 15 deletions(-)
diff --git a/scripts/test_list.py b/scripts/test_list.py
index 4f580fb3de58..3fcf0900c0e5 100755
--- a/scripts/test_list.py
+++ b/scripts/test_list.py
@@ -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)
--
2.40.1
next prev parent reply other threads:[~2023-07-13 7:51 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-13 7:50 [igt-dev] [PATCH i-g-t v3 00/14] Make test_list.py more generic Mauro Carvalho Chehab
2023-07-13 7:50 ` [igt-dev] [PATCH i-g-t v3 01/14] tests/intel-ci/meson.build: Generate and store an intel-ci.testlist Mauro Carvalho Chehab
2023-07-13 7:50 ` Mauro Carvalho Chehab [this message]
2023-07-13 7:50 ` [igt-dev] [PATCH i-g-t v3 03/14] scripts/test_list.py: rename the internal summary value Mauro Carvalho Chehab
2023-07-13 7:50 ` [igt-dev] [PATCH i-g-t v3 04/14] scripts/igt_doc.py: pass a single file when checking docs Mauro Carvalho Chehab
2023-07-13 12:08 ` Kamil Konieczny
2023-07-13 7:50 ` [igt-dev] [PATCH i-g-t v3 05/14] scripts/test_list.py: document what BAT stands for Mauro Carvalho Chehab
2023-07-13 7:50 ` [igt-dev] [PATCH i-g-t v3 06/14] scripts/test_list.py: close config file before start processing Mauro Carvalho Chehab
2023-07-13 10:21 ` Kamil Konieczny
2023-07-13 7:50 ` [igt-dev] [PATCH i-g-t v3 07/14] scripts/test_list.py: don't rely on file name to parse config Mauro Carvalho Chehab
2023-07-13 7:50 ` [igt-dev] [PATCH i-g-t v3 08/14] scripts/test_list.py: allow passing a config dict directly Mauro Carvalho Chehab
2023-07-13 7:50 ` [igt-dev] [PATCH i-g-t v3 09/14] scripts/igt_doc.py: use field names when create a TestList instance Mauro Carvalho Chehab
2023-07-13 7:50 ` [igt-dev] [PATCH i-g-t v3 10/14] scripts/test_list.py: add a check before deleting properties Mauro Carvalho Chehab
2023-07-13 7:50 ` [igt-dev] [PATCH i-g-t v3 11/14] scripts/test_list.py: filename arguments for print_ methods are optional Mauro Carvalho Chehab
2023-07-13 7:50 ` [igt-dev] [PATCH i-g-t v3 12/14] scripts/test_list.py: skip some internal fields Mauro Carvalho Chehab
2023-07-13 7:50 ` [igt-dev] [PATCH i-g-t v3 13/14] scripts/test_list.py: add support to return a string instead of print Mauro Carvalho Chehab
2023-07-13 12:09 ` Kamil Konieczny
2023-07-13 7:50 ` [igt-dev] [PATCH i-g-t v3 14/14] scripts/test_list.py: better handle internal fields Mauro Carvalho Chehab
2023-07-13 12:16 ` Kamil Konieczny
2023-07-13 9:10 ` [igt-dev] ✗ Fi.CI.BUILD: failure for Make test_list.py more generic Patchwork
2023-07-13 12:06 ` [igt-dev] ✗ Fi.CI.BUILD: failure for Make test_list.py more generic (rev2) Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230713075054.970457-3-mauro.chehab@linux.intel.com \
--to=mauro.chehab@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox