* [PATCH] selftests: watchdog: accept multiple params on command line
@ 2017-03-28 19:10 Timur Tabi
0 siblings, 0 replies; 6+ messages in thread
From: Timur Tabi @ 2017-03-28 19:10 UTC (permalink / raw)
To: Arnd Bergmann, Guenter Roeck, linux-watchdog, linux-arm-kernel
Watchdog drivers are not required to retain programming information,
such as timeouts, after the watchdog device is closed. Therefore,
the watchdog test should be able to perform multiple actions after
opening the watchdog device.
For example, to set the timeout to 10s and ping every 5s:
watchdog-test -t 10 -p 5 -e
Also, display the periodic decimal point only if the keep-alive call
succeeds.
Signed-off-by: Timur Tabi <timur@codeaurora.org>
---
tools/testing/selftests/watchdog/watchdog-test.c | 61 +++++++++++++-----------
1 file changed, 34 insertions(+), 27 deletions(-)
diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
index 6983d05..a74c9d7 100644
--- a/tools/testing/selftests/watchdog/watchdog-test.c
+++ b/tools/testing/selftests/watchdog/watchdog-test.c
@@ -24,9 +24,11 @@
static void keep_alive(void)
{
int dummy;
+ int ret;
- printf(".");
- ioctl(fd, WDIOC_KEEPALIVE, &dummy);
+ ret = ioctl(fd, WDIOC_KEEPALIVE, &dummy);
+ if (!ret)
+ printf(".");
}
/*
@@ -51,6 +53,7 @@ int main(int argc, char *argv[])
int flags;
unsigned int ping_rate = 1;
int ret;
+ int i;
setbuf(stdout, NULL);
@@ -61,31 +64,35 @@ int main(int argc, char *argv[])
exit(-1);
}
- if (argc > 1) {
- if (!strncasecmp(argv[1], "-d", 2)) {
- flags = WDIOS_DISABLECARD;
- ioctl(fd, WDIOC_SETOPTIONS, &flags);
- printf("Watchdog card disabled.\n");
- goto end;
- } else if (!strncasecmp(argv[1], "-e", 2)) {
- flags = WDIOS_ENABLECARD;
- ioctl(fd, WDIOC_SETOPTIONS, &flags);
- printf("Watchdog card enabled.\n");
- goto end;
- } else if (!strncasecmp(argv[1], "-t", 2) && argv[2]) {
- flags = atoi(argv[2]);
- ioctl(fd, WDIOC_SETTIMEOUT, &flags);
- printf("Watchdog timeout set to %u seconds.\n", flags);
- goto end;
- } else if (!strncasecmp(argv[1], "-p", 2) && argv[2]) {
- ping_rate = strtoul(argv[2], NULL, 0);
- printf("Watchdog ping rate set to %u seconds.\n", ping_rate);
- } else {
- printf("-d to disable, -e to enable, -t <n> to set " \
- "the timeout,\n-p <n> to set the ping rate, and \n");
- printf("run by itself to tick the card.\n");
- goto end;
- }
+ for (i = 1; i < argc; i++) {
+ if (!strncasecmp(argv[i], "-d", 2)) {
+ flags = WDIOS_DISABLECARD;
+ ret = ioctl(fd, WDIOC_SETOPTIONS, &flags);
+ if (!ret)
+ printf("Watchdog card disabled.\n");
+ } else if (!strncasecmp(argv[i], "-e", 2)) {
+ flags = WDIOS_ENABLECARD;
+ ret = ioctl(fd, WDIOC_SETOPTIONS, &flags);
+ if (!ret)
+ printf("Watchdog card enabled.\n");
+ } else if (!strncasecmp(argv[i], "-t", 2) && argv[2]) {
+ flags = atoi(argv[i + 1]);
+ ret = ioctl(fd, WDIOC_SETTIMEOUT, &flags);
+ if (!ret)
+ printf("Watchdog timeout set to %u seconds.\n", flags);
+ i++;
+ } else if (!strncasecmp(argv[i], "-p", 2) && argv[2]) {
+ ping_rate = strtoul(argv[i + 1], NULL, 0);
+ printf("Watchdog ping rate set to %u seconds.\n", ping_rate);
+ i++;
+ } else {
+ printf("-d to disable, -e to enable, -t <n> to set "
+ "the timeout,\n-p <n> to set the ping rate, and ");
+ printf("run by itself to tick the card.\n");
+ printf("Parameters are parsed left-to-right in real-time.\n");
+ printf("Example: %s -d -t 10 -p 5 -e\n", argv[0]);
+ goto end;
+ }
}
printf("Watchdog Ticking Away!\n");
--
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc. Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] selftests: watchdog: accept multiple params on command line
@ 2017-03-28 19:44 Timur Tabi
2017-04-17 1:13 ` Guenter Roeck
0 siblings, 1 reply; 6+ messages in thread
From: Timur Tabi @ 2017-03-28 19:44 UTC (permalink / raw)
To: Guenter Roeck, Arnd Bergmann, linux-kselftest, linux-watchdog
Watchdog drivers are not required to retain programming information,
such as timeouts, after the watchdog device is closed. Therefore,
the watchdog test should be able to perform multiple actions after
opening the watchdog device.
For example, to set the timeout to 10s and ping every 5s:
watchdog-test -t 10 -p 5 -e
Also, display the periodic decimal point only if the keep-alive call
succeeds.
Signed-off-by: Timur Tabi <timur@codeaurora.org>
---
tools/testing/selftests/watchdog/watchdog-test.c | 61 +++++++++++++-----------
1 file changed, 34 insertions(+), 27 deletions(-)
diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
index 6983d05..a74c9d7 100644
--- a/tools/testing/selftests/watchdog/watchdog-test.c
+++ b/tools/testing/selftests/watchdog/watchdog-test.c
@@ -24,9 +24,11 @@
static void keep_alive(void)
{
int dummy;
+ int ret;
- printf(".");
- ioctl(fd, WDIOC_KEEPALIVE, &dummy);
+ ret = ioctl(fd, WDIOC_KEEPALIVE, &dummy);
+ if (!ret)
+ printf(".");
}
/*
@@ -51,6 +53,7 @@ int main(int argc, char *argv[])
int flags;
unsigned int ping_rate = 1;
int ret;
+ int i;
setbuf(stdout, NULL);
@@ -61,31 +64,35 @@ int main(int argc, char *argv[])
exit(-1);
}
- if (argc > 1) {
- if (!strncasecmp(argv[1], "-d", 2)) {
- flags = WDIOS_DISABLECARD;
- ioctl(fd, WDIOC_SETOPTIONS, &flags);
- printf("Watchdog card disabled.\n");
- goto end;
- } else if (!strncasecmp(argv[1], "-e", 2)) {
- flags = WDIOS_ENABLECARD;
- ioctl(fd, WDIOC_SETOPTIONS, &flags);
- printf("Watchdog card enabled.\n");
- goto end;
- } else if (!strncasecmp(argv[1], "-t", 2) && argv[2]) {
- flags = atoi(argv[2]);
- ioctl(fd, WDIOC_SETTIMEOUT, &flags);
- printf("Watchdog timeout set to %u seconds.\n", flags);
- goto end;
- } else if (!strncasecmp(argv[1], "-p", 2) && argv[2]) {
- ping_rate = strtoul(argv[2], NULL, 0);
- printf("Watchdog ping rate set to %u seconds.\n", ping_rate);
- } else {
- printf("-d to disable, -e to enable, -t <n> to set " \
- "the timeout,\n-p <n> to set the ping rate, and \n");
- printf("run by itself to tick the card.\n");
- goto end;
- }
+ for (i = 1; i < argc; i++) {
+ if (!strncasecmp(argv[i], "-d", 2)) {
+ flags = WDIOS_DISABLECARD;
+ ret = ioctl(fd, WDIOC_SETOPTIONS, &flags);
+ if (!ret)
+ printf("Watchdog card disabled.\n");
+ } else if (!strncasecmp(argv[i], "-e", 2)) {
+ flags = WDIOS_ENABLECARD;
+ ret = ioctl(fd, WDIOC_SETOPTIONS, &flags);
+ if (!ret)
+ printf("Watchdog card enabled.\n");
+ } else if (!strncasecmp(argv[i], "-t", 2) && argv[2]) {
+ flags = atoi(argv[i + 1]);
+ ret = ioctl(fd, WDIOC_SETTIMEOUT, &flags);
+ if (!ret)
+ printf("Watchdog timeout set to %u seconds.\n", flags);
+ i++;
+ } else if (!strncasecmp(argv[i], "-p", 2) && argv[2]) {
+ ping_rate = strtoul(argv[i + 1], NULL, 0);
+ printf("Watchdog ping rate set to %u seconds.\n", ping_rate);
+ i++;
+ } else {
+ printf("-d to disable, -e to enable, -t <n> to set "
+ "the timeout,\n-p <n> to set the ping rate, and ");
+ printf("run by itself to tick the card.\n");
+ printf("Parameters are parsed left-to-right in real-time.\n");
+ printf("Example: %s -d -t 10 -p 5 -e\n", argv[0]);
+ goto end;
+ }
}
printf("Watchdog Ticking Away!\n");
--
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc. Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] selftests: watchdog: accept multiple params on command line
2017-03-28 19:44 [PATCH] selftests: watchdog: accept multiple params on command line Timur Tabi
@ 2017-04-17 1:13 ` Guenter Roeck
2017-05-01 18:45 ` Timur Tabi
0 siblings, 1 reply; 6+ messages in thread
From: Guenter Roeck @ 2017-04-17 1:13 UTC (permalink / raw)
To: Timur Tabi, Arnd Bergmann, linux-kselftest, linux-watchdog
On 03/28/2017 12:44 PM, Timur Tabi wrote:
> Watchdog drivers are not required to retain programming information,
> such as timeouts, after the watchdog device is closed. Therefore,
> the watchdog test should be able to perform multiple actions after
> opening the watchdog device.
>
> For example, to set the timeout to 10s and ping every 5s:
>
> watchdog-test -t 10 -p 5 -e
>
> Also, display the periodic decimal point only if the keep-alive call
> succeeds.
>
> Signed-off-by: Timur Tabi <timur@codeaurora.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> tools/testing/selftests/watchdog/watchdog-test.c | 61 +++++++++++++-----------
> 1 file changed, 34 insertions(+), 27 deletions(-)
>
> diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
> index 6983d05..a74c9d7 100644
> --- a/tools/testing/selftests/watchdog/watchdog-test.c
> +++ b/tools/testing/selftests/watchdog/watchdog-test.c
> @@ -24,9 +24,11 @@
> static void keep_alive(void)
> {
> int dummy;
> + int ret;
>
> - printf(".");
> - ioctl(fd, WDIOC_KEEPALIVE, &dummy);
> + ret = ioctl(fd, WDIOC_KEEPALIVE, &dummy);
> + if (!ret)
> + printf(".");
> }
>
> /*
> @@ -51,6 +53,7 @@ int main(int argc, char *argv[])
> int flags;
> unsigned int ping_rate = 1;
> int ret;
> + int i;
>
> setbuf(stdout, NULL);
>
> @@ -61,31 +64,35 @@ int main(int argc, char *argv[])
> exit(-1);
> }
>
> - if (argc > 1) {
> - if (!strncasecmp(argv[1], "-d", 2)) {
> - flags = WDIOS_DISABLECARD;
> - ioctl(fd, WDIOC_SETOPTIONS, &flags);
> - printf("Watchdog card disabled.\n");
> - goto end;
> - } else if (!strncasecmp(argv[1], "-e", 2)) {
> - flags = WDIOS_ENABLECARD;
> - ioctl(fd, WDIOC_SETOPTIONS, &flags);
> - printf("Watchdog card enabled.\n");
> - goto end;
> - } else if (!strncasecmp(argv[1], "-t", 2) && argv[2]) {
> - flags = atoi(argv[2]);
> - ioctl(fd, WDIOC_SETTIMEOUT, &flags);
> - printf("Watchdog timeout set to %u seconds.\n", flags);
> - goto end;
> - } else if (!strncasecmp(argv[1], "-p", 2) && argv[2]) {
> - ping_rate = strtoul(argv[2], NULL, 0);
> - printf("Watchdog ping rate set to %u seconds.\n", ping_rate);
> - } else {
> - printf("-d to disable, -e to enable, -t <n> to set " \
> - "the timeout,\n-p <n> to set the ping rate, and \n");
> - printf("run by itself to tick the card.\n");
> - goto end;
> - }
> + for (i = 1; i < argc; i++) {
> + if (!strncasecmp(argv[i], "-d", 2)) {
> + flags = WDIOS_DISABLECARD;
> + ret = ioctl(fd, WDIOC_SETOPTIONS, &flags);
> + if (!ret)
> + printf("Watchdog card disabled.\n");
> + } else if (!strncasecmp(argv[i], "-e", 2)) {
> + flags = WDIOS_ENABLECARD;
> + ret = ioctl(fd, WDIOC_SETOPTIONS, &flags);
> + if (!ret)
> + printf("Watchdog card enabled.\n");
> + } else if (!strncasecmp(argv[i], "-t", 2) && argv[2]) {
> + flags = atoi(argv[i + 1]);
> + ret = ioctl(fd, WDIOC_SETTIMEOUT, &flags);
> + if (!ret)
> + printf("Watchdog timeout set to %u seconds.\n", flags);
> + i++;
> + } else if (!strncasecmp(argv[i], "-p", 2) && argv[2]) {
> + ping_rate = strtoul(argv[i + 1], NULL, 0);
> + printf("Watchdog ping rate set to %u seconds.\n", ping_rate);
> + i++;
> + } else {
> + printf("-d to disable, -e to enable, -t <n> to set "
> + "the timeout,\n-p <n> to set the ping rate, and ");
> + printf("run by itself to tick the card.\n");
> + printf("Parameters are parsed left-to-right in real-time.\n");
> + printf("Example: %s -d -t 10 -p 5 -e\n", argv[0]);
> + goto end;
> + }
> }
>
> printf("Watchdog Ticking Away!\n");
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] selftests: watchdog: accept multiple params on command line
2017-04-17 1:13 ` Guenter Roeck
@ 2017-05-01 18:45 ` Timur Tabi
2017-05-01 19:15 ` Shuah Khan
0 siblings, 1 reply; 6+ messages in thread
From: Timur Tabi @ 2017-05-01 18:45 UTC (permalink / raw)
To: linux-kselftest, shuahkh; +Cc: Arnd Bergmann, linux-watchdog, Guenter Roeck
On Sun, Apr 16, 2017 at 8:13 PM, Guenter Roeck <linux@roeck-us.net> wrote:
>
>> Watchdog drivers are not required to retain programming information,
>> such as timeouts, after the watchdog device is closed. Therefore,
>> the watchdog test should be able to perform multiple actions after
>> opening the watchdog device.
>>
>> For example, to set the timeout to 10s and ping every 5s:
>>
>> watchdog-test -t 10 -p 5 -e
>>
>> Also, display the periodic decimal point only if the keep-alive call
>> succeeds.
>>
>> Signed-off-by: Timur Tabi <timur@codeaurora.org>
>
>
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Any chance of getting this into 4.12?
--
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] selftests: watchdog: accept multiple params on command line
2017-05-01 18:45 ` Timur Tabi
@ 2017-05-01 19:15 ` Shuah Khan
2017-05-01 19:24 ` Timur Tabi
0 siblings, 1 reply; 6+ messages in thread
From: Shuah Khan @ 2017-05-01 19:15 UTC (permalink / raw)
To: Timur Tabi, linux-kselftest
Cc: Arnd Bergmann, linux-watchdog, Guenter Roeck, Shuah Khan
On 05/01/2017 12:45 PM, Timur Tabi wrote:
> On Sun, Apr 16, 2017 at 8:13 PM, Guenter Roeck <linux@roeck-us.net> wrote:
>>
>>> Watchdog drivers are not required to retain programming information,
>>> such as timeouts, after the watchdog device is closed. Therefore,
>>> the watchdog test should be able to perform multiple actions after
>>> opening the watchdog device.
>>>
>>> For example, to set the timeout to 10s and ping every 5s:
>>>
>>> watchdog-test -t 10 -p 5 -e
>>>
>>> Also, display the periodic decimal point only if the keep-alive call
>>> succeeds.
>>>
>>> Signed-off-by: Timur Tabi <timur@codeaurora.org>
>>
>>
>> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
>
> Any chance of getting this into 4.12?
>
Hi Timur,
I can't find the patch in my Inbox. Could you please send it to me.
I can get this into 4.12-rc1
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] selftests: watchdog: accept multiple params on command line
2017-05-01 19:15 ` Shuah Khan
@ 2017-05-01 19:24 ` Timur Tabi
0 siblings, 0 replies; 6+ messages in thread
From: Timur Tabi @ 2017-05-01 19:24 UTC (permalink / raw)
To: Shuah Khan, linux-kselftest; +Cc: Arnd Bergmann, linux-watchdog, Guenter Roeck
On 05/01/2017 02:15 PM, Shuah Khan wrote:
> I can't find the patch in my Inbox. Could you please send it to me.
> I can get this into 4.12-rc1
Done. get_maintainers told me to use shuah@kernel.org, so I hope that's correct.
--
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc. Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-05-01 19:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-28 19:44 [PATCH] selftests: watchdog: accept multiple params on command line Timur Tabi
2017-04-17 1:13 ` Guenter Roeck
2017-05-01 18:45 ` Timur Tabi
2017-05-01 19:15 ` Shuah Khan
2017-05-01 19:24 ` Timur Tabi
-- strict thread matches above, loose matches on Subject: below --
2017-03-28 19:10 Timur Tabi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).