Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mauro.chehab@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v3 04/14] scripts/igt_doc.py: pass a single file when checking docs
Date: Thu, 13 Jul 2023 09:50:44 +0200	[thread overview]
Message-ID: <20230713075054.970457-5-mauro.chehab@linux.intel.com> (raw)
In-Reply-To: <20230713075054.970457-1-mauro.chehab@linux.intel.com>

From: Mauro Carvalho Chehab <mchehab@kernel.org>

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.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
 docs/testplan/meson.build |  2 +-
 scripts/igt_doc.py        |  6 +++---
 scripts/test_list.py      | 42 +++++++++++++++++++--------------------
 3 files changed, 25 insertions(+), 25 deletions(-)
 mode change 100755 => 100644 scripts/test_list.py

diff --git a/docs/testplan/meson.build b/docs/testplan/meson.build
index e838f2eb1540..b388a04b20ea 100644
--- a/docs/testplan/meson.build
+++ b/docs/testplan/meson.build
@@ -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
diff --git a/scripts/igt_doc.py b/scripts/igt_doc.py
index 38e2bdee4f2a..c02029e03a31 100755
--- a/scripts/igt_doc.py
+++ b/scripts/igt_doc.py
@@ -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:
diff --git a/scripts/test_list.py b/scripts/test_list.py
old mode 100755
new mode 100644
index 330ad95231fa..cfff4153b8d9
--- a/scripts/test_list.py
+++ b/scripts/test_list.py
@@ -246,7 +246,7 @@ class TestList:
     """
 
     def __init__(self, config_fname, include_plan = False, file_list = False,
-                 igt_build_path = None,
+                 built_testlist = None,
                  test_tag = "TEST", subtest_tag = "SUBTESTS?",
                  main_name = "igt", subtest_separator = "@"):
         self.doc = {}
@@ -256,7 +256,7 @@ class TestList:
         self.plan_filenames = []
         self.props = {}
         self.config_fname = config_fname
-        self.igt_build_path = igt_build_path
+        self.built_testlist = built_testlist
         self.level_count = 0
         self.field_list = {}
         self.title = None
@@ -852,7 +852,7 @@ class TestList:
             fname = self.doc[test]["File"]
 
             test_name = re.sub(r'.*/', '', fname)
-            test_name = re.sub(r'\.[ch]', '', test_name)
+            test_name = re.sub(r'\.[ch]\s*', '', test_name)
             test_name = self.main_name + test_name
 
             subtest_array += self.expand_subtest(fname, test_name, test, True)
@@ -918,29 +918,15 @@ class TestList:
 
         return subtests
 
-    def get_testlist(self):
-
-        """ Return a list of tests as reported by --list-subtests """
-        tests = []
-        for name in self.filenames:
-            fname = re.sub(r"\.c$", ".testlist", name.split('/')[-1])
-            fname = os.path.join(self.igt_build_path, "tests", fname)
-
-            with open(fname, 'r', encoding='utf8') as handle:
-                for line in handle:
-                    tests.append(line.rstrip("\n"))
-
-        return sorted(tests)
-
     #
     # Validation methods
     #
     def check_tests(self):
 
-        """Compare documented subtests with the IGT test list"""
+        """Compare documented subtests with the test list"""
 
-        if not self.igt_build_path:
-            sys.exit("Need the IGT build path")
+        if not self.built_testlist:
+            sys.exit("Need the build path where the exec files are located")
 
         if self.filters:
             print("NOTE: test checks are affected by filters")
@@ -957,7 +943,21 @@ class TestList:
         doc_subtests = list(sorted(doc_subtests))
 
         # Get a list of tests from
-        run_subtests = self.get_testlist()
+        tests = set()
+        for name in self.filenames:
+            test = self.main_name + re.sub(r"\.c$", "", name.split('/')[-1])
+            tests.add(test)
+
+        run_subtests = []
+        with open(self.built_testlist, 'r', encoding='utf8') as handle:
+            for line in handle:
+                name = line.rstrip("\n")
+                if name in tests:
+                    run_subtests.append(name)
+                else:
+                    result = name.rsplit(self.subtest_separator, 1)[0]
+                    if name in tests:
+                        run_subtests.append(name)
 
         # Compare arrays
 
-- 
2.40.1

  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 ` [igt-dev] [PATCH i-g-t v3 02/14] scripts/test_list.py: make the class more generic Mauro Carvalho Chehab
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 ` Mauro Carvalho Chehab [this message]
2023-07-13 12:08   ` [igt-dev] [PATCH i-g-t v3 04/14] scripts/igt_doc.py: pass a single file when checking docs 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-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox