diff options
| author | Eugeniu Rosca <erosca@de.adit-jv.com> | 2017-07-01 08:57:29 -0400 |
|---|---|---|
| committer | Shuah Khan <shuahkh@osg.samsung.com> | 2017-07-24 14:37:01 -0400 |
| commit | f8f92c072e6f1e694c13d432bdbdbcbf138c31ad (patch) | |
| tree | 1ace4779880da25dc389e7acf429a8bc050c3f74 /tools/testing | |
| parent | 42f34c4e245641d1bae88de469053d3c3aa4d9fa (diff) | |
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: Eugeniu Rosca <erosca@de.adit-jv.com>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to 'tools/testing')
| -rw-r--r-- | tools/testing/selftests/watchdog/watchdog-test.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c index 41f40c3c4d95..9b34b319fc91 100644 --- a/tools/testing/selftests/watchdog/watchdog-test.c +++ b/tools/testing/selftests/watchdog/watchdog-test.c | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | #include <linux/types.h> | 14 | #include <linux/types.h> |
| 15 | #include <linux/watchdog.h> | 15 | #include <linux/watchdog.h> |
| 16 | 16 | ||
| 17 | #define DEFAULT_PING_RATE 1 | ||
| 18 | |||
| 17 | int fd; | 19 | int fd; |
| 18 | const char v = 'V'; | 20 | const char v = 'V'; |
| 19 | static const char sopts[] = "dehp:t:"; | 21 | static const char sopts[] = "dehp:t:"; |
| @@ -64,7 +66,7 @@ static void usage(char *progname) | |||
| 64 | printf(" -d, --disable Turn off the watchdog timer\n"); | 66 | printf(" -d, --disable Turn off the watchdog timer\n"); |
| 65 | printf(" -e, --enable Turn on the watchdog timer\n"); | 67 | printf(" -e, --enable Turn on the watchdog timer\n"); |
| 66 | printf(" -h, --help Print the help message\n"); | 68 | printf(" -h, --help Print the help message\n"); |
| 67 | printf(" -p, --pingrate=P Set ping rate to P seconds\n"); | 69 | printf(" -p, --pingrate=P Set ping rate to P seconds (default %d)\n", DEFAULT_PING_RATE); |
| 68 | printf(" -t, --timeout=T Set timeout to T seconds\n"); | 70 | printf(" -t, --timeout=T Set timeout to T seconds\n"); |
| 69 | printf("\n"); | 71 | printf("\n"); |
| 70 | printf("Parameters are parsed left-to-right in real-time.\n"); | 72 | printf("Parameters are parsed left-to-right in real-time.\n"); |
| @@ -74,7 +76,7 @@ static void usage(char *progname) | |||
| 74 | int main(int argc, char *argv[]) | 76 | int main(int argc, char *argv[]) |
| 75 | { | 77 | { |
| 76 | int flags; | 78 | int flags; |
| 77 | unsigned int ping_rate = 1; | 79 | unsigned int ping_rate = DEFAULT_PING_RATE; |
| 78 | int ret; | 80 | int ret; |
| 79 | int c; | 81 | int c; |
| 80 | 82 | ||
| @@ -107,6 +109,8 @@ int main(int argc, char *argv[]) | |||
| 107 | break; | 109 | break; |
| 108 | case 'p': | 110 | case 'p': |
| 109 | ping_rate = strtoul(optarg, NULL, 0); | 111 | ping_rate = strtoul(optarg, NULL, 0); |
| 112 | if (!ping_rate) | ||
| 113 | ping_rate = DEFAULT_PING_RATE; | ||
| 110 | printf("Watchdog ping rate set to %u seconds.\n", ping_rate); | 114 | printf("Watchdog ping rate set to %u seconds.\n", ping_rate); |
| 111 | break; | 115 | break; |
| 112 | case 't': | 116 | case 't': |
