[m-rev.] for review: gathering trace counts

Zoltan Somogyi zs at cs.mu.OZ.AU
Wed Mar 23 14:26:02 AEDT 2005


For review by Ian or Julien.

Zoltan.

Provide a mechanism for gathering sets of trace counts from both passed and
failed test cases.

runtime/mercury_trace_base.[ch]:
	Instead of writing out trace counts to a file with a fixed name,
	write it out to a file whose name includes the name of the executable
	and the process id.

	Export only the functions that need to be exported.

	Add sanity checking code that looks for and reports occurrences
	of a situation reported by Peter Wang: positive counts for internal
	events in a procedure with a missing (and hence zero) count for the
	CALL event of that same procedure. Make this sanity check conditional
	on the new configuration macro MR_TRACE_COUNT_DEBUG. The sanity check
	did not find any anomalies during any of my bootchecks.

runtime/mercury_conf_param.h:
	Document MR_TRACE_COUNT_DEBUG.

tests/Mmake.common:
tests/run_one_test:
	Move the code for executing one test from a very long action in
	Mmake.common to the new shell script run_one_test, to make it possible
	to edit it without having to worry about line continuations.

tests/run_one_test:
	Make the code for executing one test move the trace count files
	generated by the test, if any, to the directory for passed or failed
	test cases, and record their names.

	Add a mechanism for creating a timestamp file for each test.

tools/bootcheck:
	Clean up the files and directories containing trace counts information
	from a previous bootcheck before running the tests this time.

	Add an option --progress, that creates a timestamp file for each test.
	This allows users to gauge the rate at which bootcheck executes test
	cases, and provides the information required for detecting performance
	problems that manifest themselves as slow test case execution.

	Allow the --trace-count option to be spelt --trace-counts.

	Since run_one_test now gathers a list of failed test in a much cleaner
	format than before (a simple list of the names of failed test cases,
	complete with their directories), print this list at the end of the
	output. This saves having to grep for FAILED TEST in the output file.

	The existing --failing-tests option did "dumpster diving" to discover
	the list of failing test cases, and rerun only them. This behavior
	is still available as the --error-file option, but --failing-tests
	now uses the much simpler record of which tests failed to repeat
	only failed tests.

	The new --specified-test option allows the rerunning of only a single
	test. This way, "tools/bootcheck -b- -s debugger/queens" will rerun
	only the queens test in the debugger directory. While you can often
	compile and run test cases by hand, it is difficult to compile and
	run them the same way as bootcheck does, especially for multi-module
	programs. This way, one can use the bootcheck script as a scalpel,
	not a club.

	Make this file use four-space indentation.

tests/Mmake.common:
	Clean up any stray trace count files.

	Implement the infrastructure required for --specified-test.

tests/debugger/Mmakefile:
	Conform to the new naming scheme for trace counts files.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_conf_param.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_conf_param.h,v
retrieving revision 1.79
diff -u -b -r1.79 mercury_conf_param.h
--- runtime/mercury_conf_param.h	20 Jul 2004 04:41:20 -0000	1.79
+++ runtime/mercury_conf_param.h	4 Mar 2005 02:29:54 -0000
@@ -161,6 +161,10 @@
 **
 **	Setting MR_DECL_DEBUG requires MR_EXEC_TRACE to be set also.
 **
+** MR_TRACE_COUNT_DEBUG
+** 	Enables runtime checking of the invariants involving the implementation
+** 	of the --trace-count runtime option.
+**
 ** MR_LOWLEVEL_DEBUG
 **	Enables various low-level debugging stuff,
 **	that was in the distant past used to debug
Index: runtime/mercury_trace_base.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_trace_base.c,v
retrieving revision 1.63
diff -u -b -r1.63 mercury_trace_base.c
--- runtime/mercury_trace_base.c	18 Feb 2005 04:05:34 -0000	1.63
+++ runtime/mercury_trace_base.c	5 Mar 2005 10:15:26 -0000
@@ -171,6 +171,34 @@
     if (label_number >= module_layout->MR_ml_num_label_exec_counts) {
         MR_fatal_error("MR_trace_count: invalid label number");
     }
