From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 05/18] scripts/igt_doc.py: improve --show-subtests logic
Date: Fri, 10 Mar 2023 09:23:13 +0100 [thread overview]
Message-ID: <20230310082326.12088-6-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20230310082326.12088-1-zbigniew.kempczynski@intel.com>
From: Mauro Carvalho Chehab <mchehab@kernel.org>
Add command line parameters to improve --show-subtests:
1) to sort results of --show-subtest based on the contents of a field.
This is useful, for instance, to check if all subtests have
proper values for a given field.
2) to filter for an specific field value. This is interesting to be
able to compare testlists with the expected documented test list.
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
scripts/igt_doc.py | 64 ++++++++++++++++++++++++++++++++++++++++------
1 file changed, 56 insertions(+), 8 deletions(-)
diff --git a/scripts/igt_doc.py b/scripts/igt_doc.py
index 643c7e7a7b..712e22c9d3 100755
--- a/scripts/igt_doc.py
+++ b/scripts/igt_doc.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-# pylint: disable=C0301,R0902,R0914,R0912,R0915
+# pylint: disable=C0301,R0902,R0914,R0912,R0915,R1702,C0302
# SPDX-License-Identifier: (GPL-2.0 OR MIT)
## Copyright (C) 2023 Intel Corporation ##
@@ -689,11 +689,27 @@ class TestList:
# Subtest list methods
#
- def get_subtests(self):
+ def get_subtests(self, sort_field = None, filter_field_expr = None):
"""Return an array with all subtests"""
- subtests = []
+ subtests = {}
+ subtests[""] = []
+
+ if sort_field:
+ if sort_field.lower() not in self.field_list:
+ sys.exit(f"Field '{sort_field}' is not defined")
+ sort_field = self.field_list[sort_field.lower()]
+
+ if filter_field_expr:
+ if not (match := re.match(r"(.*)=~\s*(.*)", filter_field_expr)):
+ sys.exit(f"Filter field {filter_field_expr} is not at <field> =~ <regex> syntax")
+
+ field = match.group(1).strip().lower()
+ if field not in self.field_list:
+ sys.exit(f"Field '{field}' is not defined")
+ filter_field = self.field_list[field]
+ regex = re.compile("{0}".format(match.group(2).strip()), re.I) # pylint: disable=C0209
for test in sorted(self.doc.keys()):
fname = self.doc[test]["File"]
@@ -702,10 +718,26 @@ class TestList:
test_name = re.sub(r'\.[ch]', '', test_name)
test_name = "igt@" + test_name
- subtest_array = self.expand_subtest(fname, test_name, test)
+ subtest_array = self.expand_subtest(fname, test_name, test, True)
for subtest in subtest_array:
- subtests.append(subtest["Summary"])
+ if filter_field_expr:
+ if filter_field not in subtest:
+ continue
+ if not re.match(regex, subtest[filter_field]):
+ continue
+
+ if sort_field:
+ if sort_field in subtest:
+ if subtest[sort_field] not in subtests:
+ subtests[subtest[sort_field]] = []
+
+ subtests[subtest[sort_field]].append(subtest["Summary"])
+ else:
+ subtests[""].append(subtest["Summary"])
+
+ else:
+ subtests[""].append(subtest["Summary"])
return subtests
@@ -716,7 +748,7 @@ class TestList:
"""Compare documented subtests with the IGT test list"""
- doc_subtests = sorted(self.get_subtests())
+ doc_subtests = sorted(self.get_subtests()[""])
for i in range(0, len(doc_subtests)): # pylint: disable=C0200
doc_subtests[i] = re.sub(r'\<[^\>]+\>', r'\\d+', doc_subtests[i])
@@ -990,6 +1022,10 @@ 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",
+ help="modify --show-subtests to filter output based a regex given by FILTER_FIELD=~'regex'")
parser.add_argument("--check-testlist", action="store_true",
help="Compare documentation against IGT runner testlist.")
parser.add_argument("--include-plan", action="store_true",
@@ -1007,8 +1043,20 @@ tests = TestList(parse_args.config, parse_args.include_plan, parse_args.files)
RUN = 0
if parse_args.show_subtests:
RUN = 1
- for sub in tests.get_subtests():
- print (sub)
+ if parse_args.sort_field:
+ test_subtests = tests.get_subtests(parse_args.sort_field, parse_args.filter_field)
+ for val_key in sorted(test_subtests.keys()):
+ if not test_subtests[val_key]:
+ continue
+ if val_key == "":
+ print("not defined:")
+ else:
+ print(f"{val_key}:")
+ for sub in test_subtests[val_key]:
+ print (f" {sub}")
+ else:
+ for sub in tests.get_subtests(parse_args.sort_field, parse_args.filter_field)[""]:
+ print (sub)
if parse_args.check_testlist:
RUN = 1
--
2.34.1
next prev parent reply other threads:[~2023-03-10 8:23 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-10 8:23 [igt-dev] [PATCH i-g-t 00/18] Add igt_doc.py Zbigniew Kempczyński
2023-03-10 8:23 ` [igt-dev] [PATCH i-g-t 01/18] scripts/igt_doc.py: beautify its code Zbigniew Kempczyński
2023-03-10 8:23 ` [igt-dev] [PATCH i-g-t 02/18] scripts/igt_doc.py: add JSON file output Zbigniew Kempczyński
2023-03-10 8:23 ` [igt-dev] [PATCH i-g-t 03/18] scripts/igt_doc.py: dynamically create fields array from a JSON file Zbigniew Kempczyński
2023-03-10 8:23 ` [igt-dev] [PATCH i-g-t 04/18] scripts/igt_doc.py: add support to specify numeric values Zbigniew Kempczyński
2023-03-10 8:23 ` Zbigniew Kempczyński [this message]
2023-03-10 8:23 ` [igt-dev] [PATCH i-g-t 06/18] scripts/igt_doc.py: add error handler for subprocess Zbigniew Kempczyński
2023-03-10 8:23 ` [igt-dev] [PATCH i-g-t 07/18] scripts/igt_doc.py: improve multi-line logic Zbigniew Kempczyński
2023-03-10 8:23 ` [igt-dev] [PATCH i-g-t 08/18] scripts/igt_doc.py: don't use ":=" operator Zbigniew Kempczyński
2023-03-10 8:23 ` [igt-dev] [PATCH i-g-t 09/18] scripts/igt_doc.py: make it compatible with Python 3.6 Zbigniew Kempczyński
2023-03-10 8:23 ` [igt-dev] [PATCH i-g-t 10/18] scripts/igt_doc.py: sets the minimal version to run the script Zbigniew Kempczyński
2023-03-10 8:23 ` [igt-dev] [PATCH i-g-t 11/18] scripts/igt_doc.py: use a different logic to get IGT prefix Zbigniew Kempczyński
2023-03-10 8:23 ` [igt-dev] [PATCH i-g-t 12/18] testplan/meson.build: add targets to build Xe test documentation Zbigniew Kempczyński
2023-03-10 8:23 ` [igt-dev] [PATCH i-g-t 13/18] xe/xe_test_config.json: cleanup the field struct Zbigniew Kempczyński
2023-03-10 8:23 ` [igt-dev] [PATCH i-g-t 14/18] xe/xe_huc_copy: add GPU dependency to its documentation Zbigniew Kempczyński
2023-03-10 8:23 ` [igt-dev] [PATCH i-g-t 15/18] xe/xe_*: add TEST/SUBTEST documentation Zbigniew Kempczyński
2023-03-10 8:23 ` [igt-dev] [PATCH i-g-t 16/18] xe-fast-feedback.testlist: update debugfs tests Zbigniew Kempczyński
2023-03-10 8:23 ` [igt-dev] [PATCH i-g-t 17/18] xe_mmap: skip VRAM tests if no VRAM is found Zbigniew Kempczyński
2023-03-10 10:52 ` Das, Nirmoy
2023-03-13 6:48 ` Zbigniew Kempczyński
2023-03-14 12:26 ` Das, Nirmoy
2023-03-10 8:23 ` [igt-dev] [PATCH i-g-t 18/18] meson: replace "igt@xe/" by "igt@" Zbigniew Kempczyński
2023-03-10 10:23 ` [igt-dev] ✓ Fi.CI.BAT: success for Add igt_doc.py Patchwork
2023-03-13 1:18 ` [igt-dev] ✓ Fi.CI.IGT: " 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=20230310082326.12088-6-zbigniew.kempczynski@intel.com \
--to=zbigniew.kempczynski@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