Skip to contentSkip to conversation

reset: Add KUnit test cases

PATCH Applied Tzung-Bi Shih 2 participants 3 messages Nov 4 – Nov 5 Reset controller framework

lore
Share & tools
lore
#0 lore raw

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
index eda9c698a95f..c7dceec8f58c 100644
@@ -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
index 489fafd6bbe3..bb01198d495b 100644
@@ -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
maintainer Reviewed-by on v3 1/1
#1 lore raw
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 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.

Quoted 1 line

regards
Philipp

maintainer Applied
#2 lore raw
In reply to Tzung-Bi Shih
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 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.

Quoted 1 line

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