+
+#ifdef  MR_TRACE_COUNT_DEBUG
+    {
+        const MR_Label_Layout   *call_label_layout;
+        MR_uint_least16_t       call_label_number;
+
+        call_label_layout = proc_layout->MR_sle_call_label;
+        if (label_layout != call_label_layout) {
+            /*
+            ** We should only get here if we have executed the call label,
+            ** which means its count should be nonzero.
+            */
+
+            call_label_number = call_label_layout->MR_sll_label_num_in_module;
+            if (call_label_number >=
+                module_layout->MR_ml_num_label_exec_counts)
+            {
+                MR_fatal_error("MR_trace_count: invalid call label number");
+            }
+
+            if (module_layout->MR_ml_label_exec_count[call_label_number] == 0)
+            {
+                MR_fatal_error("MR_trace_count: call label count is zero");
+            }
+        }
+    }
+#endif
+
     ++module_layout->MR_ml_label_exec_count[label_number];
     return NULL;
 }
@@ -200,26 +228,49 @@
 
 static MR_PathPort MR_named_count_port[MR_PORT_NONE + 1];
 
-static void
-MR_trace_write_quoted_atom(FILE *fp, const char *atom);
+static  void    MR_trace_write_quoted_atom(FILE *fp, const char *atom);
+static  void    MR_trace_write_label_exec_counts(FILE *fp);
+
+#define MERCURY_TRACE_COUNTS_PREFIX  "mercury_trace_counts"
 
 void
 MR_trace_write_label_exec_counts_to_file(void *dummy)
 {
     FILE	*fp;
+    int     len;
+    char    *name;
+    char    *s;
+
+    /* 100 bytes must be enough for the process id, dots and '\0' */
+    len = strlen(MERCURY_TRACE_COUNTS_PREFIX) + strlen(MR_progname) + 100;
+    name = MR_malloc(len);
+    snprintf(name, len, ".%s.%s.%d", MERCURY_TRACE_COUNTS_PREFIX, MR_progname,
+        getpid());
+
+    /* make sure name is an acceptable filename */
+    for (s = name; *s != '\0'; s++) {
+        if (*s == '/') {
+            *s = ':';
+        }
+    }
 
-    fp = fopen(MERCURY_TRACE_COUNTS_FILE_NAME, "w");
+    fp = fopen(name, "w");
     if (fp != NULL) {
         MR_do_init_modules_debugger();
         MR_trace_write_label_exec_counts(fp);
         (void) fclose(fp);
     } else {
-        fprintf(stderr, "%s: %s\n",
-            MERCURY_TRACE_COUNTS_FILE_NAME, strerror(errno));
+        fprintf(stderr, "%s: %s\n", name, strerror(errno));
     }
 }
 
-void
+/*      
+** For every label reachable from the module table, write the id of the label
+** and the number of times it has been executed to the specified file, with the
+** exception of labels that haven't been executed.
+*/ 
+
+static void
 MR_trace_write_label_exec_counts(FILE *fp)
 {
     const MR_Module_Layout      *module;
Index: runtime/mercury_trace_base.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_trace_base.h,v
retrieving revision 1.44
diff -u -b -r1.44 mercury_trace_base.h
--- runtime/mercury_trace_base.h	18 Feb 2005 04:05:34 -0000	1.44
+++ runtime/mercury_trace_base.h	5 Mar 2005 09:18:11 -0000
@@ -103,16 +103,10 @@
 
 /*
 ** For every label reachable from the module table, write the id of the label
-** and the number of times it has been executed to the specified file, with the
-** exception of labels that haven't been executed.
-*/
-
-extern	void	MR_trace_write_label_exec_counts(FILE *fp);
-
-/*
-** MR_trace_write_label_exec_counts_to_file does the same job as
-** MR_trace_write_label_exec_counts, except that it also opens the file.
-** Its signature allows it to be registered with 
+** and the number of times it has been executed to trace counts file of this
+** program, with the exception of labels that haven't been executed.
+**
+** The dummy argument allows this function to be registered with 
 ** MR_register_exception_cleanup.
 */
 
@@ -528,7 +522,5 @@
 		MR_save_transient_registers();				\
 		MR_io_tabling_enabled = saved_io_enabled;		\
 	} while (0)
