[PATCH 1/3] drm/xe/kunit: fix link failure with built-in xe

Maxime Ripard mripard at kernel.org
Mon Feb 26 09:04:15 UTC 2024


On Sun, Feb 25, 2024 at 09:42:06PM -0600, Lucas De Marchi wrote:
> On Sat, Feb 24, 2024 at 01:14:59PM +0100, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd at arndb.de>
> > 
> > When the driver is built-in but the tests are in loadable modules,
> > the helpers don't actually get put into the driver:
> > 
> > ERROR: modpost: "xe_kunit_helper_alloc_xe_device" [drivers/gpu/drm/xe/tests/xe_test.ko] undefined!
> > 
> > Change the Makefile to ensure they are always part of the driver
> > even when the rest of the kunit tests are in loadable modules.
> > 
> > The tests/xe_kunit_helpers.c file depends on DRM_KUNIT_TEST_HELPERS,
> > so this has to always be selected by the main XE module now, rather
> > than the actual tests. In turn, the "depends on (m || (y && KUNIT=y))"
> > doesn't really do what it tried and can just be removed.
> 
> it actually did, which was to workaround issues prior to the commit you
> are pointing out.  What it did  was to make sure xe.ko is m, or if it's
> built-in, kunit is also built-in. Apparently the problem here is that
> the xe_test.ko is missing the symbols.
> 
> See commit 08987a8b6820 ("drm/xe: Fix build with KUNIT=m").
> 
> I'm happy to remove it though if it's indeed not needed anymore.

I think the main issue with that original patch is that it keeps the
direct include of the test files.

I assume it was done to allow kunit tests of static functions, but now
that VISIBLE_IF_KUNIT and EXPORT_SYMBOL_IF_KUNIT are a thing, you don't
have the need for that include, and you can build your tests in a module
while the code is builtin.

And the conversion should be pretty minimal.

Maxime
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20240226/0695854e/attachment.sig>


More information about the dri-devel mailing list