[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241025013933.6516-2-lizhijian@fujitsu.com>
Date: Fri, 25 Oct 2024 09:39:32 +0800
From: Li Zhijian <lizhijian@...itsu.com>
To: linux-kselftest@...r.kernel.org
Cc: shuah@...nel.org,
linux-kernel@...r.kernel.org,
Li Zhijian <lizhijian@...itsu.com>
Subject: [PATCH for-next 2/3] selftests/watchdog: exit watchdog-test with error code
So that we can check its exit code to judge whether it succeeds
or not.
Signed-off-by: Li Zhijian <lizhijian@...itsu.com>
---
.../testing/selftests/watchdog/watchdog-test.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
index 2f8fd2670897..d42fc2fd790d 100644
--- a/tools/testing/selftests/watchdog/watchdog-test.c
+++ b/tools/testing/selftests/watchdog/watchdog-test.c
@@ -51,7 +51,7 @@ static const struct option lopts[] = {
* the PC Watchdog card to reset its internal timer so it doesn't trigger
* a computer reset.
*/
-static void keep_alive(void)
+static int keep_alive(void)
{
int dummy;
int ret;
@@ -59,6 +59,8 @@ static void keep_alive(void)
ret = ioctl(fd, WDIOC_KEEPALIVE, &dummy);
if (!ret)
printf(".");
+
+ return ret;
}
/*
@@ -175,7 +177,7 @@ int main(int argc, char *argv[])
int flags;
unsigned int ping_rate = DEFAULT_PING_RATE;
int ret;
- int c;
+ int c, n;
int oneshot = 0, stop = 1, count = 0;
char *file = "/dev/watchdog";
struct watchdog_info info;
@@ -342,7 +344,9 @@ int main(int argc, char *argv[])
signal(SIGINT, term);
while (stop || count--) {
- exit_code = keep_alive();
+ ret = keep_alive();
+ if (ret)
+ goto end;
sleep(ping_rate);
}
end:
@@ -350,9 +354,10 @@ int main(int argc, char *argv[])
* Send specific magic character 'V' just in case Magic Close is
* enabled to ensure watchdog gets disabled on close.
*/
- ret = write(fd, &v, 1);
- if (ret < 0)
+ n = write(fd, &v, 1);
+ if (n < 0)
printf("Stopping watchdog ticks failed (%d)...\n", errno);
close(fd);
- return 0;
+
+ return ret || n < 0;
}
--
2.44.0
Powered by blists - more mailing lists