Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Timur Tabi <timur@codeaurora.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>

authored by

Timur Tabi and committed by
Wim Van Sebroeck
f15d7114 c13dcf9f

+17 -5
+17 -5
Documentation/watchdog/src/watchdog-test.c
··· 41 41 int main(int argc, char *argv[]) 42 42 { 43 43 int flags; 44 + unsigned int ping_rate = 1; 44 45 45 46 fd = open("/dev/watchdog", O_WRONLY); 46 47 ··· 64 63 fprintf(stderr, "Watchdog card enabled.\n"); 65 64 fflush(stderr); 66 65 goto end; 66 + } else if (!strncasecmp(argv[1], "-t", 2) && argv[2]) { 67 + flags = atoi(argv[2]); 68 + ioctl(fd, WDIOC_SETTIMEOUT, &flags); 69 + fprintf(stderr, "Watchdog timeout set to %u seconds.\n", flags); 70 + fflush(stderr); 71 + goto end; 72 + } else if (!strncasecmp(argv[1], "-p", 2) && argv[2]) { 73 + ping_rate = strtoul(argv[2], NULL, 0); 74 + fprintf(stderr, "Watchdog ping rate set to %u seconds.\n", ping_rate); 75 + fflush(stderr); 67 76 } else { 68 - fprintf(stderr, "-d to disable, -e to enable.\n"); 77 + fprintf(stderr, "-d to disable, -e to enable, -t <n> to set " \ 78 + "the timeout,\n-p <n> to set the ping rate, and \n"); 69 79 fprintf(stderr, "run by itself to tick the card.\n"); 70 80 fflush(stderr); 71 81 goto end; 72 82 } 73 - } else { 74 - fprintf(stderr, "Watchdog Ticking Away!\n"); 75 - fflush(stderr); 76 83 } 84 + 85 + fprintf(stderr, "Watchdog Ticking Away!\n"); 86 + fflush(stderr); 77 87 78 88 signal(SIGINT, term); 79 89 80 90 while(1) { 81 91 keep_alive(); 82 - sleep(1); 92 + sleep(ping_rate); 83 93 } 84 94 end: 85 95 close(fd);