-
-#define	MERCURY_TRACE_COUNTS_FILE_NAME	".mercury_trace_counts"
 
 #endif /* MERCURY_TRACE_BASE_H */
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
Index: tests/Mmake.common
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/Mmake.common,v
retrieving revision 1.43
diff -u -b -r1.43 Mmake.common
--- tests/Mmake.common	10 Feb 2005 04:10:30 -0000	1.43
+++ tests/Mmake.common	7 Mar 2005 02:46:12 -0000
@@ -264,6 +264,12 @@
 endif
 endif
 
+ifdef SPECIFIED_TESTS
+THIS_DIR_TESTS_TO_RUN := $(SPECIFIED_TESTS)
+else
+ifdef FAILED_TESTS_ONLY
+THIS_DIR_TESTS_TO_RUN := $(shell FAILED_TESTS)
+else
 ifdef TESTS_TO_RUN
 THIS_DIR_TESTS_TO_RUN := $(shell echo $(patsubst $(THIS_DIR)/%,%,\
 		$(filter $(THIS_DIR)/%,$(TESTS_TO_RUN))) \
@@ -271,6 +277,8 @@
 else
 THIS_DIR_TESTS_TO_RUN := $(strip $(TESTS))
 endif
+endif
+endif
 
 ifeq ($(THIS_DIR_TESTS_TO_RUN),)
 
@@ -303,50 +311,28 @@
 		rm -f *.d *.dep *.int *.int2 *.int3 > /dev/null 2>&1; \
 		rm -f *.date *.date3 *.opt *.optdate > /dev/null 2>&1; \
 		rm -f *.trans_opt *.trans_opt_date > /dev/null 2>&1; \
+		rm -f .mercury_trace_counts* > /dev/null 2>&1; \
+		rm -f .date* > /dev/null 2>&1; \
 	fi
 	@> FAILED_TESTS
 
 #
-# Run a single test, cleaning up if it succeeds, or producing
-# a log file and gzipping the executable the test fails.
+# Run a single test, cleaning up if it succeeds, or producing a log file
+# and gzipping the executable if the test fails.
 #
 .PHONY: %.log
 %.log: start_runtests_local
-	+ at test=$(*:%-nodepend=%); \
-	echo RUNNING TEST $(THIS_DIR)/$* $(PARAMS_MSG) | tee $@; \
-	case $* in \
-		*-nodepend) \
-			rm -f $*.failed;; \
-		*) \
-			rm -f $*.failed; \
-			{ mmake $$test.depend 2>&1 || touch $*.failed; } \
-				| tee -a $@ ;; \
-	esac; \
-	if [ -f $*.failed ]; then \
-		echo FAILED TEST $(THIS_DIR)/$* $(PARAMS_MSG) \
-			| tee -a $@; \
-		echo $* >> FAILED_TESTS; \
-		exit 1; \
-	else \
-		{ mmake $$test.runtest 2>&1 || touch $*.failed; } \
-			| tee -a $@; \
-		if [ -f $*.failed ]; then \
-			rm -f $*.failed; \
-		    	if [ -f $$test ]; then \
-				rm -f $$test.gz $$test.exe.gz; \
-				gzip $$test || gzip $$test.exe; \
-			fi; \
-			echo FAILED TEST $(THIS_DIR)/$* $(PARAMS_MSG) \
-				| tee -a $@; \
-			echo $* >> FAILED_TESTS; \
-			exit 1; \
-		else \
-			rm -f $@; \
-			rm -f $$test.out* $$test.*res*; \
-			mmake $$test.realclean > /dev/null 2>&1; \
-			echo PASSED TEST $(THIS_DIR)/$* $(PARAMS_MSG); \
-		fi; \
-	fi
+	+ at test_full=$*; \
+	test=$(*:%-nodepend=%); \
+	params_msg="$(PARAMS_MSG)"; \
+	this_dir="$(THIS_DIR)"; \
+	tests_dir="$(TESTS_DIR)"; \
+	export test_full; \
+	export test; \
+	export params_msg; \
+	export this_dir; \
+	export tests_dir; \
+	$(TESTS_DIR)/run_one_test
 
 # XXX The tests cannot be run in parallel because where several test
 # cases depend on the same target, the different invocations of mmake
