[PATCH v5 06/10] drm/xe/kunit: Restore test->priv when done with fake xe device
Lucas De Marchi
lucas.demarchi at intel.com
Mon Dec 18 22:45:35 UTC 2023
On Mon, Dec 18, 2023 at 08:06:25PM +0100, Michal Wajdeczko wrote:
>Current KUnit implementation does not reset test->priv in case of
I don't like much having a workaround to this kunit issue on our side,
but you also did got the kunit patch reviewed at
https://lore.kernel.org/linux-kselftest/CABVgOS=imuVpgwwhSb8AQ_=YG2bfK8T5DE9yYr_XUb1CPDzxgA@mail.gmail.com/
Hopefully that will be applied soon and we can revert this.
Acked-by: Lucas De Marchi <lucas.demarchi at intel.com>
Lucas De Marchi
>parametrized tests and that may lead to wrongly treat our output
>pointer to fake xe_device from first call as input pointer with
>xe_pci_fake_data on subsequent calls. Restore test->priv to
>original value to avoid invalid access.
>
>Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
>---
> drivers/gpu/drm/xe/tests/xe_kunit_helpers.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
>diff --git a/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c b/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
>index 6d72dbf06139..fefe79b3b75a 100644
>--- a/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
>+++ b/drivers/gpu/drm/xe/tests/xe_kunit_helpers.c
>@@ -41,6 +41,13 @@ struct xe_device *xe_kunit_helper_alloc_xe_device(struct kunit *test,
> }
> EXPORT_SYMBOL_IF_KUNIT(xe_kunit_helper_alloc_xe_device);
>
>+static void kunit_action_restore_priv(void *priv)
>+{
>+ struct kunit *test = kunit_get_current_test();
>+
>+ test->priv = priv;
>+}
>+
> /**
> * xe_kunit_helper_xe_device_test_init - Prepare a &xe_device for a KUnit test.
> * @test: the &kunit where this fake &xe_device will be used
>@@ -74,6 +81,9 @@ int xe_kunit_helper_xe_device_test_init(struct kunit *test)
> err = xe_pci_fake_device_init(xe);
> KUNIT_ASSERT_EQ(test, err, 0);
>
>+ err = kunit_add_action_or_reset(test, kunit_action_restore_priv, test->priv);
>+ KUNIT_ASSERT_EQ(test, err, 0);
>+
> test->priv = xe;
> return 0;
> }
>--
>2.25.1
>
More information about the Intel-xe
mailing list