[Intel-xe] [PATCH 3/5] drm/xe: Initial selftests for xe_gt
Michal Wajdeczko
michal.wajdeczko at intel.com
Sun Mar 12 20:35:19 UTC 2023
Add few very basic mock and live selftests for the xe_gt.
Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
---
.../xe/selftests/live/xe_gt_live_selftest.c | 40 +++++++++++++++++++
.../xe/selftests/mock/xe_gt_mock_selftest.c | 40 +++++++++++++++++++
drivers/gpu/drm/xe/xe_gt.c | 6 +++
3 files changed, 86 insertions(+)
create mode 100644 drivers/gpu/drm/xe/selftests/live/xe_gt_live_selftest.c
create mode 100644 drivers/gpu/drm/xe/selftests/mock/xe_gt_mock_selftest.c
diff --git a/drivers/gpu/drm/xe/selftests/live/xe_gt_live_selftest.c b/drivers/gpu/drm/xe/selftests/live/xe_gt_live_selftest.c
new file mode 100644
index 000000000000..d807ec1d1d8c
--- /dev/null
+++ b/drivers/gpu/drm/xe/selftests/live/xe_gt_live_selftest.c
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0 AND MIT
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#include <kunit/test.h>
+
+#include "selftests/xe_selftests.h"
+
+static void test_gt_info(struct kunit *test)
+{
+ struct xe_gt *gt = test->priv;
+
+ KUNIT_EXPECT_NE(test, gt->info.type, XE_GT_TYPE_UNINITIALIZED);
+ KUNIT_EXPECT_EQ(test, gt->info.id, 0u);
+}
+
+static void test_gt_is_not_media_type(struct kunit *test)
+{
+ struct xe_gt *gt = test->priv;
+
+ KUNIT_EXPECT_FALSE(test, xe_gt_is_media_type(gt));
+}
+
+static struct kunit_case gt_live_test_cases[] = {
+ KUNIT_CASE(test_gt_info),
+ KUNIT_CASE(test_gt_is_not_media_type),
+ {}
+};
+
+static struct kunit_suite gt_live_suite = {
+ .name = "gt_live",
+ .test_cases = gt_live_test_cases,
+
+ .suite_init = init_xe_live_selftest_suite,
+ .init = init_xe_gt_selftest,
+ .exit = exit_xe_gt_selftest,
+};
+
+kunit_test_suite(gt_live_suite);
diff --git a/drivers/gpu/drm/xe/selftests/mock/xe_gt_mock_selftest.c b/drivers/gpu/drm/xe/selftests/mock/xe_gt_mock_selftest.c
new file mode 100644
index 000000000000..f208aea3d1a0
--- /dev/null
+++ b/drivers/gpu/drm/xe/selftests/mock/xe_gt_mock_selftest.c
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0 AND MIT
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#include <kunit/test.h>
+
+#include "selftests/xe_selftests.h"
+
+static void test_basic(struct kunit *test)
+{
+ struct xe_gt *gt = test->priv;
+
+ KUNIT_ASSERT_NOT_NULL(test, gt);
+ KUNIT_EXPECT_EQ(test, gt->info.type, XE_GT_TYPE_MAIN);
+ KUNIT_EXPECT_EQ(test, gt->info.id, 0u);
+}
+
+static void test_to_xe(struct kunit *test)
+{
+ struct xe_gt *gt = test->priv;
+
+ KUNIT_ASSERT_NOT_NULL(test, gt->xe);
+}
+
+static struct kunit_case gt_mock_test_cases[] = {
+ KUNIT_CASE(test_basic),
+ KUNIT_CASE(test_to_xe),
+ {}
+};
+
+static struct kunit_suite gt_mock_suite = {
+ .name = "gt_mock",
+ .test_cases = gt_mock_test_cases,
+
+ .init = init_xe_gt_selftest,
+ .exit = exit_xe_gt_selftest,
+};
+
+kunit_test_suite(gt_mock_suite);
diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
index daa433d0f2f5..83861014acfa 100644
--- a/drivers/gpu/drm/xe/xe_gt.c
+++ b/drivers/gpu/drm/xe/xe_gt.c
@@ -852,3 +852,9 @@ struct xe_hw_engine *xe_gt_any_hw_engine_by_reset_domain(struct xe_gt *gt,
return NULL;
}
+
+#if IS_ENABLED(CONFIG_DRM_XE_SELFTESTS_MOCK)
+#include "selftests/mock/xe_gt_mock_selftest.c"
+#elif IS_ENABLED(CONFIG_DRM_XE_SELFTESTS_LIVE)
+#include "selftests/live/xe_gt_live_selftest.c"
+#endif
--
2.25.1
More information about the Intel-xe
mailing list