[igt-dev] [PATCH i-g-t v2] lib: Update selftests to use dynamic subtests

Chris Wilson chris at chris-wilson.co.uk
Mon Feb 17 12:44:30 UTC 2020


Use the new igt_subtest_with_dynamic to nicely group the dynamic
subtests together.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Petri Latvala <petri.latvala at intel.com>
Cc: Tomi Sarvela <tomi.p.sarvela at intel.com>
Acked-by: Petri Latvala <petri.latvala at intel.com>
Acked-by: Tomi Sarvela <tomi.p.sarvela at intel.com>
---
I shall leave it to Tomi or Petri to handle the timing of the push to
make sure CI remains intact :)
---
 lib/igt_kmod.c            | 23 +++++++++++++++++++----
 tests/igt_command_line.sh |  9 ++-------
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index 05019c24c..e701545d3 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -21,6 +21,7 @@
  * IN THE SOFTWARE.
  */
 
+#include <ctype.h>
 #include <signal.h>
 #include <errno.h>
 
@@ -602,6 +603,18 @@ void igt_kselftest_fini(struct igt_kselftest *tst)
 	kmod_module_unref(tst->kmod);
 }
 
+static const char *unfilter(const char *filter, const char *name)
+{
+	if (!filter)
+		return name;
+
+	name += strlen(filter);
+	if (!isalpha(*name))
+		name++;
+
+	return name;
+}
+
 void igt_kselftests(const char *module_name,
 		    const char *options,
 		    const char *result,
@@ -618,10 +631,12 @@ void igt_kselftests(const char *module_name,
 		igt_require(igt_kselftest_begin(&tst) == 0);
 
 	igt_kselftest_get_tests(tst.kmod, filter, &tests);
-	igt_list_for_each_entry_safe(tl, tn, &tests, link) {
-		igt_subtest_f("%s", tl->name)
-			igt_kselftest_execute(&tst, tl, options, result);
-		free(tl);
+	igt_subtest_with_dynamic(filter ?: "all") {
+		igt_list_for_each_entry_safe(tl, tn, &tests, link) {
+			igt_dynamic_f("%s", unfilter(filter, tl->name))
+				igt_kselftest_execute(&tst, tl, options, result);
+			free(tl);
+		}
 	}
 
 	igt_fixture {
diff --git a/tests/igt_command_line.sh b/tests/igt_command_line.sh
index 291b65268..5356877c7 100755
--- a/tests/igt_command_line.sh
+++ b/tests/igt_command_line.sh
@@ -89,13 +89,8 @@ check_test ()
 	fi
 
 	if [ $RET -eq 0 -a -z "$LIST" ]; then
-		# Subtest enumeration of kernel selftest launchers depends
-		# on the running kernel. If selftests are not enabled,
-		# they will output nothing and exit with 0.
-		if [ "$testname" != "i915_selftest" -a "$testname" != "drm_mm" -a "$testname" != "kms_selftest" -a "$testname" != "dmabuf" ]; then
-			echo "    test does seem to be using igt_main() (should have subtests) and yet --list-subtests is empty!"
-			fail $test
-		fi
+		echo "    test does seem to be using igt_main() (should have subtests) and yet --list-subtests is empty!"
+		fail $test
 	fi
 }
 
-- 
2.25.0



More information about the igt-dev mailing list