Index: tests/run_one_test
===================================================================
RCS file: tests/run_one_test
diff -N tests/run_one_test
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/run_one_test	21 Mar 2005 02:32:27 -0000
@@ -0,0 +1,104 @@
+#!/bin/sh
+# vim: ts=4 sw=4 expandtab
+
+set -x
+
+exitstatus=0
+echo RUNNING TEST $this_dir/$test_full $params_msg | tee $test_full.log
+echo "MERCURY_OPTIONS=$MERCURY_OPTIONS"
+trace_count=false
+case "$MERCURY_OPTIONS" in
+    *trace-count*)
+        trace_count=true
+        /bin/rm .mercury_trace_counts.* > /dev/null 2>&1
+        ;;
+esac
+
+case $test_full in
+    *-nodepend)
+        rm -f $test_full.failed
+        ;;
+    *)
+        rm -f $test_full.failed
+        ( mmake $test.depend 2>&1 || touch $test_full.failed ) \
+            | tee -a $test_full.log
+        ;;
+esac
+
+if test -f $test_full.failed
+then
+    echo FAILED TEST $this_dir/$test_full $params_msg | tee -a $test_full.log
+    echo $test_full >> FAILED_TESTS
+    echo $this_dir/$test_full $params_msg >> $tests_dir/FAILED_TESTS_SUMMARY
+    exitstatus=1
+else
+    ( mmake $test.runtest 2>&1 || touch $test_full.failed ) \
+        | tee -a $test_full.log
+    if test -f $test_full.failed
+    then
+        rm -f $test_full.failed
+        if test -f $test
+        then
+            rm -f $test.gz $test.exe.gz
+            gzip $test || gzip $test.exe
+        fi
+        echo FAILED TEST $this_dir/$test_full $params_msg \
+            | tee -a $test_full.log
+        echo $test_full >> FAILED_TESTS
+        echo $this_dir/$test_full $params_msg \
+            >> $tests_dir/FAILED_TESTS_SUMMARY
+        case "$trace_count" in
+            true)
+                name=`echo $this_dir/$test | tr '[/]' '[:]'`
+                for counts_file in .mercury_trace_counts.*
+                do
+                    if test -s "$counts_file"
+                    then
+                        name=`echo "$counts_file" | \
+                            sed -e 's/.mercury_trace_counts//'`
+                        mkdir -p $tests_dir/FAILED_TC_DIR
+                        mv $counts_file \
+                            $tests_dir/FAILED_TC_DIR/$counts_file.$name
+                        gzip $tests_dir/FAILED_TC_DIR/$counts_file.$name
+                        echo $tests_dir/FAILED_TC_DIR/$counts_file.$name \
+                            >> $tests_dir/FAILED_TC_FILES
+                    fi
+                done
+                ;;
+        esac
+        exitstatus=1
+    else
+        rm -f $test_full.log $test.out* $test.*res*
+        mmake $test.realclean > /dev/null 2>&1
+        echo PASSED TEST $this_dir/$test_full $params_msg
+        case "$trace_count" in
+            true)
+                name=`echo $this_dir/$test | tr '[/]' '[:]'`
+                for counts_file in .mercury_trace_counts.*
+                do
+                    if test -s "$counts_file"
+                    then
+                        name=`echo "$counts_file" | \
+                            sed -e 's/.mercury_trace_counts//'`
+                        mkdir -p $tests_dir/PASSED_TC_DIR
+                        mv $counts_file \
+                            $tests_dir/PASSED_TC_DIR/$counts_file.$name
+                        /bin/rm -f \
+                            $tests_dir/PASSED_TC_DIR/$counts_file.$name.gz
+                        gzip $tests_dir/PASSED_TC_DIR/$counts_file.$name
+                        echo $tests_dir/PASSED_TC_DIR/$counts_file.$name \
+                            >> $tests_dir/PASSED_TC_FILES
+                    fi
+                done
+                ;;
+        esac
+    fi
+fi
+
+case "$BOOTCHECK_TEST_PROGRESS" in
+    yes)
+        touch .date.$test
+        ;;
+esac
+
+exit $exitstatus
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
Index: tests/debugger/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/Mmakefile,v
retrieving revision 1.112
diff -u -b -r1.112 Mmakefile
--- tests/debugger/Mmakefile	7 Mar 2005 05:00:35 -0000	1.112
+++ tests/debugger/Mmakefile	7 Mar 2005 08:39:00 -0000
@@ -285,20 +285,24 @@
 	fi
 
 dice.pass1: dice
