linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] selftests: watchdog: Validate optional file argument
@ 2019-09-07  8:58 Eugeniu Rosca
  2019-09-07  8:58 ` [PATCH 2/2] selftests: watchdog: Add command line option to show watchdog_info Eugeniu Rosca
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Eugeniu Rosca @ 2019-09-07  8:58 UTC (permalink / raw)
  To: Shuah Khan, George G. Davis, Jerry Hoemann, Colin Ian King,
	linux-kselftest, linux-kernel
  Cc: Eugeniu Rosca, Eugeniu Rosca

From: "George G. Davis" <george_davis@mentor.com>

As reported by Eugeniu Rosca, the newly added optional file
argument does not validate if the file is indeed a watchdog, e.g.:

./watchdog-test  -f /dev/zero
Watchdog Ticking Away!

Fix it by confirming that the WDIOC_GETSUPPORT ioctl succeeds.

Reported-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Signed-off-by: George G. Davis <george_davis@mentor.com>
Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
---
v1: Applied/tested on commit ce54eab71e210f ("kunit: fix failure to build without printk") of
    https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/log/?h=next

 tools/testing/selftests/watchdog/watchdog-test.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
index afff120c7be6..6ed822dc2222 100644
--- a/tools/testing/selftests/watchdog/watchdog-test.c
+++ b/tools/testing/selftests/watchdog/watchdog-test.c
@@ -97,6 +97,7 @@ int main(int argc, char *argv[])
 	int c;
 	int oneshot = 0;
 	char *file = "/dev/watchdog";
+	struct watchdog_info info;
 
 	setbuf(stdout, NULL);
 
@@ -118,6 +119,16 @@ int main(int argc, char *argv[])
 		exit(-1);
 	}
 
+	/*
+	 * Validate that `file` is a watchdog device
+	 */
+	ret = ioctl(fd, WDIOC_GETSUPPORT, &info);
+	if (ret) {
+		printf("WDIOC_GETSUPPORT error '%s'\n", strerror(errno));
+		close(fd);
+		exit(ret);
+	}
+
 	optind = 0;
 
 	while ((c = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/2] selftests: watchdog: Add command line option to show watchdog_info
  2019-09-07  8:58 [PATCH 1/2] selftests: watchdog: Validate optional file argument Eugeniu Rosca
@ 2019-09-07  8:58 ` Eugeniu Rosca
  2019-09-16 13:26   ` shuah
  2019-09-16 12:08 ` [PATCH 1/2] selftests: watchdog: Validate optional file argument Eugeniu Rosca
  2019-09-16 13:25 ` shuah
  2 siblings, 1 reply; 12+ messages in thread
From: Eugeniu Rosca @ 2019-09-07  8:58 UTC (permalink / raw)
  To: Shuah Khan, George G. Davis, Jerry Hoemann, Colin Ian King,
	linux-kselftest, linux-kernel
  Cc: Eugeniu Rosca, Eugeniu Rosca

From: "George G. Davis" <george_davis@mentor.com>

A side of affect of commit "selftests: watchdog: Add optional file
argument" is that arbitrary files may be opened for watchdog testing, e.g.
/dev/null. To prevent watchdog-test from operating on non-watchdog device
files, commit "selftests: watchdog: Validate optional file argument" was
added to validate that a file is indeed a watchdog device via an
ioctl(WDIOC_GETSUPPORT) call. Since the watchdog_info is available as a
result of the ioctl(WDIOC_GETSUPPORT) call, add a command line option to
show the watchdog_info.

Suggested-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Signed-off-by: George G. Davis <george_davis@mentor.com>
Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
---
v1: Applied/tested on commit ce54eab71e210f ("kunit: fix failure to build without printk") of 
    https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/log/?h=next

 tools/testing/selftests/watchdog/watchdog-test.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
index 6ed822dc2222..f45e510500c0 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:Tn:NLf:";
+static const char sopts[] = "bdehp:t:Tn:NLf:i";
 static const struct option lopts[] = {
 	{"bootstatus",          no_argument, NULL, 'b'},
 	{"disable",             no_argument, NULL, 'd'},
@@ -32,6 +32,7 @@ static const struct option lopts[] = {
 	{"getpretimeout",       no_argument, NULL, 'N'},
 	{"gettimeleft",		no_argument, NULL, 'L'},
 	{"file",          required_argument, NULL, 'f'},
+	{"info",		no_argument, NULL, 'i'},
 	{NULL,                  no_argument, NULL, 0x0}
 };
 
@@ -72,6 +73,7 @@ static void usage(char *progname)
 	printf("Usage: %s [options]\n", progname);
 	printf(" -f, --file\t\tOpen watchdog device file\n");
 	printf("\t\t\tDefault is /dev/watchdog\n");
+	printf(" -i, --info\t\tShow watchdog_info\n");
 	printf(" -b, --bootstatus\tGet last boot status (Watchdog/POR)\n");
 	printf(" -d, --disable\t\tTurn off the watchdog timer\n");
 	printf(" -e, --enable\t\tTurn on the watchdog timer\n");
@@ -216,6 +218,18 @@ int main(int argc, char *argv[])
 		case 'f':
 			/* Handled above */
 			break;
+		case 'i':
+			/*
+			 * watchdog_info was obtained as part of file open
+			 * validation. So we just show it here.
+			 */
+			oneshot = 1;
+			printf("watchdog_info:\n");
+			printf(" identity:\t\t%s\n", info.identity);
+			printf(" firmware_version:\t%u\n",
+			       info.firmware_version);
+			printf(" options:\t\t%08x\n", info.options);
+			break;
 
 		default:
 			usage(argv[0]);
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] selftests: watchdog: Validate optional file argument
  2019-09-07  8:58 [PATCH 1/2] selftests: watchdog: Validate optional file argument Eugeniu Rosca
  2019-09-07  8:58 ` [PATCH 2/2] selftests: watchdog: Add command line option to show watchdog_info Eugeniu Rosca
