jansson/test/run-test
Petri Lehtinen f60c563bab Enhance test system
- Tests are now named
- Testlogs are preserved between runs
- Tests can be run through Valgrind Memcheck tool
2009-07-28 10:36:16 +03:00

51 lines
1.4 KiB
Plaintext

VALGRIND_CMDLINE="valgrind --leak-check=full --show-reachable=yes --track-origins=yes -q"
run_testprog() {
local prog=$1
local prefix=$2
if [ -n "$VALGRIND" ]; then
local runner="$VALGRIND_CMDLINE "
fi
case "$prog" in
load_dump)
$runner./$prog \
$prefix.in \
$prefix.$prog.stdout \
2>$prefix.$prog.stderr
;;
*)
$runner./$prog \
<$prefix.in \
>$prefix.$prog.stdout \
2>$prefix.$prog.stderr
;;
esac
if [ -n "$VALGRIND" ]; then
# Check for Valgrind error output. The valgrind option
# --error-exitcode is not enough because Valgrind doesn't
# think unfreed allocs are errors.
if grep -E -q '^==[0-9]+== ' $prefix.$prog.stderr; then
echo "### $prefix ($prog) failed:" >&2
echo "valgrind detected an error" >&2
echo "for details, see test/$prefix.$prog.stderr" >&2
exit 1
fi
fi
}
rm -rf testlogs
for testfile in $TESTFILES; do
tmpdir="testlogs/`basename $testfile`"
mkdir -p $tmpdir
${srcdir}/split-testfile.py $testfile $tmpdir | while read name; do
run_test load_dump $tmpdir/$name
run_test loadf_dumpf $tmpdir/$name
run_test loads_dumps $tmpdir/$name
echo -n '.'
done || exit 1
echo
done