+	/bin/rm -f .mercury_trace_counts.*dice.*
 	MERCURY_OPTIONS=--trace-count ./dice 1 2 3 4 && \
-	mv .mercury_trace_counts dice.pass1
+	mv .mercury_trace_counts.*dice.* dice.pass1
 
 dice.pass2: dice
+	/bin/rm -f .mercury_trace_counts.*dice.*
 	MERCURY_OPTIONS=--trace-count ./dice 5 6 7 8 && \
-	mv .mercury_trace_counts dice.pass2
+	mv .mercury_trace_counts.*dice.* dice.pass2
 
 dice.pass3: dice
+	/bin/rm -f .mercury_trace_counts.*dice.*
 	MERCURY_OPTIONS=--trace-count ./dice 10 11 100 && \
-	mv .mercury_trace_counts dice.pass3
+	mv .mercury_trace_counts.*dice.* dice.pass3
 
 dice.fail: dice
+	/bin/rm -f .mercury_trace_counts.*dice.*
 	MERCURY_OPTIONS=--trace-count ./dice 4 1 2 3 && \
-	mv .mercury_trace_counts dice.fail
+	mv .mercury_trace_counts.*dice.* dice.fail
 
 dice.out: dice dice.inp dice.pass1 dice.pass2 dice.pass3 dice.fail
 	$(MDB_STD) ./dice 4 1 2 3 < dice.inp > dice.out 2>&1
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
Index: tools/bootcheck
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/tools/bootcheck,v
retrieving revision 1.166
diff -u -b -r1.166 bootcheck
--- tools/bootcheck	15 Feb 2005 05:22:38 -0000	1.166
+++ tools/bootcheck	7 Mar 2005 11:34:30 -0000
@@ -1,4 +1,5 @@
 #!/bin/sh
+# vim: ts=4 sw=4 wm=0 tw=0
 #---------------------------------------------------------------------------#
 # Copyright (C) 1995-2001 The University of Melbourne.
 # This file may only be copied under the terms of the GNU General
@@ -14,11 +15,20 @@
 		directories will be run. In the absence of any such options,
 		all tests in all directories will be run (unless testing
 		as a whole is disabled).
