diff freeDiameter/tests/tests.h @ 236:60f34df3e025

Remove dependency on signalent.h
author Sebastien Decugis <sdecugis@nict.go.jp>
date Mon, 08 Mar 2010 14:10:30 +0900
parents 8773740401a5
children 5df55136361b
line wrap: on
line diff
--- a/freeDiameter/tests/tests.h	Fri Mar 05 19:01:48 2010 +0900
+++ b/freeDiameter/tests/tests.h	Mon Mar 08 14:10:30 2010 +0900
@@ -56,6 +56,7 @@
 #include <getopt.h>
 #include <time.h>
 #include <libgen.h>
+#include <signal.h>
 
 /* Define the return code values */
 #define PASS	0
@@ -115,6 +116,11 @@
 	parse_cmdline(argc, argv);						\
 }
 
+static void test_timeout(int signal)
+{
+	FAILTEST("The timeout (" _stringize(TEST_TIMEOUT) " sec) was reached. Use -n or change TEST_TIMEOUT if the test needs more time to execute.");
+}
+
 static inline void parse_cmdline(int argc, char * argv[]) {
 	int c;
 	int no_timeout = 0;
@@ -137,8 +143,10 @@
 		}
 	}
 	fd_g_debug_lvl = (test_verbo > 0) ? (test_verbo - 1) : 0;
-	if (!no_timeout)
+	if (!no_timeout) {
 		alarm(TEST_TIMEOUT);
+		fd_sig_register(SIGALRM, "Test.harness", test_timeout);
+	}
 }
  
 #endif /* _TESTS_H */
"Welcome to our mercurial repository"