mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: skhan@linuxfoundation.org, shuah@kernel.org
Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] selftests/watchdog: add test for WDIOC_GETTEMP
Date: Fri, 21 Oct 2022 16:18:19 -0600	[thread overview]
Message-ID: <2b559a7d0d2be46729f3a03dc639dd4a69e465bb.1666390362.git.skhan@linuxfoundation.org> (raw)
In-Reply-To: <cover.1666390362.git.skhan@linuxfoundation.org>

Add test for WDIOC_GETTEMP and this ioctl might not be supported by some
devices and if it is this test will print the following message:

Inappropriate ioctl for device

Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
---
 tools/testing/selftests/watchdog/watchdog-test.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
index 03103eaa946c..5ec0384b7f02 100644
--- a/tools/testing/selftests/watchdog/watchdog-test.c
+++ b/tools/testing/selftests/watchdog/watchdog-test.c
@@ -1,12 +1,10 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
 * Watchdog Driver Test Program
-* - Tests all ioctls except WDIOC_GETTEMP
+* - Tests all ioctls
 * - Tests Magic Close - CONFIG_WATCHDOG_NOWAYOUT
 * - Could be tested against softdog driver on systems that
 *   don't have watchdog hadrware.
-* - TODO:
-* - Enhance test to add coverage for WDIOC_GETTEMP.
 *
 * Reference: Documentation/watchdog/watchdog-api.rst
  */
@@ -177,6 +175,7 @@ int main(int argc, char *argv[])
 	int oneshot = 0;
 	char *file = "/dev/watchdog";
 	struct watchdog_info info;
+	int temperature;
 
 	setbuf(stdout, NULL);
 
@@ -255,6 +254,12 @@ int main(int argc, char *argv[])
 				print_status(flags);
 			else
 				printf("WDIOC_GETSTATUS error '%s'\n", strerror(errno));
+			ret = ioctl(fd, WDIOC_GETTEMP, &temperature);
+			if (ret)
+				printf("WDIOC_GETTEMP: '%s'\n", strerror(errno));
+			else
+				printf("Temeprature: %d\n", temperature);
+
 			break;
 		case 't':
 			flags = strtoul(optarg, NULL, 0);
-- 
2.34.1


      parent reply	other threads:[~2022-10-21 22:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-21 22:18 [PATCH 0/4] Enhance watchdog API test coverage Shuah Khan
2022-10-21 22:18 ` [PATCH 1/4] selftests/watchdog: change to print reset reason info Shuah Khan
2022-10-21 22:18 ` [PATCH 2/4] selftests/watchdog: add support for WDIOC_GETSTATUS Shuah Khan
2022-10-21 22:18 ` [PATCH 3/4] selftests/watchdog: print watchdog_info option strings Shuah Khan
2022-10-21 22:18 ` Shuah Khan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2b559a7d0d2be46729f3a03dc639dd4a69e465bb.1666390362.git.skhan@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®