+    -s <testname>, --specified-test <testname>
+	    Run only the tests whose names are specified as arguments of this
+		option, which may be given more than once. The test names must include
+		the directory name component.
+	-f, --failing-tests
+		Run only the tests which failed on the last run, as recorded in the
+		FAILED_TESTS files in the various test directories. Meaningful only
+		in the absence of -s options.
+	--error-file
+		Run only the tests which failed on the last run, as recorded in the
+		tests/runtests.errs file. Meaningful only in the absence of -s and -f
+		options.
 	-e, --extras
 		Test the programs in the extras directory.
-	-f, --failing-tests
-		Run only the tests which failed on the last run. This
-		requires the tests/runtests.errs file from the previous run.
 	-h, --help
 		Display this usage message.
 	-j <num-jobs>, --jobs <num-jobs>
@@ -133,11 +143,17 @@
 		Keep the Deep.data files resulting from the bootcheck. The
 		usual behavior is to delete them in the interest of conserving
 		disk space.
+	--progress
+		Create a timestamp file when finishing the execution of each test case,
+		to allow the user to monitor the bootcheck's progress. The timestamp
+		files will have names of the form .date.<testname>.
 "
 
 unset WORKSPACE
 testdirs=""
+specified_tests_only=""
 failing_tests_only=false
+error_file_only=false
 extras=false
 jfactor=""
 keep_objs=false
@@ -146,7 +162,7 @@
 outfile=""
 runtests=true
 do_bootcheck=true
-if [ -f /bin/cygwin1.dll ]; then
+if test -f /bin/cygwin1.dll; then
 	# Don't run check_namespace on Cygwin, unless explicitly asked,
 	# because the `-nostdinc' option doesn't work with gcc 2.95 on Cygwin.
 	# (This has been fixed in later versions of gcc, e.g. 3.2, so
@@ -171,7 +187,7 @@
 windows=false
 use_cp=false
 A=a		# the extension for libraries
-if [ -d compiler/Mercury ]; then
+if test -d compiler/Mercury; then
 	use_subdirs=${MMAKE_USE_SUBDIRS=yes}
 else
 	use_subdirs=${MMAKE_USE_SUBDIRS=no}
@@ -183,6 +199,7 @@
 trace_count=false
 disable_debug_libs=false
 delete_deep_data=true
+progress=false
 
 if test -f .KEEP_OBJS
 then
@@ -208,7 +225,7 @@
 MDBCOMP_LIB_NAME=mer_mdbcomp
 ANALYSIS_LIB_NAME=mer_analysis
 
-while [ $# -gt 0 ]; do
+while test $# -gt 0; do
 	case "$1" in
 
 	-b-|--no-bootcheck)
@@ -222,9 +239,15 @@
 	-e|--extras)
 		extras=true ;;
 
+	-s|--specified-tests)
+		specified_tests_only="$specified_tests_only $2"; shift ;;
+
 	-f|--failing-tests)
 		failing_tests_only=true ;;
 
+	--error-file)
+		error_file_only=true ;;
+
 	-h|--help)
 		echo "$usage"
 		exit 0 ;;
@@ -324,7 +347,7 @@
 	--type-stats)
 		type_stats="$2"; shift ;;
 
-	--trace-count)
+	--trace-count|--trace-counts)
 		trace_count=true ;;
 
 	-W|--windows)
@@ -342,6 +365,9 @@
 	--keep-deep-data)
 		delete_deep_data=false ;;
 
+	--progress)
+		progress=true ;;
+
 	--)	
 		shift; break ;;
 	-*)
@@ -354,7 +380,7 @@
 	shift
 done
 
-if [ $# -ne 0 ]; then
+if test $# -ne 0; then
 	echo "$0: unexpected argument(s) \`$*'" 1>&2
 	echo "$usage" 1>&2
 	exit 1
@@ -366,22 +392,26 @@
 fi
 
 case $use_subdirs in
-	yes)	cs_subdir=Mercury/cs/
+	yes)
+		cs_subdir=Mercury/cs/
 		ss_subdir=Mercury/ss/
 		ils_subdir=Mercury/ils/
 		;;