@ 2019-09-16 12:08 ` Eugeniu Rosca
  2019-09-16 13:29   ` shuah
  2019-09-16 13:25 ` shuah
  2 siblings, 1 reply; 12+ messages in thread
From: Eugeniu Rosca @ 2019-09-16 12:08 UTC (permalink / raw)
  To: Shuah Khan
  Cc: George G. Davis, Jerry Hoemann, Colin Ian King, linux-kselftest,
	linux-kernel, Eugeniu Rosca, Eugeniu Rosca

Hi Shuah,

On Sat, Sep 07, 2019 at 10:58:32AM +0200, Eugeniu Rosca wrote:
> From: "George G. Davis" <george_davis@mentor.com>
> 
> As reported by Eugeniu Rosca, the newly added optional file
> argument does not validate if the file is indeed a watchdog, e.g.:
> 
> ./watchdog-test  -f /dev/zero
> Watchdog Ticking Away!
> 
> Fix it by confirming that the WDIOC_GETSUPPORT ioctl succeeds.
> 
> Reported-by: Eugeniu Rosca <erosca@de.adit-jv.com>
> Signed-off-by: George G. Davis <george_davis@mentor.com>
> Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
> ---
> v1: Applied/tested on commit ce54eab71e210f ("kunit: fix failure to build without printk") of
>     https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/log/?h=next

Any concerns about the two patches?
Can you please confirm they are in your queue?

-- 
Best Regards,
Eugeniu.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] selftests: watchdog: Validate optional file argument
  2019-09-07  8:58 [PATCH 1/2] selftests: watchdog: Validate optional file argument Eugeniu Rosca
  2019-09-07  8:58 ` [PATCH 2/2] selftests: watchdog: Add command line option to show watchdog_info Eugeniu Rosca
  2019-09-16 12:08 ` [PATCH 1/2] selftests: watchdog: Validate optional file argument Eugeniu Rosca
@ 2019-09-16 13:25 ` shuah
  2 siblings, 0 replies; 12+ messages in thread
