linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/2] selftests: watchdog: Validate optional file argument
@ 2019-09-17 18:40 Eugeniu Rosca
  2019-09-17 18:40 ` [PATCH v3 2/2] selftests: watchdog: Add command line option to show watchdog_info Eugeniu Rosca
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Eugeniu Rosca @ 2019-09-17 18:40 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>

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.

Fixes: c3f2490d6e9257 ("selftests: watchdog: Add optional file argument")
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>
---
v3:
 - Used v1 as starting point and simplified commit description
 - Added Fixes tag (WARNING: commit id is from linux-next!)
 - No change in the contents
 - Applied cleanly to the same base as used in [v1]
v2:
 - https://patchwork.kernel.org/patch/11147663/
v1:
 - https://patchwork.kernel.org/patch/11136283/
 - 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] 7+ messages in thread

* [PATCH v3 2/2] selftests: watchdog: Add command line option to show watchdog_info
  2019-09-17 18:40 [PATCH v3 1/2] selftests: watchdog: Validate optional file argument Eugeniu Rosca
@ 2019-09-17 18:40 ` Eugeniu Rosca
  2019-09-18 11:33 ` [PATCH v3 1/2] selftests: watchdog: Validate optional file argument Eugeniu Rosca
       [not found] ` <156996250317.31379.1299334144215961607.git-patchwork-notify@kernel.org>
  2 siblings, 0 replies; 7+ messages in thread
From: Eugeniu Rosca @ 2019-09-17 18:40 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>

With the new ioctl(WDIOC_GETSUPPORT) call in place, 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>
---
v3:
 - Used v1 as starting point and simplified commit description
 - No change in the contents
 - Applied cleanly to the same base as used in [v1]
v2:
 - https://patchwork.kernel.org/patch/11147663/
v1:
 - https://patchwork.kernel.org/patch/11136285/
 - 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] 7+ messages in thread

* Re: [PATCH v3 1/2] selftests: watchdog: Validate optional file argument
  2019-09-17 18:40 [PATCH v3 1/2] selftests: watchdog: Validate optional file argument Eugeniu Rosca
  2019-09-17 18:40 ` [PATCH v3 2/2] selftests: watchdog: Add command line option to show watchdog_info Eugeniu Rosca
@ 2019-09-18 11:33 ` Eugeniu Rosca
  2019-09-18 21:05   ` shuah
       [not found] ` <156996250317.31379.1299334144215961607.git-patchwork-notify@kernel.org>
  2 siblings, 1 reply; 7+ messages in thread
From: Eugeniu Rosca @ 2019-09-18 11:33 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Eugeniu Rosca, Eugeniu Rosca, George G. Davis, Jerry Hoemann,
	Colin Ian King, linux-kselftest, linux-kernel

Hi Shuah,

On Tue, Sep 17, 2019 at 08:40:22PM +0200, Eugeniu Rosca wrote:
> From: "George G. Davis" <george_davis@mentor.com>
> 
> 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.
> 
> Fixes: c3f2490d6e9257 ("selftests: watchdog: Add optional file argument")
> 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>
> ---
> v3:
>  - Used v1 as starting point and simplified commit description
>  - Added Fixes tag (WARNING: commit id is from linux-next!)
>  - No change in the contents
>  - Applied cleanly to the same base as used in [v1]

Can we have your confirmation the patches look fine now?

-- 
Best Regards,
Eugeniu

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

* Re: [PATCH v3 1/2] selftests: watchdog: Validate optional file argument
  2019-09-18 11:33 ` [PATCH v3 1/2] selftests: watchdog: Validate optional file argument Eugeniu Rosca
@ 2019-09-18 21:05   ` shuah
  2019-09-19  9:50     ` Eugeniu Rosca
  0 siblings, 1 reply; 7+ messages in thread
From: shuah @ 2019-09-18 21: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/18/19 5:33 AM, Eugeniu Rosca wrote:
> Hi Shuah,
> 
> On Tue, Sep 17, 2019 at 08:40:22PM +0200, Eugeniu Rosca wrote:
>> From: "George G. Davis" <george_davis@mentor.com>
>>
>> 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.
>>
>> Fixes: c3f2490d6e9257 ("selftests: watchdog: Add optional file argument")
>> 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>
>> ---
>> v3:
>>   - Used v1 as starting point and simplified commit description
>>   - Added Fixes tag (WARNING: commit id is from linux-next!)
>>   - No change in the contents
>>   - Applied cleanly to the same base as used in [v1]
> 
> Can we have your confirmation the patches look fine now?
> 

Hi Eugeniu,

They both look good to me. I will apply these patches once the merge
window closes or when my first pull request to Linus clears.

You will see a notification when I apply them to kselftest tree.

thanks,
-- Shuah

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

* Re: [PATCH v3 1/2] selftests: watchdog: Validate optional file argument
  2019-09-18 21:05   ` shuah