-	no)	cs_subdir=
+	no)
+		cs_subdir=
 		ss_subdir=
 		ils_subdir=
 		;;
 esac
 
 case $target in
-	c)	target_ext=c
+	c)
+		target_ext=c
 		target_subdir=$cs_subdir
 		target_opt=
 		;;
-	asm)	target_ext=s
+	asm)
+		target_ext=s
 		target_subdir=$ss_subdir
 		target_opt="--target asm"
 		# If the stage 1 directory was built without --target asm, 
@@ -392,7 +422,8 @@
 		;;
 esac
 case $grade in
-	il|ilc)	target_ext=il
+	il|ilc)
+		target_ext=il
 		target_subdir=$ils_subdir
 		target_opt=
 		# See comment above
@@ -478,8 +509,42 @@
 	stage3dir=stage3
 fi
 
+if $progress
+then
+	BOOTCHECK_TEST_PROGRESS=yes
+	export BOOTCHECK_TEST_PROGRESS
+fi
+
+ORIG_MERCURY_OPTIONS="$MERCURY_OPTIONS"
+
+if $write_out_profile_data
+then
+	true
+else
+	# Turn off the writing out of deep profiling files, since
+	# Deep.data will be overwritten many times in each directory,
+	# and thus the time spent writing them out is wasted. If deep
+	# profiling debugging is enabled, this also avoids the writing
+	# of *huge* amounts of stuff on stderr.
+	MERCURY_OPTIONS="$MERCURY_OPTIONS -s"
+	export MERCURY_OPTIONS
+fi
+
+if $trace_count
+then
+	MERCURY_OPTIONS="$MERCURY_OPTIONS --trace-count"
+	export MERCURY_OPTIONS
+else
+	true
+fi
+
+NEW_MERCURY_OPTIONS="$MERCURY_OPTIONS"
+
 if $do_bootcheck
 then
+	MERCURY_OPTIONS="$ORIG_MERCURY_OPTIONS"
+	export MERCURY_OPTIONS
+
 	if mmake $mmake_opts MMAKEFLAGS=$jfactor all
 	then
 		echo "building of stage 1 successful"
@@ -495,26 +560,8 @@
 		fi
 	fi
 
-	if $write_out_profile_data
-	then
-		true
-	else
-		# Turn off the writing out of deep profiling files, since
-		# Deep.data will be overwritten many times in each directory,
-		# and thus the time spent writing them out is wasted. If deep
-		# profiling debugging is enabled, this also avoids the writing
-		# of *huge* amounts of stuff on stderr.
-		MERCURY_OPTIONS="$MERCURY_OPTIONS -s"
-		export MERCURY_OPTIONS
-	fi
-
-	if $trace_count
-	then
-		MERCURY_OPTIONS="$MERCURY_OPTIONS --trace-count"
+	MERCURY_OPTIONS="$NEW_MERCURY_OPTIONS"
 		export MERCURY_OPTIONS
-	else
-		true
-	fi
 
 	MERCURY_COMPILER=$root/compiler/mercury_compile
 	export MERCURY_COMPILER
@@ -522,7 +569,7 @@
 	MERCURY_CONFIG_FILE=$root/scripts/Mercury.config
 	export MERCURY_CONFIG_FILE
 
-	[ -d $stage2dir ] || mkdir $stage2dir
+	test -d $stage2dir || mkdir $stage2dir
 	if $keep_stage_2
 	then
 		echo keeping existing stage2
@@ -937,7 +984,7 @@
 	MERCURY_COMPILER=$root/$stage2dir/compiler/mercury_compile
 	export MERCURY_COMPILER
 
-	[ -d $stage3dir ] || mkdir $stage3dir
+	test -d $stage3dir || mkdir $stage3dir
 	if $keep_stage_3
 	then
 		echo keeping existing stage3
@@ -1169,7 +1216,7 @@
 	diff_status=0
 
 	exec 3>&1		# save stdout in fd 3
