X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=test%2Frun-test;h=ffe653c0e5700d776c5b4bbd3e7b84af0f914bfa;hb=1b02f3546c19664ce80f39181f077709ffb5f573;hp=79d955a114018fba5f6a5099fefd48cdb00ec0a1;hpb=8ef778c8431c17d970b2667943c6ea13c3770912;p=jansson.git diff --git a/test/run-test b/test/run-test index 79d955a..ffe653c 100644 --- a/test/run-test +++ b/test/run-test @@ -1,31 +1,57 @@ -cleanup() { - rm -rf $TMPDIR -} -trap cleanup 0 +# Copyright (c) 2009 Petri Lehtinen +# +# Jansson is free software; you can redistribute it and/or modify +# it under the terms of the MIT license. See LICENSE for details. + +VALGRIND_CMDLINE="valgrind --leak-check=full --show-reachable=yes --track-origins=yes -q" run_testprog() { local prog=$1 - local input=$2 + local prefix=$2 + if [ -n "$VALGRIND" ]; then + local runner="$VALGRIND_CMDLINE " + fi + case "$prog" in - load_dump) - ./$prog $input $TMPDIR/output 2>$TMPDIR/error + load_file_dump_file) + $runner./$prog \ + $prefix.in \ + $prefix.$prog.stdout \ + 2>$prefix.$prog.stderr ;; *) - ./$prog <$input >$TMPDIR/output 2>$TMPDIR/error + $runner./$prog \ + <$prefix.in \ + >$prefix.$prog.stdout \ + 2>$prefix.$prog.stderr ;; esac -} -if [ ! -f $TESTFILE ]; then - echo "$TESTFILE cannot be found" >&2 - exit 1 -fi + 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 +} -mkdir -p $TMPDIR -${srcdir}/split-testfile.py $TESTFILE $TMPDIR | \ -while read input output; do - run_test load_dump $input $output - run_test loadf_dumpf $input $output - run_test loadfd_dumpfd $input $output - run_test loads_dumps $input $output +for testfile in $TESTFILES; do + tmpdir="testlogs/`basename $testfile`" + rm -rf $tmpdir + mkdir -p $tmpdir + if echo "$testfile" | grep -q -E -e '-strip$'; then + opts="--strip" + fi + ${srcdir}/split-testfile.py $opts $testfile $tmpdir | while read name; do + run_test loadf_dumpf $tmpdir/$name + run_test loads_dumps $tmpdir/$name + run_test load_file_dump_file $tmpdir/$name + echo -n '.' + done || exit 1 + echo done