#!@KSH@
set -x

# Clear files
\rm -f test > /dev/null 2>&1
> test.ti
> stdout.new
> stdout.new.norm
> stdout.old
> stdout.old.norm
> stderr.new
> stderr.new.norm
> stderr.old
> stderr.old.norm

# Execute tests
case $1 in
  *.tst)
    # Have test create files test.ti, stdout.old, stderr.old
    . ${TS_HOME_DIRECTORY}/$1

    # Compile
    ${TS_BUILD_DIRECTORY}/bin/watchdog 900 5000 ${SS_COMPILER} ${SS_DEFAULT_COMPILER_FLAGS} ${SS_COMPILER_FLAGS} test.ti || exit 10

    # Run
    ${TS_BUILD_DIRECTORY}/bin/watchdog 300 5000 ${SS_TCRUN} ./test > stdout.new 2> stderr.new || exit 20

    # Noramlize
    ${SS_NORMALIZER} < stdout.new > stdout.new.norm || exit 30
    ${SS_NORMALIZER} < stderr.new > stderr.new.norm || exit 40
    ${SS_NORMALIZER} < stdout.old > stdout.old.norm || exit 50
    ${SS_NORMALIZER} < stderr.old > stderr.old.norm || exit 60

    # Validate
    diff stdout.old.norm stdout.new.norm || exit 70
    diff stderr.old.norm stderr.new.norm || exit 80
    ;;
  *)
    # Unknown file type
    exit 90
    ;;
esac

# Done and passed
exit 0
