On 05/27/2017 11:26 AM, Eugeniu Rosca wrote:
Tested on Rcar-H3 Salvator-X board:
********************** Cold boot finished
salvator-x:/home/root#
salvator-x:/home/root# ./wdt_test -s
Last boot is caused by: Power-On-Reset.
salvator-x:/home/root#
salvator-x:/home/root# ./wdt_test -t 1 -p 5 -e
Watchdog timeout set to 1 seconds.
Watchdog ping rate set to 5 seconds.
Watchdog card enabled.
Watchdog Ticking Away!
********************** Reboot due to watchdog trigger finished
salvator-x:/home/root#
salvator-x:/home/root# ./wdt_test -s
Last boot is caused by: Watchdog.
salvator-x:/home/root# reboot
********************** Reboot due to user action finished
salvator-x:/home/root#
salvator-x:/home/root# ./wdt_test -s
Last boot is caused by: Power-On-Reset.
salvator-x:/home/root#
salvator-x:/home/root# ./wdt_test --help
-s to print the status (POR/watchdog) of the last boot,
-d to disable, -e to enable, -t <n> to set the timeout,
-p <n> to set the ping rate, and run by itself to tick the card.
Parameters are parsed left-to-right in real-time.
Example: ./wdt_test -d -t 10 -p 5 -e
salvator-x:/home/root#
Signed-off-by: Eugeniu Rosca <erosca@xxxxxxxxxxxxxx>
Reviewed-by: Guenter Roeck <linux@xxxxxxxxxxxx>
---
tools/testing/selftests/watchdog/watchdog-test.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
index a74c9d739d07..8f4198b07a61 100644
--- a/tools/testing/selftests/watchdog/watchdog-test.c
+++ b/tools/testing/selftests/watchdog/watchdog-test.c
@@ -54,6 +54,7 @@ int main(int argc, char *argv[])
unsigned int ping_rate = 1;
int ret;
int i;
+ int bootstatus;
setbuf(stdout, NULL);
@@ -85,7 +86,16 @@ int main(int argc, char *argv[])
ping_rate = strtoul(argv[i + 1], NULL, 0);
printf("Watchdog ping rate set to %u seconds.\n", ping_rate);
i++;
+ } else if (!strncasecmp(argv[i], "-s", 2)) {
+ ret = ioctl(fd, WDIOC_GETBOOTSTATUS, &bootstatus);
+ if (!ret)
+ printf("Last boot is caused by: %s.\n", (bootstatus != 0) ?
+ "Watchdog" : "Power-On-Reset");
+ else
+ printf("Error: WDIOC_GETBOOTSTATUS failed.\n");
+ goto end;
} else {
+ printf("-s to print the status (POR/watchdog) of the last boot,\n");
printf("-d to disable, -e to enable, -t <n> to set "
"the timeout,\n-p <n> to set the ping rate, and ");
printf("run by itself to tick the card.\n");
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html