From: Luigi Leonardi <leonardi@redhat.com>
To: Stefano Garzarella <sgarzare@redhat.com>, Michal Luczaj <mhal@rbox.co>
Cc: virtualization@lists.linux.dev, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Luigi Leonardi <leonardi@redhat.com>
Subject: [PATCH net-next 1/2] vsock/test: Add new function to check for timeout
Date: Thu, 06 Mar 2025 17:09:32 +0100 [thread overview]
Message-ID: <20250306-test_vsock-v1-1-0320b5accf92@redhat.com> (raw)
In-Reply-To: <20250306-test_vsock-v1-0-0320b5accf92@redhat.com>
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@redhat.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
next prev parent reply other threads:[~2025-03-06 16:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-06 16:09 [PATCH net-next 0/2] vsock/test: check for null-ptr-deref when transport changes Luigi Leonardi
2025-03-06 16:09 ` Luigi Leonardi [this message]
2025-03-06 16:09 ` [PATCH net-next 2/2] vsock/test: Add test for null ptr deref " Luigi Leonardi
2025-03-06 17:05 ` Stefano Garzarella
2025-03-07 9:32 ` Michal Luczaj
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=20250306-test_vsock-v1-1-0320b5accf92@redhat.com \
--to=leonardi@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhal@rbox.co \
--cc=netdev@vger.kernel.org \
--cc=sgarzare@redhat.com \
--cc=virtualization@lists.linux.dev \
/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;
as well as URLs for NNTP newsgroup(s).