diff options
author | Michal Wajdeczko <michal.wajdeczko@intel.com> | 2023-12-18 20:06:25 +0100 |
---|---|---|
committer | Rodrigo Vivi <rodrigo.vivi@intel.com> | 2023-12-21 16:31:30 -0500 |
commit | 0b75475723b182400a4bfa5aaff9a969afdfdb76 (patch) | |
tree | 3a99dde933352817eaaece268c0159ca6a24fa63 | |
parent | drm/xe/kunit: Define helper functions to allocate fake xe device (diff) | |
download | linux-0b75475723b182400a4bfa5aaff9a969afdfdb76.tar.gz linux-0b75475723b182400a4bfa5aaff9a969afdfdb76.tar.bz2 linux-0b75475723b182400a4bfa5aaff9a969afdfdb76.zip |
drm/xe/kunit: Restore test->priv when done with fake xe device
Current KUnit implementation does not reset test->priv in case of
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.
Acked-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/r/20231218190629.502-7-michal.wajdeczko@intel.com
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
-rw-r--r-- | drivers/gpu/drm/xe/tests/xe_kunit_helpers.c | 10 |
1 files changed, 10 insertions, 0 deletions
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; } |