[vlc-devel] [PATCH 1/2] test: dump core on timeout

Thomas Guillem thomas at gllm.fr
Tue Nov 27 15:02:18 CET 2018


---
 test/libvlc/test.h | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/test/libvlc/test.h b/test/libvlc/test.h
index 57bf787514..641e52d688 100644
--- a/test/libvlc/test.h
+++ b/test/libvlc/test.h
@@ -41,7 +41,7 @@
 #include <stdlib.h>
 #include <stdbool.h>
 #include <unistd.h>
-
+#include <signal.h>
 
 /*********************************************************************
  * Some useful global var
@@ -65,6 +65,13 @@ static const char test_default_video[] = SRCDIR"/samples/image.jpg";
 
 #define test_log( ... ) printf( "testapi: " __VA_ARGS__ );
 
+static inline void on_sigalrm(int signum)
+{
+    fprintf(stderr, "ERROR: test timeout\n");
+    /* Raise SIGABRT in order to cause a core dump */
+    raise(SIGABRT);
+}
+
 static inline void test_init (void)
 {
     (void)test_default_sample; /* This one may not be used */
@@ -84,7 +91,13 @@ static inline void test_init (void)
             alarm_timeout = val;
     }
     if (alarm_timeout != 0)
+    {
+        struct sigaction sig = {
+            .sa_handler = on_sigalrm,
+        };
+        sigaction(SIGALRM, &sig, NULL);
         alarm (alarm_timeout);
+    }
 
     setenv( "VLC_PLUGIN_PATH", "../modules", 1 );
 }
-- 
2.19.2



More information about the vlc-devel mailing list