@ 2019-09-19  9:50     ` Eugeniu Rosca
  0 siblings, 0 replies; 7+ messages in thread
From: Eugeniu Rosca @ 2019-09-19  9:50 UTC (permalink / raw)
  To: shuah
  Cc: Eugeniu Rosca, Eugeniu Rosca, George G. Davis, Jerry Hoemann,
	Colin Ian King, linux-kselftest, linux-kernel

Hi Shuah,

On Wed, Sep 18, 2019 at 03:05:33PM -0600, Shuah wrote:

[..]

> They both look good to me. I will apply these patches once the merge
> window closes or when my first pull request to Linus clears.
> 
> You will see a notification when I apply them to kselftest tree.

Many thanks for your prompt feedback.

-- 
Best Regards,
Eugeniu

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

* Re: [PATCH v3 1/2] selftests: watchdog: Validate optional file argument
       [not found] ` <156996250317.31379.1299334144215961607.git-patchwork-notify@kernel.org>
@ 2019-10-02 10:41   ` Eugeniu Rosca
  2019-10-02 19:48     ` shuah
  0 siblings, 1 reply; 7+ messages in thread
From: Eugeniu Rosca @ 2019-10-02 10:41 UTC (permalink / raw)
  To: shuah
  Cc: Eugeniu Rosca, George G. Davis, linux-kselftest, linux-kernel,
	Eugeniu Rosca

Hi Shuah,

On Tue, Oct 01, 2019 at 08:41:43PM +0000, patchwork-bot+linux-kselftest@kernel.org wrote:
> Hello:
> 
> This series was applied to shuah/linux-kselftest.git (refs/heads/fixes).
> 
> On Tue, 17 Sep 2019 20:40:22 +0200 you wrote:
> > From: "George G. Davis" <george_davis@mentor.com>
> > 
> > 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!
> > 
> > [...]
> 
> Here is a summary with links:
>   - [v3,1/2] selftests: watchdog: Validate optional file argument
>     https://git.kernel.org/shuah/linux-kselftest/c/93c384f5d553bc4fdfb252b89ff378363ee05cee

Could you please update the 'Fixes:' tag in the above commit to:
Fixes: a4864a33f56caa ("selftests: watchdog: Add optional file argument")

The warning in https://patchwork.kernel.org/patch/11149287/ clearly says
that the fixed commit is from linux-next and it seems to have been
updated before landing in mainline. TIA.

-- 
Best Regards,
Eugeniu

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

* Re: [PATCH v3 1/2] selftests: watchdog: Validate optional file argument
  2019-10-02 10:41   ` Eugeniu Rosca
@ 2019-10-02 19:48     ` shuah
  0 siblings, 0 replies; 7+ messages in thread
From: shuah @ 2019-10-02 19:48 UTC (permalink / raw)
  To: Eugeniu Rosca
  Cc: George G. Davis, linux-kselftest, linux-kernel, Eugeniu Rosca, shuah

On 10/2/19 4:41 AM, Eugeniu Rosca wrote:
> Hi Shuah,
> 
> On Tue, Oct 01, 2019 at 08:41:43PM +0000, patchwork-bot+linux-kselftest@kernel.org wrote:
>> Hello:
>>
>> This series was applied to shuah/linux-kselftest.git (refs/heads/fixes).
>>
>> On Tue, 17 Sep 2019 20:40:22 +0200 you wrote:
>>> From: "George G. Davis" <george_davis@mentor.com>
>>>
>>> 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!
>>>
>>> [...]
>>
>> Here is a summary with links:
>>    - [v3,1/2] selftests: watchdog: Validate optional file argument
>>      https://git.kernel.org/shuah/linux-kselftest/c/93c384f5d553bc4fdfb252b89ff378363ee05cee
> 
> Could you please update the 'Fixes:' tag in the above commit to:
> Fixes: a4864a33f56caa ("selftests: watchdog: Add optional file argument")
> 
> The warning in https://patchwork.kernel.org/patch/11149287/ clearly says
> that the fixed commit is from linux-next and it seems to have been
> updated before landing in mainline. TIA.
> 

Thanks. My scripts didn't catch it for some reason. Fixed now.

-- Shuah

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

end of thread, other threads:[~2019-10-02 19:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-17 18:40 [PATCH v3 1/2] selftests: watchdog: Validate optional file argument Eugeniu Rosca
2019-09-17 18:40 ` [PATCH v3 2/2] selftests: watchdog: Add command line option to show watchdog_info Eugeniu Rosca
2019-09-18 11:33 ` [PATCH v3 1/2] selftests: watchdog: Validate optional file argument Eugeniu Rosca
2019-09-18 21:05   ` shuah
2019-09-19  9:50     ` Eugeniu Rosca
     [not found] ` <156996250317.31379.1299334144215961607.git-patchwork-notify@kernel.org>
2019-10-02 10:41   ` Eugeniu Rosca
2019-10-02 19:48     ` 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).