#!/bin/sh
if [ "x$GCTLIB" = "x" ]
then
  GCTLIB=`pwd`/../../../
  PATH=.:`pwd`/../../..:$PATH
  export GCTLIB
  export PATH
fi

# Make, possibly flushing silly "-target sun3" message.
make clean
make -f Makefile.gct gct 2>&1 | grep -v "target"

# Check that greport -all works.
if [ "$GCT_UNPORTABLE_OK" = "true" ]
then
    # Run the suite.
    run-suite

    # Does gsummary work?
    echo $INDENT basic-gsummary
    gsummary LOG > gsummary.log
    diff gsummary.log gsummary.ref

    # Check that greport works.
    echo $INDENT basic-greport
    greport LOG > greport.log
    diff greport.log greport.ref

    # Check that greport -all works.
    echo $INDENT greport-all
    greport -all LOG | grep -v "operator =" | grep -v operand > all.log
    diff all.log all.ref
    echo $INDENT "Note:  someday make sure that the run-to-run difference on Sparc"
    echo $INDENT "is truly not a problem, that register windows behave as assumed."

    # Check greport after addition of a test.
    echo $INDENT greport-addition
    echo "{" | lc -\{ > /dev/null
    greport LOG > greport2.log
    diff greport2.log greport2.ref
else 
  echo $INDENT "Skipping remaining tests (not portable)"
fi


exit 0
