Skip to contentSkip to conversation

drm/xe: Fix kunit integration due to missing prototypes

PATCH In review Lucas De Marchi 2 participants 2 messages Feb 23, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/xe: Fix kunit integration due to missing prototypes

In order to avoid -Werror=missing-prototypes, add the prototypes in a separate tests/<test-name>_test.h file that is included by both the implementation (tests/xe_<testname>.c, injected in xe.ko) and the kunit module (tests/xe_<testname>_test.c -> xe-<testname>-test.ko).

v2: Add header and don't add ifdef to files that are already not built when not using kunit (Matt Auld)

---
 drivers/gpu/drm/xe/tests/xe_bo.c           |  2 ++
 drivers/gpu/drm/xe/tests/xe_bo_test.c      |  5 ++---
 drivers/gpu/drm/xe/tests/xe_bo_test.h      | 14 ++++++++++++++
 drivers/gpu/drm/xe/tests/xe_dma_buf.c      |  2 ++
 drivers/gpu/drm/xe/tests/xe_dma_buf_test.c |  4 ++--
 drivers/gpu/drm/xe/tests/xe_dma_buf_test.h | 13 +++++++++++++
 drivers/gpu/drm/xe/tests/xe_migrate.c      |  2 ++
 drivers/gpu/drm/xe/tests/xe_migrate_test.c |  4 ++--
 drivers/gpu/drm/xe/tests/xe_migrate_test.h | 13 +++++++++++++
 9 files changed, 52 insertions(+), 7 deletions(-)
 create mode 100644 drivers/gpu/drm/xe/tests/xe_bo_test.h
 create mode 100644 drivers/gpu/drm/xe/tests/xe_dma_buf_test.h
 create mode 100644 drivers/gpu/drm/xe/tests/xe_migrate_test.h
drivers/gpu/drm/xe/tests/xe_bo.c +2 -0
index 87ac21cc8ca9..f03fb907b59a 100644
@@ -5,6 +5,8 @@
 
 #include <kunit/test.h>
 
+#include "tests/xe_bo_test.h"
+
 #include "xe_bo_evict.h"
 #include "xe_pci.h"
 
drivers/gpu/drm/xe/tests/xe_bo_test.c +2 -3
index c8fa29b0b3b2..92dda4fca21b 100644
@@ -3,10 +3,9 @@
  * Copyright © 2022 Intel Corporation
  */
 
-#include <kunit/test.h>
+#include "xe_bo_test.h"
 
-void xe_ccs_migrate_kunit(struct kunit *test);
-void xe_bo_evict_kunit(struct kunit *test);
+#include <kunit/test.h>
 
 static struct kunit_case xe_bo_tests[] = {
 	KUNIT_CASE(xe_ccs_migrate_kunit),
drivers/gpu/drm/xe/tests/xe_bo_test.h new file +14 -0
new file mode 100644
index 000000000000..d751a618c0c8
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 AND MIT */
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#ifndef __XE_BO_TEST_H__
+#define __XE_BO_TEST_H__
+
+struct kunit;
+
+void xe_ccs_migrate_kunit(struct kunit *test);
+void xe_bo_evict_kunit(struct kunit *test);
+
+#endif
drivers/gpu/drm/xe/tests/xe_dma_buf.c +2 -0
index 615d22e3f731..e66a8361ae1f 100644
@@ -5,6 +5,8 @@
 
 #include <kunit/test.h>
 
+#include "tests/xe_dma_buf_test.h"
+
 #include "xe_pci.h"
 
 static bool p2p_enabled(struct dma_buf_test_params *params)
drivers/gpu/drm/xe/tests/xe_dma_buf_test.c +2 -2
index 7bb292da1193..a1adfd1e1605 100644
@@ -3,9 +3,9 @@
  * Copyright © 2022 Intel Corporation
  */
 
-#include <kunit/test.h>
+#include "xe_dma_buf_test.h"
 
-void xe_dma_buf_kunit(struct kunit *test);
+#include <kunit/test.h>
 
 static struct kunit_case xe_dma_buf_tests[] = {
 	KUNIT_CASE(xe_dma_buf_kunit),
drivers/gpu/drm/xe/tests/xe_dma_buf_test.h new file +13 -0
new file mode 100644
index 000000000000..4e9a8bef5751
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 AND MIT */
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#ifndef __XE_DMA_BUF_TEST_H__
+#define __XE_DMA_BUF_TEST_H__
+
+struct kunit;
+
+void xe_dma_buf_kunit(struct kunit *test);
+
+#endif
drivers/gpu/drm/xe/tests/xe_migrate.c +2 -0
index 03a60d5b42f1..0de17e90aba9 100644
@@ -5,6 +5,8 @@
 
 #include <kunit/test.h>
 
+#include "tests/xe_migrate_test.h"
+
 #include "xe_pci.h"
 
 static bool sanity_fence_failed(struct xe_device *xe, struct dma_fence *fence,
drivers/gpu/drm/xe/tests/xe_migrate_test.c +2 -2
index ad779e2bd071..d6be360c3b6d 100644
@@ -3,9 +3,9 @@
  * Copyright © 2022 Intel Corporation
  */
 
-#include <kunit/test.h>
+#include "xe_migrate_test.h"
 
-void xe_migrate_sanity_kunit(struct kunit *test);
+#include <kunit/test.h>
 
 static struct kunit_case xe_migrate_tests[] = {
 	KUNIT_CASE(xe_migrate_sanity_kunit),
drivers/gpu/drm/xe/tests/xe_migrate_test.h new file +13 -0
new file mode 100644
index 000000000000..db1f8ef035bb
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 AND MIT */
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#ifndef __XE_MIGRATE_TEST_H__
+#define __XE_MIGRATE_TEST_H__
+
+struct kunit;
+
+void xe_migrate_sanity_kunit(struct kunit *test);
+
+#endif
Signature · 1 line
2.39.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Lucas De Marchi

In order to avoid -Werror=missing-prototypes, add the prototypes in a separate tests/<test-name>_test.h file that is included by both the implementation (tests/xe_<testname>.c, injected in xe.ko) and the kunit module (tests/xe_<testname>_test.c -> xe-<testname>-test.ko).

v2: Add header and don't add ifdef to files that are already not built when not using kunit (Matt Auld)