[m-rev.] diff: set timeout on tests/par_conj/threads_hang

Peter Wang wangp at students.cs.mu.oz.au
Mon Sep 11 15:37:19 AEST 2006


Estimated hours taken: 0.5
Branches: main

tests/par_conj/threads_hang.m:
tests/par_conj/Mmakefile:
	Set an alarm that aborts this test case if it's taking too long
	so as not to hold up the test suite.

Index: tests/par_conj/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/par_conj/Mmakefile,v
retrieving revision 1.7
diff -u -r1.7 Mmakefile
--- tests/par_conj/Mmakefile	9 Aug 2006 03:17:16 -0000	1.7
+++ tests/par_conj/Mmakefile	11 Sep 2006 05:31:25 -0000
@@ -125,7 +125,8 @@
 ifeq "$(filter hl% java% il%,$(GRADE))" ""
 threads_hang.out: threads_hang
 	for i in 1 2 3 4 5 6 7 8 9 10 ; do \
-		MERCURY_OPTIONS=-P10 ./threads_hang 2>&1 > threads_hang.out ;\
+		MERCURY_OPTIONS=-P10 ./threads_hang 2>&1 > threads_hang.out ||\
+			{ echo 'failed' > threads_hang.out; break; } \
 	done
 endif
 
Index: tests/par_conj/threads_hang.m
===================================================================
RCS file: /home/mercury1/repository/tests/par_conj/threads_hang.m,v
retrieving revision 1.2
diff -u -r1.2 threads_hang.m
--- tests/par_conj/threads_hang.m	3 Jul 2006 03:59:01 -0000	1.2
+++ tests/par_conj/threads_hang.m	11 Sep 2006 05:31:34 -0000
@@ -5,12 +5,16 @@
 :- interface.
 :- import_module io.
 
-:- pred main(io::di, io::uo) is det.
+:- impure pred main(io::di, io::uo) is det.
 
 :- implementation.
 :- import_module int.
 
 main(!IO) :-
+    % Set a signal to go off if the program is taking too long.
+    % The default SIGALRM handler will abort the program.
+    impure alarm(10),
+
     fib(7, F),
     fib(6, G),
     io.write_int(F, !IO),
@@ -30,3 +34,14 @@
         ),
         F = F1 + F2
     ).
+
+:- pragma foreign_decl("C", "#include <unistd.h>").
+
+:- impure pred alarm(int::in) is det.
+
+:- pragma foreign_proc("C",
+    alarm(Seconds::in),
+    [will_not_call_mercury],
+"
+    alarm(Seconds);
+").
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list