From: shuah @ 2019-09-16 13:25 UTC (permalink / raw)
  To: Eugeniu Rosca, George G. Davis, Jerry Hoemann, Colin Ian King,
	linux-kselftest, linux-kernel
  Cc: Eugeniu Rosca, shuah

On 9/7/19 2:58 AM, Eugeniu Rosca wrote:
> From: "George G. Davis" <george_davis@mentor.com>
> 
> As reported by Eugeniu Rosca, the newly added optional file
> argument does not validate if the file is indeed a watchdog, e.g.:
> 
> ./watchdog-test  -f /dev/zero
> Watchdog Ticking Away!
> 
> Fix it by confirming that the WDIOC_GETSUPPORT ioctl succeeds.
> 
> Reported-by: Eugeniu Rosca <erosca@de.adit-jv.com>
> Signed-off-by: George G. Davis <george_davis@mentor.com>
> Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
> ---
> v1: Applied/tested on commit ce54eab71e210f ("kunit: fix failure to build without printk") of
>      https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/log/?h=next
> 
>   tools/testing/selftests/watchdog/watchdog-test.c | 11 +++++++++++
>   1 file changed, 11 insertions(+)
> 
> diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
> index afff120c7be6..6ed822dc2222 100644
> --- a/tools/testing/selftests/watchdog/watchdog-test.c
> +++ b/tools/testing/selftests/watchdog/watchdog-test.c
> @@ -97,6 +97,7 @@ int main(int argc, char *argv[])
>   	int c;
>   	int oneshot = 0;
>   	char *file = "/dev/watchdog";
> +	struct watchdog_info info;
>   
>   	setbuf(stdout, NULL);
>   
> @@ -118,6 +119,16 @@ int main(int argc, char *argv[])
>   		exit(-1);
>   	}
>   
> +	/*
> +	 * Validate that `file` is a watchdog device
> +	 */
> +	ret = ioctl(fd, WDIOC_GETSUPPORT, &info);
> +	if (ret) {
> +		printf("WDIOC_GETSUPPORT error '%s'\n", strerror(errno));
> +		close(fd);
> +		exit(ret);
> +	}
> +
>   	optind = 0;
>   
>   	while ((c = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
> 

Thanks for catching this. I will pull this in for second update for
5.4-rc1.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] selftests: watchdog: Add command line option to show watchdog_info
  2019-09-07  8:58 ` [PATCH 2/2] selftests: watchdog: Add command line option to show watchdog_info Eugeniu Rosca
@ 2019-09-16 13:26   ` shuah
  2019-09-16 13:55     ` George G. Davis
  2019-09-16 13:57     ` Eugeniu Rosca
  0 siblings, 2 replies; 12+ messages in thread
From: shuah @ 2019-09-16 13:26 UTC (permalink / raw)
  To: Eugeniu Rosca, George G. Davis, Jerry Hoemann, Colin Ian King,
	linux-kselftest, linux-kernel
  Cc: Eugeniu Rosca, shuah

On 9/7/19 2:58 AM, Eugeniu Rosca wrote:
> From: "George G. Davis" <george_davis@mentor.com>
> 
> A side of affect of commit "selftests: watchdog: Add optional file
> argument" is that arbitrary files may be opened for watchdog testing, e.g.
> /dev/null. To prevent watchdog-test from operating on non-watchdog device
> files, commit "selftests: watchdog: Validate optional file argument" was
> added to validate that a file is indeed a watchdog device via an
> ioctl(WDIOC_GETSUPPORT) call. Since the watchdog_info is available as a
> result of the ioctl(WDIOC_GETSUPPORT) call, add a command line option to
> show the watchdog_info.
> 
> Suggested-by: Eugeniu Rosca <erosca@de.adit-jv.com>
> Signed-off-by: George G. Davis <george_davis@mentor.com>
> Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
> ---
> v1: Applied/tested on commit ce54eab71e210f ("kunit: fix failure to build without printk") of
>      https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/log/?h=next
> 
>   tools/testing/selftests/watchdog/watchdog-test.c | 16 +++++++++++++++-
>   1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
> index 6ed822dc2222..f45e510500c0 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:Tn:NLf:";
> +static const char sopts[] = "bdehp:t:Tn:NLf:i";
>   static const struct option lopts[] = {
>   	{"bootstatus",          no_argument, NULL, 'b'},
>   	{"disable",             no_argument, NULL, 'd'},
> @@ -32,6 +32,7 @@ static const struct option lopts[] = {
>   	{"getpretimeout",       no_argument, NULL, 'N'},
>   	{"gettimeleft",		no_argument, NULL, 'L'},
>   	{"file",          required_argument, NULL, 'f'},
> +	{"info",		no_argument, NULL, 'i'},
>   	{NULL,                  no_argument, NULL, 0x0}
>   };
>   
> @@ -72,6 +73,7 @@ static void usage(char *progname)
>   	printf("Usage: %s [options]\n", progname);
>   	printf(" -f, --file\t\tOpen watchdog device file\n");
>   	printf("\t\t\tDefault is /dev/watchdog\n");
> +	printf(" -i, --info\t\tShow watchdog_info\n");
>   	printf(" -b, --bootstatus\tGet last boot status (Watchdog/POR)\n");
>   	printf(" -d, --disable\t\tTurn off the watchdog timer\n");
>   	printf(" -e, --enable\t\tTurn on the watchdog timer\n");
> @@ -216,6 +218,18 @@ int main(int argc, char *argv[])
>   		case 'f':
>   			/* Handled above */
>   			break;
> +		case 'i':
> +			/*
> +			 * watchdog_info was obtained as part of file open
> +			 * validation. So we just show it here.
> +			 */
> +			oneshot = 1;
> +			printf("watchdog_info:\n");
> +			printf(" identity:\t\t%s\n", info.identity);
> +			printf(" firmware_version:\t%u\n",
> +			       info.firmware_version);
> +			printf(" options:\t\t%08x\n", info.options);
> +			break;
>   
>   		default:
>   			usage(argv[0]);
> 

I would like to see these combined. Please don't add another argument.
Combine patch and 1&2.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] selftests: watchdog: Validate optional file argument
  2019-09-16 12:08 ` [PATCH 1/2] selftests: watchdog: Validate optional file argument Eugeniu Rosca
@ 2019-09-16 13:29   ` shuah
  2019-09-17 18:55     ` Eugeniu Rosca
  0 siblings, 1 reply; 12+ messages in thread
From: shuah @ 2019-09-16 13:29 UTC (permalink / raw)
  To: Eugeniu Rosca
  Cc: George G. Davis, Jerry Hoemann, Colin Ian King, linux-kselftest,
	linux-kernel, Eugeniu Rosca, shuah

On 9/16/19 6:08 AM, Eugeniu Rosca wrote:
> Hi Shuah,
> 
> On Sat, Sep 07, 2019 at 10:58:32AM +0200, Eugeniu Rosca wrote:
>> From: "George G. Davis" <george_davis@mentor.com>
>>
>> As reported by Eugeniu Rosca, the newly added optional file
>> argument does not validate if the file is indeed a watchdog, e.g.:
>>
>> ./watchdog-test  -f /dev/zero
>> Watchdog Ticking Away!
>>
>> Fix it by confirming that the WDIOC_GETSUPPORT ioctl succeeds.
>>
>> Reported-by: Eugeniu Rosca <erosca@de.adit-jv.com>
>> Signed-off-by: George G. Davis <george_davis@mentor.com>
>> Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
>> ---
>> v1: Applied/tested on commit ce54eab71e210f ("kunit: fix failure to build without printk") of
>>      https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/log/?h=next
> 
> Any concerns about the two patches?
I responded to the patches as well.

> Can you please confirm they are in your queue?
> 

I just sent response. Please collapse the two patches. They will go in
for 5.4-rc1 second update.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] selftests: watchdog: Add command line option to show watchdog_info
  2019-09-16 13:26   ` shuah
@ 2019-09-16 13:55     ` George G. Davis
  2019-09-16 13:57     ` Eugeniu Rosca
  1 sibling, 0 replies; 12+ messages in thread
From: George G. Davis @ 2019-09-16 13:55 UTC (permalink / raw)
  To: shuah
  Cc: Eugeniu Rosca, Jerry Hoemann, Colin Ian King, linux-kselftest,
	linux-kernel, Eugeniu Rosca

Hello,

On Mon, Sep 16, 2019 at 07:26:41AM -0600, shuah wrote:
> On 9/7/19 2:58 AM, Eugeniu Rosca wrote:
> >diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
> >index 6ed822dc2222..f45e510500c0 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:Tn:NLf:";
> >+static const char sopts[] = "bdehp:t:Tn:NLf:i";
> >  static const struct option lopts[] = {
> >  	{"bootstatus",          no_argument, NULL, 'b'},
> >  	{"disable",             no_argument, NULL, 'd'},
> >@@ -32,6 +32,7 @@ static const struct option lopts[] = {
> >  	{"getpretimeout",       no_argument, NULL, 'N'},
> >  	{"gettimeleft",		no_argument, NULL, 'L'},
> >  	{"file",          required_argument, NULL, 'f'},
> >+	{"info",		no_argument, NULL, 'i'},
> >  	{NULL,                  no_argument, NULL, 0x0}
> >  };
> >@@ -72,6 +73,7 @@ static void usage(char *progname)
> >  	printf("Usage: %s [options]\n", progname);
> >  	printf(" -f, --file\t\tOpen watchdog device file\n");
> >  	printf("\t\t\tDefault is /dev/watchdog\n");
> >+	printf(" -i, --info\t\tShow watchdog_info\n");
> >  	printf(" -b, --bootstatus\tGet last boot status (Watchdog/POR)\n");
> >  	printf(" -d, --disable\t\tTurn off the watchdog timer\n");
> >  	printf(" -e, --enable\t\tTurn on the watchdog timer\n");
> >@@ -216,6 +218,18 @@ int main(int argc, char *argv[])
> >  		case 'f':
> >  			/* Handled above */
> >  			break;
> >+		case 'i':
> >+			/*
> >+			 * watchdog_info was obtained as part of file open
> >+			 * validation. So we just show it here.
> >+			 */
> >+			oneshot = 1;
> >+			printf("watchdog_info:\n");
> >+			printf(" identity:\t\t%s\n", info.identity);
> >+			printf(" firmware_version:\t%u\n",
> >+			       info.firmware_version);
> >+			printf(" options:\t\t%08x\n", info.options);
> >+			break;
> >  		default:
> >  			usage(argv[0]);
> >
> 
> I would like to see these combined.

Ok.

> Please don't add another argument.

I'm not clear on your request here. Do you want to drop the addition
of optional --info|-i command line option and always display the
watchdog_info?

If yes, perhaps Eugeniu may mention what he has already mentioned to me earlier
that "it's very useful to see the watchdog identity" but "some users might
perceive the console output a bit busy if the Watchdog identity: <WDT name>
message is always on" so perhaps it is "more user-friendly to still call the
WDIOC_GETSUPPORT ioctl to sanitize the device file, but to only print the
Watchdog identity: message when the user passes e.g. a new -i, --identity
parameter".


> Combine patch and 1&2.

I'll do that but I'm not entirely clear on your "Please don't add another
argument" request.

> 
> thanks,
> -- Shuah

-- 
Regards,
George

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] selftests: watchdog: Add command line option to show watchdog_info
  2019-09-16 13:26   ` shuah
  2019-09-16 13:55     ` George G. Davis
@ 2019-09-16 13:57     ` Eugeniu Rosca
  2019-09-16 16:05       ` shuah
  1 sibling, 1 reply; 12+ messages in thread
From: Eugeniu Rosca @ 2019-09-16 13:57 UTC (permalink / raw)
  To: shuah
  Cc: Eugeniu Rosca, George G. Davis, Jerry Hoemann, Colin Ian King,
	linux-kselftest, linux-kernel, Eugeniu Rosca

Hi Shuah,
CC George

On Mon, Sep 16, 2019 at 07:26:41AM -0600, shuah wrote:
[..]
> >   		case 'f':
> >   			/* Handled above */
> >   			break;
> > +		case 'i':
> > +			/*
> > +			 * watchdog_info was obtained as part of file open
> > +			 * validation. So we just show it here.
> > +			 */
> > +			oneshot = 1;
> > +			printf("watchdog_info:\n");
> > +			printf(" identity:\t\t%s\n", info.identity);
> > +			printf(" firmware_version:\t%u\n",
> > +			       info.firmware_version);
> > +			printf(" options:\t\t%08x\n", info.options);
> > +			break;
> >   		default:
> >   			usage(argv[0]);
> > 
> 
> I would like to see these combined. Please don't add another argument.
> Combine patch and 1&2.

With all my appreciation for your comment, why do you think it is better
to get rid of the new argument? I don't think it is user-friendly to
always report the watchdog_info to the user. Just look at outputs [1-2]
and imagine that the watchdog_info part would pop up unconditionally.
It looks too busy to me.

[1] watchdog-test -b -i
Last boot is caused by: Power-On-Reset.
watchdog_info:
 identity:              Renesas WDT Watchdog
 firmware_version:      0
 options:               000081a0

[2] watchdog-test -i --help    
watchdog_info:
 identity:              Renesas WDT Watchdog
 firmware_version:      0
 options:               000081a0
Usage: ./watchdog-test [options]
 -f, --file             Open watchdog device file
                        Default is /dev/watchdog
 -i, --info             Show watchdog_info
 -b, --bootstatus       Get last boot status (Watchdog/POR)
 -d, --disable          Turn off the watchdog timer
 -e, --enable           Turn on the watchdog timer
 -h, --help             Print the help message
 -p, --pingrate=P       Set ping rate to P seconds (default 1)
 -t, --timeout=T        Set timeout to T seconds
 -T, --gettimeout       Get the timeout
 -n, --pretimeout=T     Set the pretimeout to T seconds
 -N, --getpretimeout    Get the pretimeout
 -L, --gettimeleft      Get the time left until timer expires

Parameters are parsed left-to-right in real-time.
Example: ./watchdog-test -d -t 10 -p 5 -e
Example: ./watchdog-test -t 12 -T -n 7 -N

-- 
Best Regards,
Eugeniu.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] selftests: watchdog: Add command line option to show watchdog_info
  2019-09-16 13:57     ` Eugeniu Rosca
@ 2019-09-16 16:05       ` shuah
  2019-09-16 16:15         ` George G. Davis
  0 siblings, 1 reply; 12+ messages in thread
From: shuah @ 2019-09-16 16:05 UTC (permalink / raw)
  To: Eugeniu Rosca
  Cc: Eugeniu Rosca, George G. Davis, Jerry Hoemann, Colin Ian King,
	linux-kselftest, linux-kernel, shuah

On 9/16/19 7:57 AM, Eugeniu Rosca wrote:
> Hi Shuah,
> CC George
> 
> On Mon, Sep 16, 2019 at 07:26:41AM -0600, shuah wrote:
> [..]
>>>    		case 'f':
>>>    			/* Handled above */
>>>    			break;
>>> +		case 'i':
>>> +			/*
>>> +			 * watchdog_info was obtained as part of file open
>>> +			 * validation. So we just show it here.
>>> +			 */
>>> +			oneshot = 1;
>>> +			printf("watchdog_info:\n");
>>> +			printf(" identity:\t\t%s\n", info.identity);
>>> +			printf(" firmware_version:\t%u\n",
>>> +			       info.firmware_version);
>>> +			printf(" options:\t\t%08x\n", info.options);
>>> +			break;
>>>    		default:
>>>    			usage(argv[0]);
>>>
>>
>> I would like to see these combined. Please don't add another argument.
>> Combine patch and 1&2.
> 
> With all my appreciation for your comment, why do you think it is better
> to get rid of the new argument? I don't think it is user-friendly to
> always report the watchdog_info to the user. Just look at outputs [1-2]
> and imagine that the watchdog_info part would pop up unconditionally.
> It looks too busy to me.

Yes it does look busy. I am okay with adding a second options
based on what you both said.

I don't like the commit log.

Unfortunately this thread no longer contains the commit log.

I would like to see the commit log without any references to side
effects. It make it rather confusing.

"A side of affect of commit "selftests: watchdog: Add optional file
argument" is that arbitrary files may be opened for watchdog testing, e.g.
/dev/null. To prevent watchdog-test from operating on non-watchdog device
files, commit "selftests: watchdog: Validate optional file argument" was
added to validate that a file is indeed a watchdog device via an
ioctl(WDIOC_GETSUPPORT) call. Since the watchdog_info is available as a
result of the ioctl(WDIOC_GETSUPPORT) call, add a command line option to
show the watchdog_info."

I would drop all references to that.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] selftests: watchdog: Add command line option to show watchdog_info
  2019-09-16 16:05       ` shuah
