Re: [PATCH for-next 1/3] selftests/watchdog: add count parameter for watchdog-test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/24/24 19:39, Li Zhijian wrote:
Currently, watchdog-test keep running until it gets a SIGINT. However,
when watchdog-test is executed from the kselftests framework, where it
launches test via timeout which will send SIGTERM in time up. This could
lead to
1. watchdog haven't stop, a watchdog reset is triggered to reboot the OS
    in silent.
2. kselftests gets an timeout exit code, and judge watchdog-test as
   'not ok'

This test isn't really supposed to be run from kselftest framework.
This is the reason why it isn't included in the default run.

This patch is prepare to fix above 2 issues

This series needs a separate cover letter explaining how this problem is
being fixed.


Signed-off-by: Li Zhijian <lizhijian@xxxxxxxxxxx>
---
Hey,
Cover letter is here.

It's notice that a OS reboot was triggerred after ran the watchdog-test
in kselftests framwork 'make run_tests', that's because watchdog-test
didn't stop feeding the watchdog after enable it.

In addition, current watchdog-test didn't adapt to the kselftests
framework which launchs the test with /usr/bin/timeout and no timeout
is expected.
---
  tools/testing/selftests/watchdog/watchdog-test.c | 13 +++++++++----
  1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
index bc71cbca0dde..2f8fd2670897 100644
--- a/tools/testing/selftests/watchdog/watchdog-test.c
+++ b/tools/testing/selftests/watchdog/watchdog-test.c
@@ -27,7 +27,7 @@
int fd;
  const char v = 'V';
-static const char sopts[] = "bdehp:st:Tn:NLf:i";
+static const char sopts[] = "bdehp:st:Tn:NLf:c:i";
  static const struct option lopts[] = {
  	{"bootstatus",          no_argument, NULL, 'b'},
  	{"disable",             no_argument, NULL, 'd'},
@@ -42,6 +42,7 @@ static const struct option lopts[] = {
  	{"gettimeleft",		no_argument, NULL, 'L'},
  	{"file",          required_argument, NULL, 'f'},
  	{"info",		no_argument, NULL, 'i'},
+	{"count",         required_argument, NULL, 'c'},
  	{NULL,                  no_argument, NULL, 0x0}
  };
@@ -95,6 +96,7 @@ static void usage(char *progname)
  	printf(" -n, --pretimeout=T\tSet the pretimeout to T seconds\n");
  	printf(" -N, --getpretimeout\tGet the pretimeout\n");
  	printf(" -L, --gettimeleft\tGet the time left until timer expires\n");
+	printf(" -c, --count\tStop after feeding the watchdog count times\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);
@@ -174,7 +176,7 @@ int main(int argc, char *argv[])
  	unsigned int ping_rate = DEFAULT_PING_RATE;
  	int ret;
  	int c;
-	int oneshot = 0;
+	int oneshot = 0, stop = 1, count = 0;
  	char *file = "/dev/watchdog";
  	struct watchdog_info info;
  	int temperature;
@@ -307,6 +309,9 @@ int main(int argc, char *argv[])
  			else
  				printf("WDIOC_GETTIMELEFT error '%s'\n", strerror(errno));
  			break;
+		case 'c':
+			stop = 0;
+			count = strtoul(optarg, NULL, 0);
  		case 'f':
  			/* Handled above */
  			break;
@@ -336,8 +341,8 @@ int main(int argc, char *argv[])
signal(SIGINT, term); - while (1) {
-		keep_alive();
+	while (stop || count--) {
+		exit_code = keep_alive();
  		sleep(ping_rate);
  	}
  end:





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux