[Intel-xe] [PATCH 2/5] drm/xe: Initial selftests for xe_device
Michal Wajdeczko
michal.wajdeczko at intel.com
Mon Mar 13 08:13:13 UTC 2023
Add few very basic mock and live selftests for the xe_device.
Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
---
.../selftests/live/xe_device_live_selftest.c | 39 ++++++++++++++++++
.../selftests/mock/xe_device_mock_selftest.c | 41 +++++++++++++++++++
drivers/gpu/drm/xe/xe_device.c | 6 +++
3 files changed, 86 insertions(+)
create mode 100644 drivers/gpu/drm/xe/selftests/live/xe_device_live_selftest.c
create mode 100644 drivers/gpu/drm/xe/selftests/mock/xe_device_mock_selftest.c
diff --git a/drivers/gpu/drm/xe/selftests/live/xe_device_live_selftest.c b/drivers/gpu/drm/xe/selftests/live/xe_device_live_selftest.c
new file mode 100644
index 000000000000..05ad2b04528a
--- /dev/null
+++ b/drivers/gpu/drm/xe/selftests/live/xe_device_live_selftest.c
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0 AND MIT
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#include <kunit/test.h>
+
+#include "selftests/xe_selftests.h"
+
+static void test_to_gt(struct kunit *test)
+{
+ struct xe_device *xe = test->priv;
+
+ KUNIT_ASSERT_NOT_NULL(test, to_gt(xe));
+}
+
+static void test_guc_submission_enabled(struct kunit *test)
+{
+ struct xe_device *xe = test->priv;
+
+ KUNIT_EXPECT_TRUE(test, xe_device_guc_submission_enabled(xe));
+}
+
+static struct kunit_case device_live_test_cases[] = {
+ KUNIT_CASE(test_to_gt),
+ KUNIT_CASE(test_guc_submission_enabled),
+ {}
+};
+
+static struct kunit_suite device_live_suite = {
+ .name = "device_live",
+ .test_cases = device_live_test_cases,
+
+ .suite_init = init_xe_live_selftest_suite,
+ .init = init_xe_device_selftest,
+ .exit = exit_xe_device_selftest,
+};
+
+kunit_test_suite(device_live_suite);
diff --git a/drivers/gpu/drm/xe/selftests/mock/xe_device_mock_selftest.c b/drivers/gpu/drm/xe/selftests/mock/xe_device_mock_selftest.c
new file mode 100644
index 000000000000..1da4fbf7abae
--- /dev/null
+++ b/drivers/gpu/drm/xe/selftests/mock/xe_device_mock_selftest.c
@@ -0,0 +1,41 @@
+// 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_device *xe = test->priv;
+
+ KUNIT_ASSERT_NOT_NULL(test, xe);
+ KUNIT_EXPECT_STRNEQ(test, dev_name(xe->drm.dev), "");
+
+ drm_dbg(&xe->drm, "Done!\n");
+}
+
+static void test_to_gt(struct kunit *test)
+{
+ struct xe_device *xe = test->priv;
+
+ KUNIT_ASSERT_NOT_NULL(test, to_gt(xe));
+}
+
+static struct kunit_case device_mock_test_cases[] = {
+ KUNIT_CASE(test_basic),
+ KUNIT_CASE(test_to_gt),
+ {}
+};
+
+static struct kunit_suite device_mock_suite = {
+ .name = "device_mock",
+ .test_cases = device_mock_test_cases,
+
+ .init = init_xe_device_selftest,
+ .exit = exit_xe_device_selftest,
+};
+
+kunit_test_suite(device_mock_suite);
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 1553949d12b6..503f985167fd 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -426,3 +426,9 @@ void xe_device_mem_access_put(struct xe_device *xe)
XE_WARN_ON(xe->mem_access.ref < 0);
}
+
+#if IS_ENABLED(CONFIG_DRM_XE_SELFTESTS_MOCK)
+#include "selftests/mock/xe_device_mock_selftest.c"
+#elif IS_ENABLED(CONFIG_DRM_XE_SELFTESTS_LIVE)
+#include "selftests/live/xe_device_live_selftest.c"
+#endif
--
2.25.1
More information about the Intel-xe
mailing list