@@ -1,4 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
-TEST_GEN_PROGS := watchdog-test
+TEST_GEN_FILES := watchdog-test
+TEST_PROGS := run_watchdog-test.sh
include ../lib.mk
new file mode 100755
@@ -0,0 +1,41 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+
+echo "$0: Feed dog"
+./watchdog-test -c 2 || exit
+
+echo
+echo "$0: Show watchdog_info"
+./watchdog-test -i -c 2 || exit
+
+echo
+echo "$0 Turn off the watchdog timer"
+./watchdog-test -d -c 2 || exit
+
+echo
+echo "$0: Turn on the watchdog timer"
+./watchdog-test -e -c 2 || exit
+
+echo
+echo "$0: Set timeout to T seconds"
+./watchdog-test -d -t 10 -c 2 -e || exit
+
+echo
+echo "$0: Get the timeout"
+./watchdog-test -T -c 2 || exit
+
+echo
+echo "$0: Get the pretimeout to T seconds"
+./watchdog-test -d -N -c 2 -e || exit
+
+echo
+echo "$0 Get the time left until timer expires"
+./watchdog-test -L -c 2 || exit
+
+echo
+echo "Get status & supported features"
+./watchdog-test -s || exit
+
+echo
+echo "$0: Set the pretimeout to T seconds"
+./watchdog-test -n 3 -c 2 || exit
We are ready to run the watchdog tests and check its exit code. An example output is like below: linux/tools/testing/selftests/watchdog# make run_tests TAP version 13 1..1 # timeout set to 45 # selftests: watchdog: run_watchdog-test.sh # ./run_watchdog-test.sh: Feed dog # Watchdog Ticking Away! # .. # ./run_watchdog-test.sh: Show watchdog_info # watchdog_info: # identity: iTCO_wdt # firmware_version: 2 # Support/Status: Set timeout (in seconds) # Support/Status: Supports magic close char # Support/Status: Keep alive ping reply # # ./run_watchdog-test.sh Turn off the watchdog timer # Watchdog card disabled. # Watchdog Ticking Away! # .. # ./run_watchdog-test.sh: Turn off the watchdog timer # Watchdog card enabled. # Watchdog Ticking Away! # .. # ./run_watchdog-test.sh: Set timeout to T seconds # Watchdog card disabled. # Watchdog timeout set to 10 seconds. # Watchdog card enabled. # Watchdog Ticking Away! # .. # ./run_watchdog-test.sh: Get the timeout # WDIOC_GETTIMEOUT returns 10 seconds. # # ./run_watchdog-test.sh: Get the pretimeout to T seconds # Watchdog card disabled. # WDIOC_GETPRETIMEOUT returns 0 seconds. # Watchdog card enabled. # # ./run_watchdog-test.sh Get the time left until timer expires # WDIOC_GETTIMELEFT returns 9 seconds. # # Get status & supported features # Support/Status: Keep alive ping reply # WDIOC_GETTEMP: 'Inappropriate ioctl for device' not ok 1 selftests: watchdog: run_watchdog-test.sh # exit=1 Signed-off-by: Li Zhijian <lizhijian@fujitsu.com> --- tools/testing/selftests/watchdog/Makefile | 3 +- .../selftests/watchdog/run_watchdog-test.sh | 41 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/watchdog/run_watchdog-test.sh