mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Tests for drivers often require a struct device to pass to other functions. While it's possible to create these with root_device_register(), or to use something like a platform device, this is both a misuse of those APIs, and can be difficult to clean up after, for example, a failed assertion. Add some KUnit-specific functions for registering and unregistering a struct device: - kunit_device_register() - kunit_device_register_with_driver() - kunit_device_unregister() These helpers allocate a on a 'kunit' bus which will either probe the driver passed in (kunit_device_register_with_driver), or will create a stub driver (kunit_device_register) which is cleaned up on test shutdown. Devices are automatically unregistered on test shutdown, but can be manually unregistered earlier with kunit_device_unregister() in order to, for example, test device release code. Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Reviewed-by: Maxime Ripard <mripard@kernel.org> Signed-off-by: David Gow <davidgow@google.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
22 lines
531 B
ReStructuredText
22 lines
531 B
ReStructuredText
.. SPDX-License-Identifier: GPL-2.0
|
|
|
|
============
|
|
Resource API
|
|
============
|
|
|
|
This file documents the KUnit resource API.
|
|
|
|
Most users won't need to use this API directly, power users can use it to store
|
|
state on a per-test basis, register custom cleanup actions, and more.
|
|
|
|
.. kernel-doc:: include/kunit/resource.h
|
|
:internal:
|
|
|
|
Managed Devices
|
|
---------------
|
|
|
|
Functions for using KUnit-managed struct device and struct device_driver.
|
|
Include ``kunit/device.h`` to use these.
|
|
|
|
.. kernel-doc:: include/kunit/device.h
|
|
:internal:
|