Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/xe/kunit: Simplify xe_mocs live tests code layout

The test case logic is implemented by the functions compiled as
part of the core Xe driver module and then exported to build and
register the test suite in the live test module.

But we don't need to export individual test case functions, we may
just export the entire test suite. And we don't need to register
this test suite in a separate file, it can be done in the main
file of the live test module.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240708111210.1154-5-michal.wajdeczko@intel.com

+18 -42
+1 -2
drivers/gpu/drm/xe/tests/Makefile
··· 2 2 3 3 # "live" kunit tests 4 4 obj-$(CONFIG_DRM_XE_KUNIT_TEST) += xe_live_test.o 5 - xe_live_test-y = xe_live_test_mod.o \ 6 - xe_mocs_test.o 5 + xe_live_test-y = xe_live_test_mod.o 7 6 8 7 # Normal kunit tests 9 8 obj-$(CONFIG_DRM_XE_KUNIT_TEST) += xe_test.o
+2
drivers/gpu/drm/xe/tests/xe_live_test_mod.c
··· 8 8 extern struct kunit_suite xe_bo_test_suite; 9 9 extern struct kunit_suite xe_dma_buf_test_suite; 10 10 extern struct kunit_suite xe_migrate_test_suite; 11 + extern struct kunit_suite xe_mocs_test_suite; 11 12 12 13 kunit_test_suite(xe_bo_test_suite); 13 14 kunit_test_suite(xe_dma_buf_test_suite); 14 15 kunit_test_suite(xe_migrate_test_suite); 16 + kunit_test_suite(xe_mocs_test_suite); 15 17 16 18 MODULE_AUTHOR("Intel Corporation"); 17 19 MODULE_LICENSE("GPL");
+15 -5
drivers/gpu/drm/xe/tests/xe_mocs.c
··· 6 6 #include <kunit/test.h> 7 7 #include <kunit/visibility.h> 8 8 9 - #include "tests/xe_mocs_test.h" 10 9 #include "tests/xe_pci_test.h" 11 10 #include "tests/xe_test.h" 12 11 ··· 133 134 return 0; 134 135 } 135 136 136 - void xe_live_mocs_kernel_kunit(struct kunit *test) 137 + static void xe_live_mocs_kernel_kunit(struct kunit *test) 137 138 { 138 139 xe_call_for_each_device(mocs_kernel_test_run_device); 139 140 } 140 - EXPORT_SYMBOL_IF_KUNIT(xe_live_mocs_kernel_kunit); 141 141 142 142 static int mocs_reset_test_run_device(struct xe_device *xe) 143 143 { ··· 173 175 return 0; 174 176 } 175 177 176 - void xe_live_mocs_reset_kunit(struct kunit *test) 178 + static void xe_live_mocs_reset_kunit(struct kunit *test) 177 179 { 178 180 xe_call_for_each_device(mocs_reset_test_run_device); 179 181 } 180 - EXPORT_SYMBOL_IF_KUNIT(xe_live_mocs_reset_kunit); 182 + 183 + static struct kunit_case xe_mocs_tests[] = { 184 + KUNIT_CASE(xe_live_mocs_kernel_kunit), 185 + KUNIT_CASE(xe_live_mocs_reset_kunit), 186 + {} 187 + }; 188 + 189 + VISIBLE_IF_KUNIT 190 + struct kunit_suite xe_mocs_test_suite = { 191 + .name = "xe_mocs", 192 + .test_cases = xe_mocs_tests, 193 + }; 194 + EXPORT_SYMBOL_IF_KUNIT(xe_mocs_test_suite);
-21
drivers/gpu/drm/xe/tests/xe_mocs_test.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * Copyright © 2022 Intel Corporation 4 - */ 5 - 6 - #include "xe_mocs_test.h" 7 - 8 - #include <kunit/test.h> 9 - 10 - static struct kunit_case xe_mocs_tests[] = { 11 - KUNIT_CASE(xe_live_mocs_kernel_kunit), 12 - KUNIT_CASE(xe_live_mocs_reset_kunit), 13 - {} 14 - }; 15 - 16 - static struct kunit_suite xe_mocs_test_suite = { 17 - .name = "xe_mocs", 18 - .test_cases = xe_mocs_tests, 19 - }; 20 - 21 - kunit_test_suite(xe_mocs_test_suite);
-14
drivers/gpu/drm/xe/tests/xe_mocs_test.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 AND MIT */ 2 - /* 3 - * Copyright © 2023 Intel Corporation 4 - */ 5 - 6 - #ifndef _XE_MOCS_TEST_H_ 7 - #define _XE_MOCS_TEST_H_ 8 - 9 - struct kunit; 10 - 11 - void xe_live_mocs_kernel_kunit(struct kunit *test); 12 - void xe_live_mocs_reset_kunit(struct kunit *test); 13 - 14 - #endif