#!/usr/bin/env bash
t=${0##*/}; TEST_NAME=${t:5}   # basename $0 with 'test-' stripped off

[ -z "$builddir" ] && export builddir=$PWD
. ${builddir}/check-common.sh

tests=${@:-"trace trace2"}
# tests=${@:-"trace2"}

for SUBTEST in $tests ; do
  echo "checking $SUBTEST..."
  TEST_NAME=$SUBTEST
  TEST_FILE="${top_builddir}/test/${SUBTEST}.check"
  RIGHT_FILE="${top_srcdir}/test/data/${SUBTEST}.right"
  (cd $srcdir && $SH ${TEST_NAME}.tests > $TEST_FILE 2>&1 < /dev/null)
  check_output $TEST_FILE $RIGHT_FILE
  rc=$?
  if test $rc -eq 0  ; then 
    rm -f $TEST_FILE
  else
    exit $rc
  fi
done

# Return code tells testing mechanism whether passed or not.
exit 0
