Commit f15d7114 authored by Timur Tabi's avatar Timur Tabi Committed by Wim Van Sebroeck

Documentation/watchdog: add timeout and ping rate control to watchdog-test.c

The watchdog test program is much more useful if it can configure the
timeout value and ping rate.  This will allow you to test actual timeouts.

Adds the -t parameter to set the timeout value (in seconds), and -p to set
the ping rate (number of seconds between pings).
Signed-off-by: default avatarTimur Tabi <timur@codeaurora.org>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent c13dcf9f
...@@ -41,6 +41,7 @@ static void term(int sig) ...@@ -41,6 +41,7 @@ static void term(int sig)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int flags; int flags;
unsigned int ping_rate = 1;
fd = open("/dev/watchdog", O_WRONLY); fd = open("/dev/watchdog", O_WRONLY);
...@@ -63,22 +64,33 @@ int main(int argc, char *argv[]) ...@@ -63,22 +64,33 @@ int main(int argc, char *argv[])
fprintf(stderr, "Watchdog card enabled.\n"); fprintf(stderr, "Watchdog card enabled.\n");
fflush(stderr); fflush(stderr);
goto end; goto end;
} else if (!strncasecmp(argv[1], "-t", 2) && argv[2]) {
flags = atoi(argv[2]);
ioctl(fd, WDIOC_SETTIMEOUT, &flags);
fprintf(stderr, "Watchdog timeout set to %u seconds.\n", flags);
fflush(stderr);
goto end;
} else if (!strncasecmp(argv[1], "-p", 2) && argv[2]) {
ping_rate = strtoul(argv[2], NULL, 0);
fprintf(stderr, "Watchdog ping rate set to %u seconds.\n", ping_rate);
fflush(stderr);
} else { } else {
fprintf(stderr, "-d to disable, -e to enable.\n"); fprintf(stderr, "-d to disable, -e to enable, -t <n> to set " \
"the timeout,\n-p <n> to set the ping rate, and \n");
fprintf(stderr, "run by itself to tick the card.\n"); fprintf(stderr, "run by itself to tick the card.\n");
fflush(stderr); fflush(stderr);
goto end; goto end;
} }
} else {
fprintf(stderr, "Watchdog Ticking Away!\n");
fflush(stderr);
} }
fprintf(stderr, "Watchdog Ticking Away!\n");
fflush(stderr);
signal(SIGINT, term); signal(SIGINT, term);
while(1) { while(1) {
keep_alive(); keep_alive();
sleep(1); sleep(ping_rate);
} }
end: end:
close(fd); close(fd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment