]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests: watchdog: skip ping loop if WDIOF_KEEPALIVEPING not supported
authorAkhilesh Patil <akhilesh@ee.iitb.ac.in>
Sun, 14 Sep 2025 15:28:41 +0000 (20:58 +0530)
committerShuah Khan <skhan@linuxfoundation.org>
Tue, 16 Sep 2025 22:55:04 +0000 (16:55 -0600)
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 getting stuck in loop executing failing keep_alive()

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

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
Watchdog card disabled.
Watchdog timeout set to 5 seconds.
Watchdog ping rate set to 2 seconds.
Watchdog card enabled.
Watchdog Ticking Away!
(Where test stuck here forver silently)

Updated change log at commit time:
Shuah Khan <skhan@linuxfoundation.org>

Link: https://lore.kernel.org/r/20250914152840.GA3047348@bhairav-test.ee.iitb.ac.in
Fixes: d89d08ffd2c5 ("selftests: watchdog: Fix ioctl SET* error paths to take oneshot exit path")
Signed-off-by: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/watchdog/watchdog-test.c

index a1f506ba557864bdae7316d12a79de2d852ab2a0..4f09c5db0c7f30f35d8ad61597dbfba187cbef54 100644 (file)
@@ -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");
 
        /*