diff mbox series

[RFC,v2,5/8] drm/i915: add live selftests to KUnit

Message ID 7a0221045bcec317cf8353c72f0c26cc62935273.1667486144.git.mchehab@kernel.org (mailing list archive)
State New
Headers show
Series Add KUnit support for i915 driver | expand

Commit Message

Mauro Carvalho Chehab Nov. 3, 2022, 2:51 p.m. UTC
Now that i915 KUnit has PCI support, add live tests as well.

NOTE: currently, some tests are failing when excecuting via
KUnit. I'll do a further investigation to check why, and if
this patch can be safely merged or not.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---

To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH RFC v2 0/8] at: https://lore.kernel.org/all/cover.1667486144.git.mchehab@kernel.org/

 drivers/gpu/drm/i915/selftests/i915_kunit.c | 35 ++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/selftests/i915_kunit.c b/drivers/gpu/drm/i915/selftests/i915_kunit.c
index 430610864f6e..f5281c866d75 100644
--- a/drivers/gpu/drm/i915/selftests/i915_kunit.c
+++ b/drivers/gpu/drm/i915/selftests/i915_kunit.c
@@ -177,6 +177,31 @@  static struct kunit_case i915_mock_tests[] = {
 };
 #undef selftest
 
+/*
+ * Suite 2: live selftests
+ */
+
+/* Declare selftest functions */
+#define selftest(x, __y) int __y(struct drm_i915_private *i915);
+#include "i915_live_selftests.h"
+#undef selftest
+
+/* Create selftest functions */
+#define selftest(__x, __y) 				\
+	static void live_##__x(struct kunit *test) {	\
+		run_pci_test(test, __y);		\
+	}
+#include "i915_live_selftests.h"
+#undef selftest
+
+/* Fill tests array */
+#define selftest(__x, __y) KUNIT_CASE(live_##__x),
+static struct kunit_case i915_live_tests[] = {
+#include "i915_live_selftests.h"
+	{}
+};
+#undef selftest
+
 /*
  * Declare test suites
  */
@@ -187,9 +212,17 @@  static struct kunit_suite i915_test_suites[] = {
 		.test_cases = i915_mock_tests,
 		.init = initialize_i915_selftests,
 	},
+	{
+		.name = "i915 live selftests",
+		.test_cases = i915_live_tests,
+		.init = initialize_i915_selftests,
+		.suite_init = i915_pci_init_suite,
+		.suite_exit = i915_pci_exit_suite,
+	},
 };
 
-kunit_test_suites(i915_test_suites);
+kunit_test_suites(&i915_test_suites[0],
+		  &i915_test_suites[1]);
 
 MODULE_LICENSE("GPL v2");
 MODULE_IMPORT_NS(I915_SELFTEST);