// SPDX-License-Identifier: GPL-2.0 AND MIT /* * Copyright © 2023 Intel Corporation */ #include <kunit/test.h> #include <kunit/static_stub.h> #include <kunit/visibility.h> #include <drm/drm_drv.h> #include <drm/drm_kunit_helpers.h> #include "tests/xe_kunit_helpers.h" #include "tests/xe_pci_test.h" #include "xe_device_types.h" /** * xe_kunit_helper_alloc_xe_device - Allocate a &xe_device for a KUnit test. * @test: the &kunit where this &xe_device will be used * @dev: The parent device object * * This function allocates xe_device using drm_kunit_helper_alloc_device(). * The xe_device allocation is managed by the test. * * @dev should be allocated using drm_kunit_helper_alloc_device(). * * This function uses KUNIT_ASSERT to detect any allocation failures. * * Return: A pointer to the new &xe_device. */ struct xe_device *xe_kunit_helper_alloc_xe_device(struct kunit *test, struct device *dev) { … } EXPORT_SYMBOL_IF_KUNIT(…); static void kunit_action_restore_priv(void *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 * * This function allocates and initializes a fake &xe_device and stores its * pointer as &kunit.priv to allow the test code to access it. * * This function can be directly used as custom implementation of * &kunit_suite.init. * * It is possible to prepare specific variant of the fake &xe_device by passing * in &kunit.priv pointer to the struct xe_pci_fake_data supplemented with * desired parameters prior to calling this function. * * This function uses KUNIT_ASSERT to detect any failures. * * Return: Always 0. */ int xe_kunit_helper_xe_device_test_init(struct kunit *test) { … } EXPORT_SYMBOL_IF_KUNIT(…);