@ 2019-09-16 16:15         ` George G. Davis
  2019-09-17 18:53           ` Eugeniu Rosca
  0 siblings, 1 reply; 12+ messages in thread
From: George G. Davis @ 2019-09-16 16:15 UTC (permalink / raw)
  To: shuah
  Cc: Eugeniu Rosca, Eugeniu Rosca, Jerry Hoemann, Colin Ian King,
	linux-kselftest, linux-kernel

Hello Shuah,

On Mon, Sep 16, 2019 at 10:05:17AM -0600, shuah wrote:
> On 9/16/19 7:57 AM, Eugeniu Rosca wrote:
> >Hi Shuah,
> >CC George
> >
> >On Mon, Sep 16, 2019 at 07:26:41AM -0600, shuah wrote:
> >[..]
> >>>   		case 'f':
> >>>   			/* Handled above */
> >>>   			break;
> >>>+		case 'i':
> >>>+			/*
> >>>+			 * watchdog_info was obtained as part of file open
> >>>+			 * validation. So we just show it here.
> >>>+			 */
> >>>+			oneshot = 1;
> >>>+			printf("watchdog_info:\n");
> >>>+			printf(" identity:\t\t%s\n", info.identity);
> >>>+			printf(" firmware_version:\t%u\n",
> >>>+			       info.firmware_version);
> >>>+			printf(" options:\t\t%08x\n", info.options);
> >>>+			break;
> >>>   		default:
> >>>   			usage(argv[0]);
> >>>
> >>
> >>I would like to see these combined. Please don't add another argument.
> >>Combine patch and 1&2.
> >
> >With all my appreciation for your comment, why do you think it is better
> >to get rid of the new argument? I don't think it is user-friendly to
> >always report the watchdog_info to the user. Just look at outputs [1-2]
> >and imagine that the watchdog_info part would pop up unconditionally.
> >It looks too busy to me.
> 
> Yes it does look busy. I am okay with adding a second options
> based on what you both said.
> 
> I don't like the commit log.

