#!/bin/sh

if [ "$1" = "-val" ]
then
    shift
    [ ! -d .valgrind ] && mkdir .valgrind
    rm -f .valgrind/log*
    PROG=./trun_vallog
else
    PROG=../bin/spftest/spftest_static
fi

echo
echo "Testing byte-compiler on SPF Adoption Roll data"
echo "Prog = $PROG"


perl test_parser.pl -impl libspf-alt -program $PROG -data test_adopt_roll.txt 2>&1 \
	    | grep -v "^ok [0-9][0-9]*" | tee tests_parser.out

num_errors=`grep "^# Test [0-9][0-9]* got:" tests_parser.out | grep -v "\*TODO\*)" | wc -l`
num_errors=`expr $num_errors + 0`

if [ $num_errors -ne 0 ]
then
    echo "Error:  $num_errors tests failed"
else
    echo "All regression tests passed"
fi

if [ "$1" = "-val" ]
then
    sleep 1
    grep -n "== ERROR SUMMARY: " .valgrind/log* | grep -v "0 errors from 0 contexts" | head
fi

[ $num_errors -ne 0 ] && exit 1

exit 0


syntax highlighted by Code2HTML, v. 0.9.1