List:Commits« Previous MessageNext Message »
From:jwinstead Date:April 26 2007 9:47pm
Subject:Connector/ODBC 3.51 commit: r330 - trunk/test/include
View as plain text  
Modified:
   trunk/test/include/odbctap.h
Log:
Add basic timeout for tests (30 secs for each sub-test)


Modified: trunk/test/include/odbctap.h
===================================================================
--- trunk/test/include/odbctap.h	2007-04-26 20:55:46 UTC (rev 329)
+++ trunk/test/include/odbctap.h	2007-04-26 21:47:37 UTC (rev 330)
@@ -29,7 +29,10 @@
 /** @todo Remove dependency on this crufty old header. */
 #define DEBUG_LEVEL 2
 #include "mytest3.h"
+
 #include <stdarg.h>
+#include <signal.h>
+
 #undef printMessage
 void printMessage(char *fmt, ...) {
   va_list ap;
@@ -76,6 +79,13 @@
 #define ADD_TEST(name) { #name, name, OK   },
 #define ADD_TODO(name) { #name, name, FAIL },
 #define END_TESTS }; \
+void test_timeout(int signum) \
+{ \
+  printf("Bail out! Timeout."); \
+  exit(1); \
+} \
+\
+\
 int main(int argc, char **argv) \
 { \
   SQLHENV  henv; \
@@ -109,11 +119,15 @@
   num_tests= sizeof(tests) / sizeof(tests[0]); \
   printf("1..%d\n", num_tests); \
 \
+  (void)signal(SIGALRM, test_timeout); \
+\
   alloc_basic_handles(&henv,&hdbc,&hstmt); \
 \
   for (i= 0; i < num_tests; i++ ) \
   { \
-    int rc= tests[i].func(hdbc, hstmt, henv); \
+    int rc; \
+    alarm(30); \
+    rc= tests[i].func(hdbc, hstmt, henv); \
     printf("%s %d %s %s\n", rc == OK ? "ok" : "not ok", i + 1, \
            tests[i].expect == FAIL ? "# TODO" : "-", \
            tests[i].name); \

Thread
Connector/ODBC 3.51 commit: r330 - trunk/test/includejwinstead26 Apr