[vlc-devel] [PATCH] test: configure timeout with an env variable

Thomas Guillem thomas at gllm.fr
Mon Nov 26 10:23:32 CET 2018


VLC_TEST_TIMEOUT=-1 for an infinite timeout
VLC_TEST_TIMEOUT=n (n > 0) for a timeout of n seconds.
---
 test/libvlc/test.h | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/test/libvlc/test.h b/test/libvlc/test.h
index 7be53e1417..a51b2f1b49 100644
--- a/test/libvlc/test.h
+++ b/test/libvlc/test.h
@@ -41,6 +41,7 @@
 #include <stdlib.h>
 #include <stdbool.h>
 #include <unistd.h>
+#include <limits.h>
 
 
 /*********************************************************************
@@ -68,7 +69,27 @@ static const char test_default_video[] = SRCDIR"/samples/image.jpg";
 static inline void test_init (void)
 {
     (void)test_default_sample; /* This one may not be used */
-    alarm (10); /* Make sure "make check" does not get stuck */
+
+    /* Make sure "make check" does not get stuck */
+    /* Timeout of 10secs by default */
+    unsigned alarm_timeout = 10;
+    /* Valid timeout value are < 0, for infinite, and > 0, for the number of
+     * seconds */
+    char *alarm_timeout_str = getenv("VLC_TEST_TIMEOUT");
+    if (alarm_timeout_str)
+    {
+        long int val = strtol(alarm_timeout_str, NULL, 10);
+        const bool valid_timeout_value = val != LONG_MIN && val != LONG_MAX &&
+                                         val != 0;
+        assert(valid_timeout_value);
+        if (val < 0)
+            alarm_timeout = 0; /* infinite */
+        else
+            alarm_timeout = val;
+    }
+    if (alarm_timeout != 0)
+        alarm (alarm_timeout);
+
     setenv( "VLC_PLUGIN_PATH", "../modules", 1 );
 }
 
-- 
2.19.2



More information about the vlc-devel mailing list