mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-19 07:45:09 +00:00
Estimated hours taken: 24 Branches: main Add two new command line tools "mslice" and "mdice", which manipulate slices and dices respectively. The functionality of "mdice" duplicates the functionality of mdb's current "dice" command, while the functionality of "mslice" is new. runtime/mercury_trace_base.[ch]: When generating trace count files, include information about the context of each execution count. While mdb has access to this information in the running program, mslice and mdice do not. In any case, the code in mdb for looking up this information was terribly inefficient. Provide a mechanism for recording all execution counts, even the zero ones, for use in coverage testing. This mechanism is not used yet. Put a header on trace counts files, to make them recognizable as such. Make this header indicate whether we are including zero trace counts. runtime/mercury_wrapper.c: Provide a flag in MERCURY_OPTIONS for turning on recording of zero execution counts. browser/dice.m: mdbcomp/slice_and_dice.m: Move most of the code of browser/dice.m to mdbcomp/slice_and_dice.m, much modified; browser/dice.m is now empty. The modifications are as follows. Factor out the code for reading dices, since dices are useful independent of mdb's dice command. Generalize the code for computing dices to allow either or both of the slices being subtracted to be specified as the union of one or more trace counts files. Add two more sort conditions for comparing the execution counts in two slices: ascending and descending versions of simple execution count differences. For each operation we have so far performed on dices, add code for performing that operation on slices. browser/mdb.m: Delete the include of dice.m, since it is now empty. Delete a duplicate include_module of term_rep, and delete the now unnecessary include_modules of set_cc and tree234_cc. mdbcomp/mdbcomp.m: Add slice_and_dice.m as a submodule. mdbcomp/trace_counts.m: Provide a mechanism to allow a slice to be specified as coming not from a single trace count file but from the union operation on a set of trace count files. Convert to four-space indentation to eliminate some excessively indented lines. slice/mdice.m: slice/mslice.m: The main modules of two new commands. Their functionality is almost entirely in mdbcomp/slice_and_dice.m and mdbcomp/trace_counts.m. slice/Mmakefile: New Mmakefile for building mslice and mdice. It is modelled on profiler/Mmakefile. slice/Mercury.options: Empty file, for use in the future. slice/.nocopyright: Don't require copyright notice in Mercury.options. Mmakefile: Process the slice directory at appropriate points when processing other directories. compiler/tupling.m: Conform to the updated interface of mdbcomp/trace_counts. library/list.m: Add versions of list__map for some more arities, for use in the code above. trace/mercury_trace_internal.c: Generalize the code for specifying dices to allow either or both of the slices being subtracted to be specified as the union of one or more trace counts files. Fix several places where we weren't checking the return value of malloc. Fix two places where we could conceivably free strings that were still alive. Fix some places where we could pass NULL strings to Mercury code, and some places where we could free NULL pointers (which, once upon a time, was not guaranteed to work on all platforms). Use existing functions such as MR_copy_string where appropriate. tests/run_one_test: Fix two small bugs in this script: make the filenames more user friendly, and make sure that gzip isn't asked to overwrite an existing file, since that causes it to ask a question on stdout and to wait for an answer. tools/bootcheck: Copy or link the slice directory into stage 2. Rename the --copy-profiler option as --copy-profilers, since it now copies three directories containing performance engineering tools: profiler, deep_profiler and slice.
88 lines
2.5 KiB
Bash
Executable File
88 lines
2.5 KiB
Bash
Executable File
#!/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
|
|
tcdir=FAILED_TC_DIR
|
|
tcfile=FAILED_TC_FILES
|
|
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
|
|
tcdir=PASSED_TC_DIR
|
|
tcfile=PASSED_TC_FILES
|
|
fi
|
|
case "$trace_count" in
|
|
true)
|
|
mkdir -p $tests_dir/$tcdir
|
|
testname=`echo $this_dir/$test_full | tr '[/]' '[:]'`
|
|
for counts_file in .mercury_trace_counts.*
|
|
do
|
|
if test -s "$counts_file"
|
|
then
|
|
progpidname=`echo "$counts_file" | \
|
|
sed -e 's/.mercury_trace_counts.//'`
|
|
name="TEST_${testname}_PROG_${progpidname}"
|
|
mv $counts_file $tests_dir/$tcdir/$name
|
|
/bin/rm -f $tests_dir/$tcdir/$name.gz
|
|
gzip $tests_dir/$tcdir/$name
|
|
echo $tcdir/$name >> $tests_dir/$tcfile
|
|
fi
|
|
done
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
case "$BOOTCHECK_TEST_PROGRESS" in
|
|
yes)
|
|
touch .date.$test
|
|
;;
|
|
esac
|
|
|
|
exit $exitstatus
|