Agreed, I didn't like it either - it was rather a draft.

> 
> Unfortunately this thread no longer contains the commit log.
> 
> I would like to see the commit log without any references to side
> effects. It make it rather confusing.
> 
> "A side of affect of commit "selftests: watchdog: Add optional file
> argument" is that arbitrary files may be opened for watchdog testing, e.g.
> /dev/null. To prevent watchdog-test from operating on non-watchdog device
> files, commit "selftests: watchdog: Validate optional file argument" was
> added to validate that a file is indeed a watchdog device via an
> ioctl(WDIOC_GETSUPPORT) call. Since the watchdog_info is available as a
> result of the ioctl(WDIOC_GETSUPPORT) call, add a command line option to
> show the watchdog_info."
> 
> I would drop all references to that.

How about the following commit message for the squash commit for [1] and [2]?:

"
selftests: watchdog: Validate optional file argument

As reported by Eugeniu Rosca, a side of affect of commit c3f2490d6e92
("selftests: watchdog: Add optional file argument") is that arbitrary files
may be opened for watchdog testing, e.g.

./watchdog-test  -f /dev/zero
Watchdog Ticking Away!

To prevent watchdog-test from operating on non-watchdog device files,
validate that a file is indeed a watchdog device via an
ioctl(WDIOC_GETSUPPORT) call.

