testing/drivers: add watchdog notifier cmocka coverage#3639
Conversation
9584062 to
6ec0489
Compare
|
Updated the companion branch in response to the check results:
The test scope and watchdog-only registration behavior are unchanged. |
6ec0489 to
cdd0b1f
Compare
| #if !defined(CONFIG_ARCH_ARMV7A) || !defined(CONFIG_ARCH_HAVE_TRUSTZONE) | ||
| cmocka_unit_test_prestate(drivertest_watchdog_api, &wdg_state) | ||
| cmocka_unit_test_prestate(drivertest_watchdog_api, &wdg_state), | ||
| #endif |
There was a problem hiding this comment.
#endif
#endif
#ifdef CONFIG_WATCHDOG_TIMEOUT_NOTIFIER
cmocka_unit_test_prestate(drivertest_watchdog_notifier, &wdg_state),
cederom
left a comment
There was a problem hiding this comment.
Thank you @Zepp-Hanzj :-)
- You may want to udpate code style or leave as is if you want.
- Please add git commit messages, see https://nuttx.apache.org/docs/latest/contributing/index.html.
|
yeah we can skip this cosmetic part :-)
just a git message and we are ready to go :-)
…--
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
|
|
If you are using AI tools, please add the Could you please attach the logs from the tests you ran on sim? |
| ifeq ($(CONFIG_TESTING_DRIVER_TEST_WATCHDOG_ONLY),y) | ||
| MAINSRC += drivertest_watchdog.c | ||
| PROGNAME += cmocka_driver_watchdog | ||
| else |
There was a problem hiding this comment.
why skip other wdog test
cdd0b1f to
f1d3688
Compare
|
Addressed the review comments in the latest push. Code updates
The watchdog-only option intentionally skips the other drivertest applications: its purpose is to produce a minimal simulator image that registers only Simulator test logConfiguration: The capture-stop pending-interrupt validation also passed: the callback returned safely after the association was cleared and did not dereference a NULL upper-half. |
Add cmocka coverage for notifier priority ordering, duplicate registration, repeated timeout delivery, unregister behavior, action propagation, and NULL callback data. Signed-off-by: hanzhijian <hanzhijian@zepp.com> Assisted-by: OpenAI Codex
Add a focused watchdog-only cmocka registration and exercise notifier ordering, duplicate registration, repeated timeout delivery, unregister behavior, NULL data, and concurrent register/timeout/unregister activity. Signed-off-by: hanzhijian <hanzhijian@zepp.com> Assisted-by: OpenAI Codex
f1d3688 to
8fa68e9
Compare
|
The checkpatch failure was caused by commit messages shorter than the repository minimum of five lines. Both commits now include a descriptive body, the requested |
Include the container_of declaration and exclude unused hardware-only helpers when the watchdog notifier test is built alone. Signed-off-by: hanzhijian <hanzhijian@zepp.com> Assisted-by: OpenAI Codex
|
The simulator build exposed and is now fixed in commit |
Assisted-by: OpenAI Codex |
|
Thanks @cederom. Agreed — the remaining cosmetic formatting discussion can be skipped. The required commit messages are now in place with both |
Keep the existing drivertest applications under the main test option and register only the watchdog notifier application for the watchdog-only mode. This prevents unrelated cmocka applications from being added to simulator configurations that do not enable the driver test option. Signed-off-by: hanzhijian <hanzhijian@zepp.com> Assisted-by: OpenAI Codex
|
The failed CI jobs were investigated. The root cause was the CMake condition in Fixed in commit
|
| bool "Enable cmocka driver simple test" | ||
| default n | ||
|
|
||
| config TESTING_DRIVER_TEST_WATCHDOG_ONLY |
There was a problem hiding this comment.
why need special config
There was a problem hiding this comment.
This option was originally added to isolate the notifier tests on the simulator, because the existing watchdog tests require reset-cause support and a real watchdog device. After re-evaluating the registration logic, I agree that a special WATCHDOG_ONLY option is unnecessary and causes the existing watchdog tests to be skipped.
I will remove it, register cmocka_driver_watchdog when either CONFIG_BOARDCTL_RESET_CAUSE or CONFIG_WATCHDOG_TIMEOUT_NOTIFIER is available, and guard the hardware and notifier test groups separately. This preserves all existing watchdog tests when reset-cause support is available, while the simulator runs only the notifier cases.
| #define WDG_DEFAULT_TIMEOUT 2000 | ||
| #define WDG_DEFAULT_TESTCASE 0 | ||
| #define WDG_DEFAULT_DEVIATION 20 | ||
| #ifndef BOARDIOC_RESETCAUSE_SYS_CHIPPOR |
There was a problem hiding this comment.
These definitions were originally added because the reset-cause enum is not declared when reset-cause support is disabled. However, the enum values are not preprocessor macros, so these fallback checks are incorrect. I will remove both definitions and compile the reset-cause-dependent tests only under CONFIG_BOARDCTL_RESET_CAUSE.
Remove the special watchdog-only selection and register the watchdog cmocka application when reset-cause or timeout-notifier support is available. Compile the hardware watchdog cases only when reset-cause support is enabled, while allowing notifier-only simulator coverage. Remove the invalid reset-cause fallback macros so the real enum values are preserved. Assisted-by: OpenAI Codex Signed-off-by: hanzhijian <hanzhijian@zepp.com>
There was a problem hiding this comment.
@Zepp-Hanzj please add Documentation to drivertest to https://nuttx.apache.org/docs/latest/applications/testing/drivertest/index.html since the original author didn't add it and in the past we didn't required Documentation for new features
Please explain what is drivertest and which kind of tests are executed currently
|
Thanks. I expanded the drivertest documentation to explain what the test collection is, how its applications are selected and run, the current test categories, and the watchdog reset/notifier cases. The documentation source is in the main NuttX repository, so the change is in the companion NuttX PR #19433, commit I also verified the complete documentation tree with Sphinx using |
Summary
Add focused cmocka coverage for the watchdog timeout notifier chain and allow the watchdog drivertest to run notifier-only coverage on configurations without reset-cause support.
Changes
cmocka_driver_watchdogwhen watchdog support is enabled together with either reset-cause support or timeout-notifier support.CONFIG_BOARDCTL_RESET_CAUSEand the notifier cases only withCONFIG_WATCHDOG_TIMEOUT_NOTIFIER.WATCHDOG_NOTIFIER_ACTIONpropagation;data == NULLpropagation;Validation
The test was run using the companion NuttX simulator configuration. Since that configuration enables timeout-notifier support without reset-cause support,
cmocka_driver_watchdogruns only the two notifier cases:Both the Make and CMake registration paths compile
cmocka_driver_watchdogfor this configuration. The race test repeatedly interleaves timeout delivery with notifier registration and unregistration and asserts that callbacks remain valid and receive aNULLpayload.Additional hardware-path validation was performed in the companion NuttX PR on STM32F407 WWDG hardware. The corresponding UART logs and screenshots are linked there:
Scope
This PR contains only watchdog notifier tests and their test registration. Unrelated
O_RDONLYcompatibility changes are intentionally excluded.Merge order
Merge the companion NuttX core PR first, then enable this test configuration in CI or simulator validation.
Checklist
git diff --checkand NuttXcheckpatch.shpass.