mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 09:23:44 +00:00
Estimated hours taken: 2 bootcheck, binary, linear: Link to absolute, not relative path names, since relative path names do not work back across symbolic links. binary, linear: Allow the user to give an initial list of suspects. assemble, binary, linear: Allow negative searches, i.e. searches in which the base version is the bad version and we want to see which module "fixes" the problem caused by the other modules, as opposed to normal searches in which we are looking for the module that introduces the problem.
240 lines
5.0 KiB
Bash
Executable File
240 lines
5.0 KiB
Bash
Executable File
#!/bin/sh
|
|
# Test the stage2 directory to see whether it passes
|
|
# a bootstrap check and/or a check using the tests directory.
|
|
# If stage2 passes, binary_step returns an exit status of 0 (true);
|
|
# if it fails, binary_step returns an exit status of 1 (false).
|
|
#
|
|
# binary_step remakes the archive in stage2/library and the executable
|
|
# in stage2/compiler. In the intended use, the binary script sets up
|
|
# these directories so that these actions cause no recompilations,
|
|
# either Mercury to C or C to object, only linking. Other uses probably
|
|
# won't work.
|
|
|
|
usage="\
|
|
Usage: $0 [options]
|
|
Options:
|
|
-b, --no-bootcheck
|
|
Do not perform a bootcheck; check only the tests directory.
|
|
-c, --compile-only
|
|
Compile only. Do not compare stage2.ok and stage3.
|
|
-h, --help
|
|
Display this usage message.
|
|
-j <num-jobs>, --jobs <num-jobs>
|
|
Run using <num-jobs> different parallel processes.
|
|
-m <mmake-args>, --mmake-args <mmake-args>
|
|
Pass <mmake-args> as options to \`mmake'.
|
|
-o <filename>, --output-file <filename>
|
|
Output results to <filename>.
|
|
-t <testdir>, --test-dir <testdir>
|
|
Execute runtests from the named subdirectory of tests.
|
|
"
|
|
|
|
set -x
|
|
|
|
alltestdirs="benchmarks general hard_coded invalid valid warnings"
|
|
|
|
bootcheck="true"
|
|
compile_only="false"
|
|
jfactor=""
|
|
mmake_opts=""
|
|
outfile="DIFF.BINARY"
|
|
testdirs=""
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
|
|
-b|--no-bootcheck)
|
|
bootcheck="false" ;;
|
|
|
|
-c|--compile-only)
|
|
compile_only="true" ;;
|
|
|
|
-h|--help)
|
|
echo "$usage"
|
|
exit 0 ;;
|
|
|
|
-j|--jobs)
|
|
jfactor="-j$2"; shift ;;
|
|
-j*)
|
|
jfactor="-j` expr $1 : '-j\(.*\)' `" ;;
|
|
--jobs*)
|
|
jfactor="--jobs` expr $1 : '--jobs\(.*\)' `" ;;
|
|
|
|
-m|--mmake)
|
|
mmake_opts="$mmake_opts $2"; shift ;;
|
|
|
|
-o|--output-file)
|
|
outfile="$2"; shift ;;
|
|
-o*)
|
|
outfile="` expr $1 : '-o\(.*\)' `"; ;;
|
|
|
|
-t|--test-dir)
|
|
testdir="$2"; shift
|
|
if test -d tests/$testdir
|
|
then
|
|
testdirs="$testdirs $testdir"
|
|
else
|
|
if test "$testdir" = "all"
|
|
then
|
|
testdirs="$alltestdirs"
|
|
else
|
|
echo "tests has no subdirectory named $testdir"
|
|
fi
|
|
fi ;;
|
|
-t*)
|
|
testdir="` expr $1 : '-t\(.*\)' `"
|
|
if test -d tests/$testdir
|
|
then
|
|
testdirs="$testdirs $testdir"
|
|
else
|
|
if test "$testdir" = "all"
|
|
then
|
|
testdirs="$alltestdirs"
|
|
else
|
|
echo "tests has no subdirectory named $testdir"
|
|
fi
|
|
fi ;;
|
|
|
|
-*)
|
|
echo "$0: unknown option \`$1'" 1>&2
|
|
echo "$usage" 1>&2
|
|
exit 1 ;;
|
|
|
|
*)
|
|
echo "$usage" 1>&2
|
|
exit 1 ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
root=`/bin/pwd`
|
|
|
|
MERCURY_COMPILER=$root/stage1/mercury_compile
|
|
export MERCURY_COMPILER
|
|
MERCURY_INT_DIR=$root/stage2/library
|
|
export MERCURY_INT_DIR
|
|
|
|
MMAKE_VPATH=.
|
|
export MMAKE_VPATH
|
|
MMAKE_DIR=../scripts
|
|
export MMAKE_DIR
|
|
|
|
# Ensure that mmake will not disturb the .o and .c files placed there by binary
|
|
|
|
set +x
|
|
|
|
touch stage2/library/*.c
|
|
touch stage2/compiler/*.c
|
|
|
|
sleep 2
|
|
|
|
touch stage2/library/*.o
|
|
touch stage2/compiler/*.o
|
|
|
|
# Rebuild the stage2 library and compiler from the components already there.
|
|
|
|
/bin/rm -f stage2/library/libmercury.a stage2/library/libmercury.so
|
|
/bin/rm -f stage2/compiler/mercury_compile
|
|
|
|
set -x
|
|
|
|
# the `RM_C=:' ensures that the `.c' files do not get deleted
|
|
|
|
if (cd stage2/library ; mmake $mmake_opts $jfactor RM_C=: libmercury)
|
|
then
|
|
echo "building of stage 2 library successful"
|
|
else
|
|
echo "building of stage 2 library not successful"
|
|
exit 1
|
|
fi
|
|
|
|
if (cd stage2/compiler ; mmake $mmake_opts $jfactor RM_C=: mercury_compile)
|
|
then
|
|
echo "building of stage 2 compiler successful"
|
|
else
|
|
echo "building of stage 2 compiler not successful"
|
|
exit 1
|
|
fi
|
|
|
|
unset MMAKE_VPATH
|
|
unset MMAKE_DIR
|
|
|
|
MERCURY_COMPILER=$root/stage2/compiler/mercury_compile
|
|
export MERCURY_COMPILER
|
|
MERCURY_INT_DIR=$root/stage3/library
|
|
export MERCURY_INT_DIR
|
|
|
|
if "$bootcheck" = true
|
|
then
|
|
|
|
# Rebuild the stage3 library and compiler from scratch
|
|
|
|
/bin/rm -f stage3/library/*.c
|
|
/bin/rm -f stage3/compiler/*.c
|
|
|
|
if (cd stage3 ; mmake $mmake_opts depend_library depend_compiler)
|
|
then
|
|
echo "building of stage 3 dependencies successful"
|
|
else
|
|
echo "building of stage 3 dependencies not successful"
|
|
exit 1
|
|
fi
|
|
|
|
MMAKE_VPATH=.
|
|
export MMAKE_VPATH
|
|
MMAKE_DIR=../scripts
|
|
export MMAKE_DIR
|
|
|
|
if (cd stage3/library ; mmake -S $mmake_opts $jfactor cs)
|
|
then
|
|
echo "building of stage 3 library successful"
|
|
else
|
|
echo "building of stage 3 library not successful"
|
|
exit 1
|
|
fi
|
|
|
|
if (cd stage3/compiler ; mmake -S $mmake_opts $jfactor cs)
|
|
then
|
|
echo "building of stage 3 compiler successful"
|
|
else
|
|
echo "building of stage 3 compiler not successful"
|
|
exit 1
|
|
fi
|
|
|
|
if test "$compile_only" = false
|
|
then
|
|
founddiff=false
|
|
cat /dev/null > $outfile
|
|
for dir in library compiler
|
|
do
|
|
for file in stage2.ok/$dir/*.c
|
|
do
|
|
stage3file="stage3/$dir/`basename $file`"
|
|
diff -u $file $stage3file >> $outfile ||
|
|
founddiff=true
|
|
done
|
|
done
|
|
|
|
if "$founddiff" = true
|
|
then
|
|
echo "error - stage2.ok and stage3 differ!"
|
|
exit 1
|
|
else
|
|
echo "stage2.ok and stage3 compare ok"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
for testdir in $testdirs
|
|
do
|
|
if (cd tests/$testdir; runtests)
|
|
then
|
|
echo "tests in the $testdir directory successful"
|
|
else
|
|
echo "tests in the $testdir directory not successful"
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
exit 0
|