-	if [ -n "$outfile" ]
+	if test -n "$outfile"
 	then
 		exec > "$outfile"	# redirect stdout to $outfile
 	fi
@@ -1185,7 +1232,8 @@
 	done
 
 	exec >&3		# restore stdout from fd 3
-	if [ $diff_status -ne 0 ]; then
+	if test $diff_status -ne 0
+	then
 		echo "** error - stage 2 and stage 3 differ!"
 	else
 		echo "stage 2 and stage 3 compare ok"
@@ -1327,36 +1375,65 @@
 		then
 			cp $root/$stage2dir/Mmake.params ${tests_prefix}tests
 		else
-			/bin/rm ${tests_prefix}tests/Mmake.params \
-				> /dev/null 2>&1
+			/bin/rm ${tests_prefix}tests/Mmake.params > /dev/null 2>&1
 		fi
 
 		cp $root/doc/mdb_command_test.inp ${tests_prefix}tests/debugger
 
-		case $failing_tests_only in
+		case $error_file_only in
 			true)
-				if [ ! -f ${tests_prefix}tests/runtests.errs ]
+				if test ! -f ${tests_prefix}tests/runtests.errs
 				then
+					echo "bootcheck: \`--failing-tests' specified but" 1>&2
 					echo \
-		"bootcheck: \`--failing-tests' specified but" 1>&2
-					echo \
-		"\`${tests_prefix}tests/runtests.errs' does not exist." 1>&2
+					"\`${tests_prefix}tests/runtests.errs' does not exist." \
+						1>&2
 					exit 1
 				fi
 
 				mv ${tests_prefix}tests/runtests.errs \
 					${tests_prefix}tests/runtests.$$
-				test_log_opt=\
-			"ERROR_FILE=${tests_prefix}tests/runtests.$$"
+				test_log_opt="ERROR_FILE=$root/${tests_prefix}tests/runtests.$$"
 				;;
 			false)
 				test_log_opt=""
 				;;
 		esac
 			
+		case $failing_tests_only in
+			true)
+				test_log_opt="FAILING_TESTS_ONLY"
+				;;
+		esac
+
+		cd $root/${tests_prefix}tests
+		/bin/rm -fr PASSED_TC_DIR PASSED_TC_FILES > /dev/null 2>&1
+		/bin/rm -fr FAILED_TC_DIR FAILED_TC_FILES > /dev/null 2>&1
+		> FAILED_TESTS_SUMMARY
+
+		if test "$specified_tests_only" != ""
+		then
+			test_status=0
+			for specified_test in $specified_tests_only
+			do
+				specified_test_dir=`dirname $specified_test`
+				specified_test_base=`basename $specified_test`
+				if test -d "$root/${tests_prefix}/tests/$specified_test_dir"
+				then
+					cd $root/${tests_prefix}tests/$specified_test_dir
+					mmake $target_opt $jfactor $test_grade_opt \
+						SPECIFIED_TESTS="$specified_test_base" runtests
+					if test "$?" -ne "0"
+					then
+						test_status=$?
+					fi
+				else
+					test_status=1
+				fi
+			done
+		else
 		if test "$testdirs" = ""
 		then
-			cd ${tests_prefix}tests
 			mmake $target_opt $jfactor $test_grade_opt \
 				$test_log_opt runtests
 		else
@@ -1368,6 +1445,7 @@
 			done
 		fi
 		test_status=$?
+		fi
 
 		case $failing_tests_only in
 			true)	rm -f ${tests_prefix}tests/runtests.$$ ;;
@@ -1474,6 +1552,11 @@
 then
 	echo "error exit: some namespace isn't clean"
 	exitstatus=1
+fi
+
+if test -s $root/${tests_prefix}tests/FAILED_TESTS_SUMMARY
+then
+	cat $root/${tests_prefix}tests/FAILED_TESTS_SUMMARY
 fi
 
 echo "finishing at `date`"
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list