reset: Add KUnit test cases
PATCH v3 1/1 reset: Add KUnit test cases
Since commit 9035073d0ef1 ("reset: convert reset core to using firmware nodes"), reset suppliers and consumers can be wired up using software nodes without requiring Device Tree or hardware devices. Leverage this to add KUnit test cases for the reset controller framework.
The test cases cover the following scenarios:
- Basic: Verifies that a consumer can acquire a reset control via fwnode and perform reset, assert, deassert, status, release, and acquire operations.
- Use After Unregister: Verifies that after the supplier unregisters the reset_controller_dev while a consumer still holds a reset_control handle, subsequent consumer operations fail safely with -ENODEV.
- Concurrent Unregister: Verifies that unregistering the reset_controller_dev concurrently with an in-flight reset operation waits for the active operation to complete before returning.
---
Test:
$ ./tools/testing/kunit/kunit.py run \
--kconfig_add CONFIG_RESET_CONTROLLER=y \
--kconfig_add CONFIG_RESET_KUNIT_TEST=y \
reset_test
---
v3:
- Verify that reset_controller_unregister() blocks until active
consumers finish in reset_test_concurrent_unregister().v2: https://lore.kernel.org/all/[email protected]
- Separate out from the revocable series.
- Add reset_test_exit() to clean up rstc and rcdev on test exit or assertion failure.
- Clean up kthreads on error paths in reset_test_concurrent_unregister().
v1: https://lore.kernel.org/all/[email protected]
--- drivers/reset/Kconfig | 5 + drivers/reset/Makefile | 2 + drivers/reset/core-test.c | 365 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 372 insertions(+) create mode 100644 drivers/reset/core-test.c
drivers/reset/Kconfig +5 -0
@@ -457,4 +457,9 @@ source "drivers/reset/starfive/Kconfig" source "drivers/reset/sti/Kconfig" source "drivers/reset/tegra/Kconfig" +config RESET_KUNIT_TEST + tristate "KUnit tests for reset controller" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + endif
drivers/reset/Makefile +2 -0
@@ -55,3 +55,5 @@ obj-$(CONFIG_RESET_UNIPHIER) += reset-uniphier.o obj-$(CONFIG_RESET_UNIPHIER_GLUE) += reset-uniphier-glue.o obj-$(CONFIG_RESET_ZYNQ) += reset-zynq.o obj-$(CONFIG_RESET_ZYNQMP) += reset-zynqmp.o + +obj-$(CONFIG_RESET_KUNIT_TEST) += core-test.o
drivers/reset/core-test.c new file +365 -0
365 lines not on this page · raw message
Signature · 1 line
2.53.0
Quoted 17 lines · Tzung-Bi Shih
Since commit
9035073d0ef1("reset: convert reset core to using firmware nodes"), reset suppliers and consumers can be wired up using software nodes without requiring Device Tree or hardware devices. Leverage this to add KUnit test cases for the reset controller framework.The test cases cover the following scenarios:
- Basic: Verifies that a consumer can acquire a reset control via fwnode and perform reset, assert, deassert, status, release, and acquire operations.
- Use After Unregister: Verifies that after the supplier unregisters thereset_controller_devwhile a consumer still holds areset_controlhandle, subsequent consumer operations fail safely with-ENODEV.
- Concurrent Unregister: Verifies that unregistering thereset_controller_devconcurrently with an in-flight reset operation waits for the active operation to complete before returning.
Quoted 1 line
Signed-off-by Tzung-Bi Shih <[email protected]>
regards
Philipp
Quoted 17 lines · Tzung-Bi Shih
Since commit
9035073d0ef1("reset: convert reset core to using firmware nodes"), reset suppliers and consumers can be wired up using software nodes without requiring Device Tree or hardware devices. Leverage this to add KUnit test cases for the reset controller framework.The test cases cover the following scenarios:
- Basic: Verifies that a consumer can acquire a reset control via fwnode and perform reset, assert, deassert, status, release, and acquire operations.
- Use After Unregister: Verifies that after the supplier unregisters thereset_controller_devwhile a consumer still holds areset_controlhandle, subsequent consumer operations fail safely with-ENODEV.
- Concurrent Unregister: Verifies that unregistering thereset_controller_devconcurrently with an in-flight reset operation waits for the active operation to complete before returning.
Quoted 1 line
Signed-off-by Tzung-Bi Shih <[email protected]>
Applied to reset/next, thanks!
[1/1] reset: Add KUnit test cases
https://git.kernel.org/pub/scm/linux/kernel/git/pza/linux.git/commit/?id=db2f5f4ccc3df
regards
Philipp