Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 276123efe0
Fetching contributors…

Cannot retrieve contributors at this time

executable file 115 lines (94 sloc) 2.692 kB
#! /bin/sh
# Make sure srcdir is an absolute path. Supply the variable
# if it does not exist. We want to be able to run the tests
# stand-alone!!
#
srcdir=${srcdir-.}
if test ! -d $srcdir ; then
echo "test-defs.sh: installation error" 1>&2
exit 1
fi
# Use absolute paths
case "$srcdir" in
/* | [A-Za-z]:\\*) ;;
*) srcdir=`\cd $srcdir && pwd` ;;
esac
case "$top_builddir" in
/* | [A-Za-z]:\\*) ;;
*) top_builddir=`\cd ${top_builddir-..} && pwd` ;;
esac
progname=`echo "$0" | sed 's,^.*/,,'`
testname=`echo "$progname" | sed 's,-.*$,,'`
testsubdir=${testsubdir-testSubDir}
# User can set VERBOSE to cause output redirection
case "$VERBOSE" in
[Nn]|[Nn][Oo]|0|"")
VERBOSE=0
exec > /dev/null 2>&1
;;
[Yy]|[Yy][Ee][Ss])
VERBOSE=1
;;
esac
rm -rf "$testsubdir/$progname" > /dev/null 2>&1
mkdir -p "$testsubdir/$progname"
cd "$testsubdir/$progname" \
|| { echo "Cannot make or change into $testsubdir/$progname"; exit 1; }
echo "=== Running test $progname"
CMP="${CMP-cmp}"
use_valgrind=${USE_VALGRIND-1}
valgrind_path=$(which valgrind 2> /dev/null)
if [ -z "${valgrind_path}" -o ! -x "${valgrind_path}" ] ; then
use_valgrind=0
fi
#
# This is a common function to check the results of a test program
# that is intended to generate consistent output across runs.
#
# ${top_builddir} must be set to the top level build directory.
#
# Output will be written to the current directory.
#
# It must be passed the name of the test command to run, which must be present
# in the ${top_builddir} directory.
#
# It will compare the output of running that against <name of command>.expected
#
run_output_test()
{
TEST_COMMAND="$1"
REDIR_OUTPUT="> \"${TEST_COMMAND}.out\""
if [ $VERBOSE -gt 1 ] ; then
REDIR_OUTPUT="| tee \"${TEST_COMMAND}.out\""
fi
if [ $use_valgrind -eq 1 ] ; then
eval valgrind --tool=memcheck \
--trace-children=yes \
--demangle=yes \
--log-file=vg.out \
--leak-check=full \
--show-reachable=yes \
--run-libc-freeres=yes \
"\"${top_builddir}/${TEST_COMMAND}\"" ${REDIR_OUTPUT}
err=$?
else
eval "\"${top_builddir}/${TEST_COMMAND}"\" ${REDIR_OUTPUT}
err=$?
fi
if [ $err -ne 0 ] ; then
echo "ERROR: ${TEST_COMMAND} exited with non-zero exit status: $err" 1>&2
fi
if [ $use_valgrind -eq 1 ] ; then
if ! tail -1 "vg.out" | grep -q "ERROR SUMMARY: 0 errors" ; then
echo "ERROR: valgrind found errors during execution:" 1>&2
cat vg.out
err=1
fi
fi
if ! "$CMP" -s "${top_builddir}/${TEST_COMMAND}.expected" "${TEST_COMMAND}.out" ; then
echo "ERROR: ${TEST_COMMAND} failed:" 1>&2
diff "${top_builddir}/${TEST_COMMAND}.expected" "${TEST_COMMAND}.out" 1>&2
err=1
fi
return $err
}
Jump to Line
Something went wrong with that request. Please try again.