[PATCH net-next 1/2] vsock/test: Add new function to check for timeout

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

 



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@xxxxxxxxxx>
---
 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





[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux