linux/lib/kunit
davidgow@google.com d03c720e03 kunit: Add APIs for managing devices
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>
2023-12-18 13:28:08 -07:00
..
.kunitconfig kunit: tool: make --kunitconfig accept dirs, add lib/kunit fragment 2021-04-02 14:14:36 -06:00
assert.c kunit: Don't use a managed alloc in is_literal() 2023-09-18 10:45:30 -06:00
attributes.c kunit: add is_init test attribute 2023-12-18 13:21:15 -07:00
debugfs.c kunit: add ability to run tests after boot using debugfs 2023-12-18 13:25:49 -07:00
debugfs.h kunit: add debugfs /sys/kernel/debug/kunit/<suite>/results display 2020-03-26 14:07:18 -06:00
device-impl.h kunit: Add APIs for managing devices 2023-12-18 13:28:08 -07:00
device.c kunit: Add APIs for managing devices 2023-12-18 13:28:08 -07:00
executor_test.c kunit: test: Fix the possible memory leak in executor_test 2023-09-28 08:51:07 -06:00
executor.c kunit: add is_init test attribute 2023-12-18 13:21:15 -07:00
hooks-impl.h kunit: Add printf attribute to fail_current_test_impl 2023-02-08 18:08:14 -07:00
hooks.c kunit: Add "hooks" to call into KUnit when it's built as a module 2023-02-08 14:26:25 -07:00
Kconfig kunit: Allow kunit test modules to use test filtering 2023-08-08 13:46:18 -06:00
kunit-example-test.c kunit: add example suite to test init suites 2023-12-18 13:21:15 -07:00
kunit-test.c kunit: Add APIs for managing devices 2023-12-18 13:28:08 -07:00
Makefile kunit: Add APIs for managing devices 2023-12-18 13:28:08 -07:00
resource.c kunit: Add kunit_add_action() to defer a call until test exit 2023-05-25 08:52:55 -06:00
static_stub.c kunit: Expose 'static stub' API to redirect functions 2023-02-08 14:28:17 -07:00
string-stream-test.c kunit: string-stream-test: Avoid cast warning when testing gfp_t flags 2023-12-18 13:21:14 -07:00
string-stream.c kunit: string-stream: Allow ERR_PTR to be passed to string_stream_destroy() 2023-12-18 13:21:14 -07:00
string-stream.h kunit: string-stream: Decouple string_stream from kunit 2023-09-18 10:45:40 -06:00
test.c kunit: Add APIs for managing devices 2023-12-18 13:28:08 -07:00
try-catch-impl.h kunit: hide unexported try-catch interface in try-catch-impl.h 2020-01-09 16:42:09 -07:00
try-catch.c kunit: make kunit_test_timeout compatible with comment 2022-03-22 15:57:11 -07:00