While we're at it, since the watchdog_info is available as a result of the
ioctl(WDIOC_GETSUPPORT) call, add a command line option to optionally show
the watchdog_info.
"

Thanks!


> 
> thanks,
> -- Shuah

-- 
Regards,
George

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] selftests: watchdog: Add command line option to show watchdog_info
  2019-09-16 16:15         ` George G. Davis
@ 2019-09-17 18:53           ` Eugeniu Rosca
  0 siblings, 0 replies; 12+ messages in thread
From: Eugeniu Rosca @ 2019-09-17 18:53 UTC (permalink / raw)
  To: George G. Davis, shuah, Eugeniu Rosca, Eugeniu Rosca,
	Jerry Hoemann, Colin Ian King, linux-kselftest, linux-kernel

(For LKML readability) Superseded by:
 - https://patchwork.kernel.org/patch/11149289/
   ("[v3,2/2] selftests: watchdog: Add command line option to show watchdog_info")

-- 
Best Regards,
Eugeniu.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] selftests: watchdog: Validate optional file argument
  2019-09-16 13:29   ` shuah
@ 2019-09-17 18:55     ` Eugeniu Rosca
  0 siblings, 0 replies; 12+ messages in thread
From: Eugeniu Rosca @ 2019-09-17 18:55 UTC (permalink / raw)
  To: shuah, Eugeniu Rosca, George G. Davis, Jerry Hoemann,
	Colin Ian King, linux-kselftest, linux-kernel, Eugeniu Rosca

(For LKML readability) Superseded by:
 - https://patchwork.kernel.org/patch/11149287/
   ("[v3,1/2] selftests: watchdog: Validate optional file argument")

-- 
Best Regards,
Eugeniu.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-09-17 18:55 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-07  8:58 [PATCH 1/2] selftests: watchdog: Validate optional file argument Eugeniu Rosca
2019-09-07  8:58 ` [PATCH 2/2] selftests: watchdog: Add command line option to show watchdog_info Eugeniu Rosca
2019-09-16 13:26   ` shuah
2019-09-16 13:55     ` George G. Davis
2019-09-16 13:57     ` Eugeniu Rosca
2019-09-16 16:05       ` shuah
2019-09-16 16:15         ` George G. Davis
2019-09-17 18:53           ` Eugeniu Rosca
2019-09-16 12:08 ` [PATCH 1/2] selftests: watchdog: Validate optional file argument Eugeniu Rosca
2019-09-16 13:29   ` shuah
2019-09-17 18:55     ` Eugeniu Rosca
2019-09-16 13:25 ` shuah

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).