2014-03-19 12:29:20 +00:00
|
|
|
# $FreeBSD$
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
|
|
|
# Common code used run regression tests for usr.bin/make.
|
|
|
|
|
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# Output a message and exit with an error.
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
fatal()
|
2005-04-28 13:20:48 +00:00
|
|
|
{
|
2005-05-31 14:13:07 +00:00
|
|
|
echo "fatal: $*" >/dev/stderr
|
|
|
|
exit 1
|
2005-04-28 13:20:48 +00:00
|
|
|
}
|
|
|
|
|
2014-03-12 10:38:32 +00:00
|
|
|
make_is_fmake() {
|
|
|
|
# This test is not very reliable but works for now: the old fmake
|
|
|
|
# does have a -v option while bmake doesn't.
|
|
|
|
${MAKE_PROG} -f Makefile.non-existent -v 2>&1 | \
|
|
|
|
grep -q "cannot open.*non-existent"
|
|
|
|
}
|
|
|
|
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# Check whether the working directory exists - it must.
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
ensure_workdir()
|
|
|
|
{
|
|
|
|
if [ ! -d ${WORK_DIR} ] ; then
|
|
|
|
fatal "working directory ${WORK_DIR} does not exist."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Make sure all tests have been run
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
ensure_run()
|
2005-04-28 13:20:48 +00:00
|
|
|
{
|
2005-05-31 14:13:07 +00:00
|
|
|
if [ -z "${TEST_N}" ] ; then
|
|
|
|
TEST_N=1
|
|
|
|
fi
|
2005-04-28 13:20:48 +00:00
|
|
|
|
2005-05-31 14:13:07 +00:00
|
|
|
FAIL=
|
|
|
|
N=1
|
|
|
|
while [ ${N} -le ${TEST_N} ] ; do
|
2005-06-01 11:25:38 +00:00
|
|
|
if ! skip_test ${N} ; then
|
2005-05-31 14:13:07 +00:00
|
|
|
if [ ! -f ${OUTPUT_DIR}/status.${N} -o \
|
|
|
|
! -f ${OUTPUT_DIR}/stdout.${N} -o \
|
|
|
|
! -f ${OUTPUT_DIR}/stderr.${N} ] ; then
|
|
|
|
echo "Test ${SUBDIR}/${N} no yet run"
|
|
|
|
FAIL=yes
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
N=$((N + 1))
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ! -z "${FAIL}" ] ; then
|
|
|
|
exit 1
|
2005-04-28 13:20:48 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# Output usage messsage.
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
print_usage()
|
2005-04-28 13:20:48 +00:00
|
|
|
{
|
2005-05-31 14:13:07 +00:00
|
|
|
echo "Usage: sh -v -m <path> -w <dir> $0 command(s)"
|
|
|
|
echo " setup - setup working directory"
|
|
|
|
echo " run - run the tests"
|
|
|
|
echo " show - show test results"
|
|
|
|
echo " compare - compare actual and expected results"
|
|
|
|
echo " diff - diff actual and expected results"
|
|
|
|
echo " reset - reset the test to its initial state"
|
|
|
|
echo " clean - delete working and output directory"
|
|
|
|
echo " test - setup + run + compare"
|
|
|
|
echo " prove - setup + run + compare + clean"
|
|
|
|
echo " desc - print short description"
|
|
|
|
echo " update - update the expected results with the current results"
|
|
|
|
echo " help - show this information"
|
|
|
|
}
|
2005-04-28 13:20:48 +00:00
|
|
|
|
2005-06-01 11:25:38 +00:00
|
|
|
#
|
|
|
|
# Return 0 if we should skip the test. 1 otherwise
|
|
|
|
#
|
|
|
|
skip_test()
|
|
|
|
{
|
|
|
|
eval skip=\${TEST_${1}_SKIP}
|
|
|
|
if [ -z "${skip}" ] ; then
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2005-05-31 14:13:07 +00:00
|
|
|
#
|
|
|
|
# Common function for setup and reset.
|
|
|
|
#
|
|
|
|
common_setup()
|
|
|
|
{
|
|
|
|
#
|
|
|
|
# If a Makefile exists in the source directory - copy it over
|
|
|
|
#
|
2014-03-19 12:29:20 +00:00
|
|
|
if [ -e ${SRC_DIR}/Makefile.test -a ! -e ${WORK_DIR}/Makefile ] ; then
|
|
|
|
cp ${SRC_DIR}/Makefile.test ${WORK_DIR}/Makefile
|
2005-04-28 13:20:48 +00:00
|
|
|
fi
|
2005-05-31 14:13:07 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# If the TEST_MAKE_DIRS variable is set, create those directories
|
|
|
|
#
|
|
|
|
set -- ${TEST_MAKE_DIRS}
|
|
|
|
while [ $# -ne 0 ] ; do
|
|
|
|
if [ ! -d ${WORK_DIR}/${1} ] ; then
|
|
|
|
mkdir -p -m ${2} ${WORK_DIR}/${1}
|
|
|
|
else
|
|
|
|
chmod ${2} ${WORK_DIR}/${1}
|
|
|
|
fi
|
|
|
|
shift ; shift
|
|
|
|
done
|
|
|
|
|
|
|
|
#
|
|
|
|
# If the TEST_COPY_FILES variable is set, copy those files over to
|
|
|
|
# the working directory. The value is assumed to be pairs of
|
|
|
|
# filenames and modes.
|
|
|
|
#
|
|
|
|
set -- ${TEST_COPY_FILES}
|
|
|
|
while [ $# -ne 0 ] ; do
|
2014-03-19 12:29:20 +00:00
|
|
|
local dstname="$(echo ${1} | sed -e 's,Makefile.test,Makefile,')"
|
|
|
|
if [ ! -e ${WORK_DIR}/${dstname} ] ; then
|
|
|
|
cp ${SRC_DIR}/${1} ${WORK_DIR}/${dstname}
|
2005-05-31 14:13:07 +00:00
|
|
|
fi
|
2014-03-19 12:29:20 +00:00
|
|
|
chmod ${2} ${WORK_DIR}/${dstname}
|
2005-05-31 14:13:07 +00:00
|
|
|
shift ; shift
|
|
|
|
done
|
|
|
|
|
|
|
|
#
|
|
|
|
# If the TEST_TOUCH variable is set, it is taken to be a list
|
|
|
|
# of pairs of filenames and arguments to touch(1). The arguments
|
|
|
|
# to touch must be surrounded by single quotes if there are more
|
|
|
|
# than one argument.
|
|
|
|
#
|
|
|
|
eval set -- ${TEST_TOUCH}
|
|
|
|
while [ $# -ne 0 ] ; do
|
|
|
|
eval touch ${2} ${WORK_DIR}/${1}
|
|
|
|
shift ; shift
|
|
|
|
done
|
|
|
|
|
|
|
|
#
|
|
|
|
# Now create links
|
|
|
|
#
|
|
|
|
eval set -- ${TEST_LINKS}
|
|
|
|
while [ $# -ne 0 ] ; do
|
|
|
|
eval ln ${WORK_DIR}/${1} ${WORK_DIR}/${2}
|
|
|
|
shift ; shift
|
|
|
|
done
|
2005-04-28 13:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# Setup the test. This creates the working and output directories and
|
|
|
|
# populates it with files. If there is a setup_test() function - call it.
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
eval_setup()
|
|
|
|
{
|
|
|
|
#
|
|
|
|
# Check whether the working directory exists. If it does exit
|
|
|
|
# fatally so that we don't clobber a test the user is working on.
|
|
|
|
#
|
|
|
|
if [ -d ${WORK_DIR} ] ; then
|
|
|
|
fatal "working directory ${WORK_DIR} already exists."
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Now create it and the output directory
|
|
|
|
#
|
|
|
|
mkdir -p ${WORK_DIR}
|
|
|
|
rm -rf ${OUTPUT_DIR}
|
|
|
|
mkdir -p ${OUTPUT_DIR}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Common stuff
|
|
|
|
#
|
|
|
|
common_setup
|
|
|
|
|
|
|
|
#
|
|
|
|
# Now after all execute the user's setup function if it exists.
|
|
|
|
#
|
|
|
|
setup_test
|
|
|
|
}
|
|
|
|
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# Default setup_test function does nothing. This may be overriden by
|
|
|
|
# the test.
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
|
|
|
setup_test()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# Reset the test. Here we need to rely on information from the test.
|
|
|
|
# We executed the same steps as in the setup, by try not to clobber existing
|
|
|
|
# files.
|
|
|
|
# All files and directories that are listed on the TEST_CLEAN_FILES
|
|
|
|
# variable are removed. Then the TEST_TOUCH list is executed and finally
|
|
|
|
# the reset_test() function called if it exists.
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
eval_reset()
|
|
|
|
{
|
|
|
|
ensure_workdir
|
|
|
|
|
|
|
|
#
|
|
|
|
# Clean the output directory
|
|
|
|
#
|
|
|
|
rm -rf ${OUTPUT_DIR}/*
|
|
|
|
|
|
|
|
#
|
|
|
|
# Common stuff
|
|
|
|
#
|
|
|
|
common_setup
|
|
|
|
|
|
|
|
#
|
|
|
|
# Remove files.
|
|
|
|
#
|
|
|
|
for f in ${TEST_CLEAN_FILES} ; do
|
|
|
|
rm -rf ${WORK_DIR}/${f}
|
|
|
|
done
|
|
|
|
|
|
|
|
#
|
|
|
|
# Execute test's function
|
|
|
|
#
|
|
|
|
reset_test
|
|
|
|
}
|
|
|
|
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# Default reset_test function does nothing. This may be overriden by
|
|
|
|
# the test.
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
reset_test()
|
2005-04-28 13:20:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# Clean the test. This simply removes the working and output directories.
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
eval_clean()
|
2005-04-28 13:20:48 +00:00
|
|
|
{
|
2010-01-04 18:57:22 +00:00
|
|
|
#
|
|
|
|
# If you have special cleaning needs, provide a 'cleanup' shell script.
|
|
|
|
#
|
|
|
|
if [ -n "${TEST_CLEANUP}" ] ; then
|
|
|
|
. ${SRC_DIR}/cleanup
|
|
|
|
fi
|
2012-06-20 21:38:16 +00:00
|
|
|
if [ -z "${NO_TEST_CLEANUP}" ] ; then
|
|
|
|
rm -rf ${WORK_DIR}
|
|
|
|
rm -rf ${OUTPUT_DIR}
|
|
|
|
fi
|
2005-04-28 13:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# Run the test.
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
eval_run()
|
|
|
|
{
|
|
|
|
ensure_workdir
|
|
|
|
|
|
|
|
if [ -z "${TEST_N}" ] ; then
|
|
|
|
TEST_N=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
N=1
|
|
|
|
while [ ${N} -le ${TEST_N} ] ; do
|
2005-06-01 11:25:38 +00:00
|
|
|
if ! skip_test ${N} ; then
|
2005-05-31 14:13:07 +00:00
|
|
|
( cd ${WORK_DIR} ;
|
|
|
|
exec 1>${OUTPUT_DIR}/stdout.${N} 2>${OUTPUT_DIR}/stderr.${N}
|
|
|
|
run_test ${N}
|
|
|
|
echo $? >${OUTPUT_DIR}/status.${N}
|
|
|
|
)
|
|
|
|
fi
|
|
|
|
N=$((N + 1))
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Default run_test() function. It can be replaced by the
|
|
|
|
# user specified regression test. The argument to this function is
|
|
|
|
# the test number.
|
|
|
|
#
|
|
|
|
run_test()
|
2005-04-28 13:20:48 +00:00
|
|
|
{
|
2005-05-31 14:13:07 +00:00
|
|
|
eval args=\${TEST_${1}-test${1}}
|
|
|
|
${MAKE_PROG} $args
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Show test results.
|
|
|
|
#
|
|
|
|
eval_show()
|
|
|
|
{
|
|
|
|
ensure_workdir
|
|
|
|
|
|
|
|
if [ -z "${TEST_N}" ] ; then
|
|
|
|
TEST_N=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
N=1
|
|
|
|
while [ ${N} -le ${TEST_N} ] ; do
|
2005-06-01 11:25:38 +00:00
|
|
|
if ! skip_test ${N} ; then
|
2005-05-31 14:13:07 +00:00
|
|
|
echo "=== Test ${N} Status =================="
|
|
|
|
cat ${OUTPUT_DIR}/status.${N}
|
|
|
|
echo ".......... Stdout .................."
|
|
|
|
cat ${OUTPUT_DIR}/stdout.${N}
|
|
|
|
echo ".......... Stderr .................."
|
|
|
|
cat ${OUTPUT_DIR}/stderr.${N}
|
|
|
|
fi
|
|
|
|
N=$((N + 1))
|
|
|
|
done
|
2005-04-28 13:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Compare results with expected results
|
|
|
|
#
|
|
|
|
eval_compare()
|
|
|
|
{
|
2005-05-31 14:13:07 +00:00
|
|
|
ensure_workdir
|
|
|
|
ensure_run
|
2005-04-28 13:20:48 +00:00
|
|
|
|
2005-05-31 14:13:07 +00:00
|
|
|
if [ -z "${TEST_N}" ] ; then
|
|
|
|
TEST_N=1
|
2005-04-28 13:20:48 +00:00
|
|
|
fi
|
2005-05-31 14:13:07 +00:00
|
|
|
|
|
|
|
echo "1..${TEST_N}"
|
|
|
|
N=1
|
|
|
|
while [ ${N} -le ${TEST_N} ] ; do
|
2005-06-01 11:25:38 +00:00
|
|
|
fail=
|
|
|
|
todo=
|
2014-03-12 10:38:32 +00:00
|
|
|
skip=
|
2005-06-01 11:25:38 +00:00
|
|
|
if ! skip_test ${N} ; then
|
|
|
|
do_compare stdout ${N} || fail="${fail}stdout "
|
|
|
|
do_compare stderr ${N} || fail="${fail}stderr "
|
|
|
|
do_compare status ${N} || fail="${fail}status "
|
|
|
|
eval todo=\${TEST_${N}_TODO}
|
2014-03-12 10:38:32 +00:00
|
|
|
else
|
|
|
|
eval skip=\${TEST_${N}_SKIP}
|
2005-06-01 11:25:38 +00:00
|
|
|
fi
|
2014-03-19 12:29:20 +00:00
|
|
|
msg=
|
2005-06-01 11:25:38 +00:00
|
|
|
if [ ! -z "$fail" ]; then
|
2014-03-19 12:29:20 +00:00
|
|
|
msg="${msg}not "
|
2005-06-01 11:25:38 +00:00
|
|
|
fi
|
2014-03-19 12:29:20 +00:00
|
|
|
msg="${msg}ok ${N} ${SUBDIR}/${N}"
|
2014-03-12 10:38:32 +00:00
|
|
|
if [ ! -z "$fail" -o ! -z "$todo" -o ! -z "$skip" ]; then
|
2014-03-19 12:29:20 +00:00
|
|
|
msg="${msg} # "
|
2005-06-01 11:25:38 +00:00
|
|
|
fi
|
2014-03-12 10:38:32 +00:00
|
|
|
if [ ! -z "$skip" ] ; then
|
2014-03-19 12:29:20 +00:00
|
|
|
msg="${msg}skip ${skip}; "
|
2014-03-12 10:38:32 +00:00
|
|
|
fi
|
2005-06-01 11:25:38 +00:00
|
|
|
if [ ! -z "$todo" ] ; then
|
2014-03-19 12:29:20 +00:00
|
|
|
msg="${msg}TODO ${todo}; "
|
2005-06-01 11:25:38 +00:00
|
|
|
fi
|
|
|
|
if [ ! -z "$fail" ] ; then
|
2014-03-19 12:29:20 +00:00
|
|
|
msg="${msg}reason: ${fail}"
|
2005-05-31 14:13:07 +00:00
|
|
|
fi
|
2014-03-19 12:29:20 +00:00
|
|
|
echo ${msg}
|
2005-05-31 14:13:07 +00:00
|
|
|
N=$((N + 1))
|
|
|
|
done
|
2005-04-28 13:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# Check if the test result is the same as the expected result.
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# $1 Input file
|
|
|
|
# $2 Test number
|
|
|
|
#
|
|
|
|
do_compare()
|
2005-04-28 13:20:48 +00:00
|
|
|
{
|
2005-05-31 14:13:07 +00:00
|
|
|
local EXPECTED RESULT
|
2014-03-19 12:29:20 +00:00
|
|
|
EXPECTED="${SRC_DIR}/expected.$1.$2"
|
2005-05-31 14:13:07 +00:00
|
|
|
RESULT="${OUTPUT_DIR}/$1.$2"
|
2005-04-28 13:20:48 +00:00
|
|
|
|
2005-05-31 14:13:07 +00:00
|
|
|
if [ -f $EXPECTED ]; then
|
2014-03-19 12:29:20 +00:00
|
|
|
cat $RESULT | sed -e "s,^$(basename $MAKE_PROG):,make:," | \
|
|
|
|
diff -u $EXPECTED -
|
|
|
|
#diff -q $EXPECTED - 1>/dev/null 2>/dev/null
|
2005-05-31 14:13:07 +00:00
|
|
|
return $?
|
2005-04-28 13:20:48 +00:00
|
|
|
else
|
2005-05-31 14:13:07 +00:00
|
|
|
return 1 # FAIL
|
2005-04-28 13:20:48 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# Diff current and expected results
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
eval_diff()
|
2005-04-28 13:20:48 +00:00
|
|
|
{
|
2005-05-31 14:13:07 +00:00
|
|
|
ensure_workdir
|
|
|
|
ensure_run
|
|
|
|
|
|
|
|
if [ -z "${TEST_N}" ] ; then
|
|
|
|
TEST_N=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
N=1
|
|
|
|
while [ ${N} -le ${TEST_N} ] ; do
|
2005-06-01 11:25:38 +00:00
|
|
|
if ! skip_test ${N} ; then
|
2005-05-31 14:13:07 +00:00
|
|
|
FAIL=
|
|
|
|
do_diff stdout ${N}
|
|
|
|
do_diff stderr ${N}
|
|
|
|
do_diff status ${N}
|
|
|
|
fi
|
|
|
|
N=$((N + 1))
|
|
|
|
done
|
2005-04-28 13:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# Check if the test result is the same as the expected result.
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# $1 Input file
|
|
|
|
# $2 Test number
|
|
|
|
#
|
|
|
|
do_diff()
|
2005-04-28 13:20:48 +00:00
|
|
|
{
|
2005-05-31 14:13:07 +00:00
|
|
|
local EXPECTED RESULT
|
2014-03-19 12:29:20 +00:00
|
|
|
EXPECTED="${SRC_DIR}/expected.$1.$2"
|
2005-05-31 14:13:07 +00:00
|
|
|
RESULT="${OUTPUT_DIR}/$1.$2"
|
|
|
|
|
|
|
|
echo diff -u $EXPECTED $RESULT
|
|
|
|
if [ -f $EXPECTED ]; then
|
|
|
|
diff -u $EXPECTED $RESULT
|
|
|
|
else
|
|
|
|
echo "${EXPECTED} does not exist"
|
2005-04-28 13:20:48 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# Update expected results
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
eval_update()
|
2005-04-28 13:20:48 +00:00
|
|
|
{
|
2005-05-31 14:13:07 +00:00
|
|
|
ensure_workdir
|
|
|
|
ensure_run
|
|
|
|
|
|
|
|
if [ -z "${TEST_N}" ] ; then
|
|
|
|
TEST_N=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
FAIL=
|
|
|
|
N=1
|
|
|
|
while [ ${N} -le ${TEST_N} ] ; do
|
2005-06-01 11:25:38 +00:00
|
|
|
if ! skip_test ${N} ; then
|
2005-05-31 14:13:07 +00:00
|
|
|
cp ${OUTPUT_DIR}/stdout.${N} expected.stdout.${N}
|
|
|
|
cp ${OUTPUT_DIR}/stderr.${N} expected.stderr.${N}
|
|
|
|
cp ${OUTPUT_DIR}/status.${N} expected.status.${N}
|
|
|
|
fi
|
|
|
|
N=$((N + 1))
|
|
|
|
done
|
2005-04-28 13:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# Print description
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
eval_desc()
|
2005-04-28 13:20:48 +00:00
|
|
|
{
|
2005-05-31 14:13:07 +00:00
|
|
|
echo "${SUBDIR}: ${DESC}"
|
2005-04-28 13:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Run the test
|
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
eval_test()
|
2005-04-28 13:20:48 +00:00
|
|
|
{
|
2005-05-31 14:13:07 +00:00
|
|
|
eval_setup
|
|
|
|
eval_run
|
2005-04-28 13:20:48 +00:00
|
|
|
eval_compare
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# Run the test for prove(1)
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
eval_prove()
|
2005-04-28 13:20:48 +00:00
|
|
|
{
|
2005-05-31 14:13:07 +00:00
|
|
|
eval_setup
|
|
|
|
eval_run
|
|
|
|
eval_compare
|
|
|
|
eval_clean
|
2005-04-28 13:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2005-05-31 14:13:07 +00:00
|
|
|
# Main function. Execute the command(s) on the command line.
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
|
|
|
eval_cmd()
|
|
|
|
{
|
|
|
|
if [ $# -eq 0 ] ; then
|
2005-05-31 14:13:07 +00:00
|
|
|
# if no arguments given default to 'prove'
|
|
|
|
set -- prove
|
2005-04-28 13:20:48 +00:00
|
|
|
fi
|
|
|
|
|
2014-03-12 10:38:32 +00:00
|
|
|
if ! make_is_fmake ; then
|
|
|
|
for i in $(jot ${TEST_N:-1}) ; do
|
|
|
|
eval TEST_${i}_SKIP=\"make is not fmake\"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2005-05-31 14:13:07 +00:00
|
|
|
for i
|
|
|
|
do
|
|
|
|
case $i in
|
|
|
|
|
|
|
|
setup | run | compare | diff | clean | reset | show | \
|
|
|
|
test | prove | desc | update)
|
|
|
|
eval eval_$i
|
|
|
|
;;
|
|
|
|
* | help)
|
|
|
|
print_usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2005-04-28 13:20:48 +00:00
|
|
|
}
|
|
|
|
|
2005-05-31 14:13:07 +00:00
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Main code
|
|
|
|
#
|
|
|
|
|
2005-04-28 13:20:48 +00:00
|
|
|
#
|
|
|
|
# Determine our sub-directory. Argh.
|
|
|
|
#
|
2014-03-19 12:29:20 +00:00
|
|
|
SRC_DIR=$(dirname $0)
|
|
|
|
SRC_BASE=`cd ${SRC_DIR} ; while [ ! -f common.sh ] ; do cd .. ; done ; pwd`
|
2005-04-28 13:20:48 +00:00
|
|
|
SUBDIR=`echo ${SRC_DIR} | sed "s@${SRC_BASE}/@@"`
|
|
|
|
|
2005-05-31 14:13:07 +00:00
|
|
|
#
|
|
|
|
# Construct working directory
|
|
|
|
#
|
2014-03-19 12:29:20 +00:00
|
|
|
WORK_DIR=$(pwd)/work/${SUBDIR}
|
2005-05-31 14:13:07 +00:00
|
|
|
OUTPUT_DIR=${WORK_DIR}.OUTPUT
|
2005-04-28 13:20:48 +00:00
|
|
|
|
2005-05-31 14:13:07 +00:00
|
|
|
#
|
|
|
|
# Make to use
|
|
|
|
#
|
|
|
|
MAKE_PROG=${MAKE_PROG:-/usr/bin/make}
|