selftests: watchdog: Add gettimeout and get|set pretimeout

Add command line arguments to call ioctl WDIOC_GETTIMEOUT,
WDIOC_GETPRETIMEOUT and WDIOC_SETPRETIMEOUT.

Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
This commit is contained in:
Jerry Hoemann 2018-09-26 15:23:09 -06:00 committed by Shuah Khan (Samsung OSG)
parent 04d5e4bd37
commit 7514c39cf1
1 changed files with 32 additions and 1 deletions

View File

@ -19,7 +19,7 @@
int fd;
const char v = 'V';
static const char sopts[] = "bdehp:t:";
static const char sopts[] = "bdehp:t:Tn:N";
static const struct option lopts[] = {
{"bootstatus", no_argument, NULL, 'b'},
{"disable", no_argument, NULL, 'd'},
@ -27,6 +27,9 @@ static const struct option lopts[] = {
{"help", no_argument, NULL, 'h'},
{"pingrate", required_argument, NULL, 'p'},
{"timeout", required_argument, NULL, 't'},
{"gettimeout", no_argument, NULL, 'T'},
{"pretimeout", required_argument, NULL, 'n'},
{"getpretimeout", no_argument, NULL, 'N'},
{NULL, no_argument, NULL, 0x0}
};
@ -71,9 +74,13 @@ static void usage(char *progname)
printf(" -h, --help Print the help message\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, --gettimeout Get the timeout\n");
printf(" -n, --pretimeout=T Set the pretimeout to T seconds\n");
printf(" -N, --getpretimeout Get the pretimeout\n");
printf("\n");
printf("Parameters are parsed left-to-right in real-time.\n");
printf("Example: %s -d -t 10 -p 5 -e\n", progname);
printf("Example: %s -t 12 -T -n 7 -N\n", progname);
}
int main(int argc, char *argv[])
@ -141,6 +148,30 @@ int main(int argc, char *argv[])
else
printf("WDIOC_SETTIMEOUT error '%s'\n", strerror(errno));
break;
case 'T':
oneshot = 1;
ret = ioctl(fd, WDIOC_GETTIMEOUT, &flags);
if (!ret)
printf("WDIOC_GETTIMEOUT returns %u seconds.\n", flags);
else
printf("WDIOC_GETTIMEOUT error '%s'\n", strerror(errno));
break;
case 'n':
flags = strtoul(optarg, NULL, 0);
ret = ioctl(fd, WDIOC_SETPRETIMEOUT, &flags);
if (!ret)
printf("Watchdog pretimeout set to %u seconds.\n", flags);
else
printf("WDIOC_SETPRETIMEOUT error '%s'\n", strerror(errno));
break;
case 'N':
oneshot = 1;
ret = ioctl(fd, WDIOC_GETPRETIMEOUT, &flags);
if (!ret)
printf("WDIOC_GETPRETIMEOUT returns %u seconds.\n", flags);
else
printf("WDIOC_GETPRETIMEOUT error '%s'\n", strerror(errno));
break;
default:
usage(argv[0]);
goto end;