[PATCH] selftests: watchdog: skip ping loop if WDIOF_KEEPALIVEPING not supported

Akhilesh Patil posted 1 patch 2 weeks, 3 days ago
tools/testing/selftests/watchdog/watchdog-test.c | 6 ++++++
1 file changed, 6 insertions(+)
[PATCH] selftests: watchdog: skip ping loop if WDIOF_KEEPALIVEPING not supported
Posted by Akhilesh Patil 2 weeks, 3 days ago
Check if watchdog device supports WDIOF_KEEPALIVEPING option before
entering keep_alive() ping test loop. Fix watchdog-test silently looping
if ioctl based ping is not supported by the device. Exit from test in
such case instead of stucking in loop executing failing keep_alive()

Fixes: d89d08ffd2c5 ("selftests: watchdog: Fix ioctl SET* error paths to take oneshot exit path")
Signed-off-by: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
---

Testing: 

# wdt_test_1 -f /dev/watchdog0 -i
watchdog_info:
 identity:              m41t93 rtc Watchdog
 firmware_version:      0
Support/Status: Set timeout (in seconds)
Support/Status: Watchdog triggers a management or other external alarm not a reboot

# wdt_test_1 -f /dev/watchdog0 -d -t 5 -p 2 -e
Watchdog card disabled.
Watchdog timeout set to 5 seconds.
Watchdog ping rate set to 2 seconds.
Watchdog card enabled.
WDIOC_KEEPALIVE not supported by this device

without this change 
# wdt_test_2 -f /dev/watchdog0 -d -t 5 -p 2 -e
Watchdog card disabled.
Watchdog timeout set to 5 seconds.
Watchdog ping rate set to 2 seconds.
Watchdog card enabled.
Watchdog Ticking Away!
^C
(Where test stuck here forver silently)
---
 tools/testing/selftests/watchdog/watchdog-test.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
index a1f506ba5578..4f09c5db0c7f 100644
--- a/tools/testing/selftests/watchdog/watchdog-test.c
+++ b/tools/testing/selftests/watchdog/watchdog-test.c
@@ -332,6 +332,12 @@ int main(int argc, char *argv[])
 	if (oneshot)
 		goto end;
 
+	/* Check if WDIOF_KEEPALIVEPING is supported */
+	if (!(info.options & WDIOF_KEEPALIVEPING)) {
+		printf("WDIOC_KEEPALIVE not supported by this device\n");
+		goto end;
+	}
+
 	printf("Watchdog Ticking Away!\n");
 
 	/*
-- 
2.34.1
Re: [PATCH] selftests: watchdog: skip ping loop if WDIOF_KEEPALIVEPING not supported
Posted by Shuah Khan 2 weeks, 1 day ago
On 9/14/25 09:28, Akhilesh Patil wrote:
> Check if watchdog device supports WDIOF_KEEPALIVEPING option before
> entering keep_alive() ping test loop. Fix watchdog-test silently looping
> if ioctl based ping is not supported by the device. Exit from test in
> such case instead of stucking in loop executing failing keep_alive()
> 
> Fixes: d89d08ffd2c5 ("selftests: watchdog: Fix ioctl SET* error paths to take oneshot exit path")
> Signed-off-by: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
> ---
> 
>

Applied to linux-kselftest next branch for Linux 6.18-rc1

thanks,
-- Shuah