From: Mauro Carvalho Chehab <mauro.chehab@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 4/6] scripts/igt_doc.py: prepare to place TestList class on a separate file
Date: Tue, 14 Mar 2023 12:41:25 +0100 [thread overview]
Message-ID: <20230314114127.649447-5-mauro.chehab@linux.intel.com> (raw)
In-Reply-To: <20230314114127.649447-1-mauro.chehab@linux.intel.com>
From: Mauro Carvalho Chehab <mchehab@kernel.org>
Do some changes at the code to avoid depending on global vars and
to declare plural ancillary function as static.
Acked-by: Jari Tahvanainen <jari.tahvanainen@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
scripts/igt_doc.py | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/scripts/igt_doc.py b/scripts/igt_doc.py
index efbcee5e74e2..8eed875b0681 100755
--- a/scripts/igt_doc.py
+++ b/scripts/igt_doc.py
@@ -51,7 +51,7 @@ def _sort_using_array(item, array):
# As suggested at https://stackoverflow.com/questions/18902608/generating-the-plural-form-of-a-noun/19018986
#
-def plural(field):
+def _plural(field):
"""
Poor man's conversion to plural.
@@ -232,7 +232,8 @@ class TestList:
Description: test ioctls
"""
- def __init__(self, config_fname, include_plan, file_list):
+ def __init__(self, config_fname, include_plan = False, file_list = False,
+ igt_build_path = None, igt_runner = None):
self.doc = {}
self.test_number = 0
self.config = None
@@ -240,6 +241,8 @@ class TestList:
self.plan_filenames = []
self.props = {}
self.config_fname = config_fname
+ self.igt_build_path = igt_build_path
+ self.igt_runner = igt_runner
self.level_count = 0
self.field_list = {}
self.title = None
@@ -264,7 +267,7 @@ class TestList:
field_lc = field.lower()
self.field_list[field_lc] = field
- field_plural = plural(field_lc)
+ field_plural = _plural(field_lc)
if field_lc != field_plural:
self.field_list[field_plural] = field
@@ -757,6 +760,9 @@ class TestList:
"""Compare documented subtests with the IGT test list"""
+ if not self.igt_build_path or not self.igt_runner:
+ sys.exit("Need the IGT build path and igt_runner executable file name")
+
doc_subtests = sorted(self.get_subtests()[""])
for i in range(0, len(doc_subtests)): # pylint: disable=C0200
@@ -766,9 +772,9 @@ class TestList:
# Get a list of tests from
try:
- result = subprocess.run([ f"{IGT_BUILD_PATH}/{IGT_RUNNER}",
+ result = subprocess.run([ f"{self.igt_build_path}/{self.igt_runner}",
"-L", "-t", test_prefix,
- f"{IGT_BUILD_PATH}/tests"], check = True,
+ f"{self.igt_build_path}/tests"], check = True,
stdout=subprocess.PIPE, universal_newlines=True)
except subprocess.CalledProcessError as sub_err:
print(sub_err.stderr)
@@ -1023,7 +1029,7 @@ class TestList:
"""Show subtests, allowing sort and filter a field """
if sort_field:
- test_subtests = tests.get_subtests(sort_field, filter_field)
+ test_subtests = self.get_subtests(sort_field, filter_field)
for val_key in sorted(test_subtests.keys()):
if not test_subtests[val_key]:
continue
@@ -1034,7 +1040,7 @@ class TestList:
for sub in test_subtests[val_key]:
print (f" {sub}")
else:
- for sub in tests.get_subtests(sort_field, filter_field)[""]:
+ for sub in self.get_subtests(sort_field, filter_field)[""]:
print (sub)
def gen_testlist(self, directory, sort_field, filter_field):
@@ -1101,7 +1107,8 @@ parser.add_argument('--files', nargs='+',
parse_args = parser.parse_args()
-tests = TestList(parse_args.config, parse_args.include_plan, parse_args.files)
+tests = TestList(parse_args.config, parse_args.include_plan, parse_args.files,
+ IGT_BUILD_PATH, IGT_RUNNER)
RUN = 0
if parse_args.show_subtests:
--
2.39.2
next prev parent reply other threads:[~2023-03-14 11:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-14 11:41 [igt-dev] [PATCH i-g-t 0/6] Do some improvements at igt_doc.py Mauro Carvalho Chehab
2023-03-14 11:41 ` [igt-dev] [PATCH i-g-t 1/6] xe_test_config.json: do some adjustments at the output hierarchy Mauro Carvalho Chehab
2023-03-14 11:41 ` [igt-dev] [PATCH i-g-t 2/6] scripts/igt_doc.py: move show_subtests logic to the class Mauro Carvalho Chehab
2023-03-14 11:41 ` [igt-dev] [PATCH i-g-t 3/6] scripts/igt_doc.py: add support to generate testlists Mauro Carvalho Chehab
2023-03-14 11:41 ` Mauro Carvalho Chehab [this message]
2023-03-14 11:41 ` [igt-dev] [PATCH i-g-t 5/6] scripts/test_list.py: prepare to place class on a separate file Mauro Carvalho Chehab
2023-03-14 11:41 ` [igt-dev] [PATCH i-g-t 6/6] scripts/igt_doc.py: re-introduce it by calling test_list.py Mauro Carvalho Chehab
2023-03-14 13:44 ` [igt-dev] ✓ Fi.CI.BAT: success for Do some improvements at igt_doc.py Patchwork
2023-03-15 17:40 ` [igt-dev] ✗ Fi.CI.IGT: failure " 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=20230314114127.649447-5-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.