Commit f8f92c07 authored by Eugeniu Rosca's avatar Eugeniu Rosca Committed by Shuah Khan

selftests: watchdog: avoid keepalive flood

Calling `watchdog-test [options] -p 0` results in flooding the kernel
with WDIOC_KEEPALIVE. Fix this by enforcing 1 second as minimal/default
keepalive/ping rate.
Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
Signed-off-by: default avatarShuah Khan <shuahkh@osg.samsung.com>
parent 42f34c4e
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/watchdog.h> #include <linux/watchdog.h>
#define DEFAULT_PING_RATE 1
int fd; int fd;
const char v = 'V'; const char v = 'V';
static const char sopts[] = "dehp:t:"; static const char sopts[] = "dehp:t:";
...@@ -64,7 +66,7 @@ static void usage(char *progname) ...@@ -64,7 +66,7 @@ static void usage(char *progname)
printf(" -d, --disable Turn off the watchdog timer\n"); printf(" -d, --disable Turn off the watchdog timer\n");
printf(" -e, --enable Turn on the watchdog timer\n"); printf(" -e, --enable Turn on the watchdog timer\n");
printf(" -h, --help Print the help message\n"); printf(" -h, --help Print the help message\n");
printf(" -p, --pingrate=P Set ping rate to P seconds\n"); printf(" -p, --pingrate=P Set ping rate to P seconds (default %d)\n", DEFAULT_PING_RATE);
printf(" -t, --timeout=T Set timeout to T seconds\n"); printf(" -t, --timeout=T Set timeout to T seconds\n");
printf("\n"); printf("\n");
printf("Parameters are parsed left-to-right in real-time.\n"); printf("Parameters are parsed left-to-right in real-time.\n");
...@@ -74,7 +76,7 @@ static void usage(char *progname) ...@@ -74,7 +76,7 @@ static void usage(char *progname)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int flags; int flags;
unsigned int ping_rate = 1; unsigned int ping_rate = DEFAULT_PING_RATE;
int ret; int ret;
int c; int c;
...@@ -107,6 +109,8 @@ int main(int argc, char *argv[]) ...@@ -107,6 +109,8 @@ int main(int argc, char *argv[])
break; break;
case 'p': case 'p':
ping_rate = strtoul(optarg, NULL, 0); ping_rate = strtoul(optarg, NULL, 0);
if (!ping_rate)
ping_rate = DEFAULT_PING_RATE;
printf("Watchdog ping rate set to %u seconds.\n", ping_rate); printf("Watchdog ping rate set to %u seconds.\n", ping_rate);
break; break;
case 't': case 't':
......
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