[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250306-test_vsock-v1-1-0320b5accf92@redhat.com>
Date: Thu, 06 Mar 2025 17:09:32 +0100
From: Luigi Leonardi <leonardi@...hat.com>
To: Stefano Garzarella <sgarzare@...hat.com>, Michal Luczaj <mhal@...x.co>
Cc: virtualization@...ts.linux.dev, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, Luigi Leonardi <leonardi@...hat.com>
Subject: [PATCH net-next 1/2] vsock/test: Add new function to check for
timeout
Add `timeout_check_expired` function that returns true if the timeout
counter has expired.
This is useful in situations where a timeout does not necessarily mean a
failure.
Signed-off-by: Luigi Leonardi <leonardi@...hat.com>
---
tools/testing/vsock/timeout.c | 7 ++++++-
tools/testing/vsock/timeout.h | 3 +++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/tools/testing/vsock/timeout.c b/tools/testing/vsock/timeout.c
index 44aee49b6cee07deb9443e3c2595ef680b726053..d6c69b14a0385befa6204a311c0a7f0c148ab021 100644
--- a/tools/testing/vsock/timeout.c
+++ b/tools/testing/vsock/timeout.c
@@ -18,7 +18,6 @@
*/
#include <stdlib.h>
-#include <stdbool.h>
#include <unistd.h>
#include <stdio.h>
#include "timeout.h"
@@ -43,6 +42,12 @@ void timeout_begin(unsigned int seconds)
alarm(seconds);
}
+/* Check if timer has expired */
+bool timeout_check_expired(void)
+{
+ return timeout;
+}
+
/* Exit with an error message if the timeout has expired */
void timeout_check(const char *operation)
{
diff --git a/tools/testing/vsock/timeout.h b/tools/testing/vsock/timeout.h
index ecb7c840e65ae5d40419bf5f9ca57fdf4051aa41..cbb183e3a73784b82b2139fbf7a00fd62521ad77 100644
--- a/tools/testing/vsock/timeout.h
+++ b/tools/testing/vsock/timeout.h
@@ -2,6 +2,8 @@
#ifndef TIMEOUT_H
#define TIMEOUT_H
+#include <stdbool.h>
+
enum {
/* Default timeout */
TIMEOUT = 10 /* seconds */
@@ -10,6 +12,7 @@ enum {
void sigalrm(int signo);
void timeout_begin(unsigned int seconds);
void timeout_check(const char *operation);
+bool timeout_check_expired(void);
void timeout_end(void);
#endif /* TIMEOUT_H */
--
2.48.1
Powered by blists - more mailing lists