Add command line arguments to call ioctl WDIOC_GETTIMEOUT, WDIOC_GETPRETIMEOUT and WDIOC_SETPRETIMEOUT.
Changes v2 1) Update usage to include argument 2) Update usage to give example. 3) Made printf of WDIOC_GETTIMEOUT distinct from WDIOC_SETTIMEOUT 4) Made WDIOC_GETTIMEOUT a "one shot" 5) Made printf of WDIOC_GETPRETIMEOUT disnct from WDIOC_SETPRETIMEOUT 6) Made WDIOC_GETPRETIMEOUT a "one shot"
Change v3 1) Printf says errno, but prints the string version of the error. Make the printf consistent. 2) As above error was cut/paste from prior printf in application add new patch 1 to fix the existing printf first.
Jerry Hoemann (2): selftests: watchdog: Fix error message. selftests: watchdog: Add gettimeout and get|set pretimeout
tools/testing/selftests/watchdog/watchdog-test.c | 41 +++++++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-)
Printf's say errno but print the string version of error. Make consistent.
Signed-off-by: Jerry Hoemann jerry.hoemann@hpe.com --- tools/testing/selftests/watchdog/watchdog-test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c index 6e29087..8429186 100644 --- a/tools/testing/selftests/watchdog/watchdog-test.c +++ b/tools/testing/selftests/watchdog/watchdog-test.c @@ -103,7 +103,7 @@ int main(int argc, char *argv[]) printf("Last boot is caused by: %s.\n", (flags != 0) ? "Watchdog" : "Power-On-Reset"); else - printf("WDIOC_GETBOOTSTATUS errno '%s'\n", strerror(errno)); + printf("WDIOC_GETBOOTSTATUS error '%s'\n", strerror(errno)); break; case 'd': flags = WDIOS_DISABLECARD; @@ -111,7 +111,7 @@ int main(int argc, char *argv[]) if (!ret) printf("Watchdog card disabled.\n"); else - printf("WDIOS_DISABLECARD errno '%s'\n", strerror(errno)); + printf("WDIOS_DISABLECARD error '%s'\n", strerror(errno)); break; case 'e': flags = WDIOS_ENABLECARD; @@ -119,7 +119,7 @@ int main(int argc, char *argv[]) if (!ret) printf("Watchdog card enabled.\n"); else - printf("WDIOS_ENABLECARD errno '%s'\n", strerror(errno)); + printf("WDIOS_ENABLECARD error '%s'\n", strerror(errno)); break; case 'p': ping_rate = strtoul(optarg, NULL, 0); @@ -133,7 +133,7 @@ int main(int argc, char *argv[]) if (!ret) printf("Watchdog timeout set to %u seconds.\n", flags); else - printf("WDIOC_SETTIMEOUT errno '%s'\n", strerror(errno)); + printf("WDIOC_SETTIMEOUT error '%s'\n", strerror(errno)); break; default: usage(argv[0]);
Add command line arguments to call ioctl WDIOC_GETTIMEOUT, WDIOC_GETPRETIMEOUT and WDIOC_SETPRETIMEOUT.
Signed-off-by: Jerry Hoemann jerry.hoemann@hpe.com --- tools/testing/selftests/watchdog/watchdog-test.c | 33 +++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c index 8429186..e29bc71 100644 --- a/tools/testing/selftests/watchdog/watchdog-test.c +++ b/tools/testing/selftests/watchdog/watchdog-test.c @@ -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 @@ {"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[]) @@ -135,6 +142,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;
On 09/26/2018 03:23 PM, Jerry Hoemann wrote:
Add command line arguments to call ioctl WDIOC_GETTIMEOUT, WDIOC_GETPRETIMEOUT and WDIOC_SETPRETIMEOUT.
Changes v2
- Update usage to include argument
- Update usage to give example.
- Made printf of WDIOC_GETTIMEOUT distinct from WDIOC_SETTIMEOUT
- Made WDIOC_GETTIMEOUT a "one shot"
- Made printf of WDIOC_GETPRETIMEOUT disnct from WDIOC_SETPRETIMEOUT
- Made WDIOC_GETPRETIMEOUT a "one shot"
Change v3
- Printf says errno, but prints the string version of the error. Make the printf consistent.
- As above error was cut/paste from prior printf in application add new patch 1 to fix the existing printf first.
Jerry Hoemann (2): selftests: watchdog: Fix error message. selftests: watchdog: Add gettimeout and get|set pretimeout
tools/testing/selftests/watchdog/watchdog-test.c | 41 +++++++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-)
Thanks for the patches. Applied to linux-kselftest next for 4.20-rc1
btw -for future reference, the convention is [PATCH v3] not [V3 PATCH]
thanks, -- Shuah
linux-kselftest-mirror@lists.linaro.org