#!/bin/sh

# DON'T set the GCTLIB and PATH - we want to see if GCT is installed
# correctly.

# This message is printed if the gct-gcc script is used with GCC 2.0.
# It's harmless, but tell installer about it.
GCC_MSG='\*Initialization\*'

# Make silently.
make clean
make -f Makefile.gct gct > /dev/null 2> make.log
grep -v "$GCC_MSG" make.log
if (grep "$GCC_MSG" make.log > /dev/null) 
then
  echo "Because you use GCC 2.0, users may see messages like this:"
  grep "$GCC_MSG" make.log
  echo "They should be rare, and they are harmless."
  echo "Refer users to the Troubleshooting document."
fi

# Run the suite.
run-suite

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

# Does gsummary -vf work? (Simple test)
echo $INDENT gsummary-vf
gsummary -vf lc.c LOG > sum-vf1.log
diff sum-vf1.log gsummary.ref

# Does gsummary -files work?
echo $INDENT gsummary-f
gsummary -f LOG > gsummaryf.log
diff gsummaryf.log gsummaryf.ref

# Does gsummary -routines work?
echo $INDENT gsummary-r
gsummary -r LOG > gsummaryr.log
diff gsummaryr.log gsummaryr.ref

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

# Check that greport -all works. (Also a test of everything in mapfile+logfile.)
echo $INDENT basic-all
greport -all LOG > all.log
diff all.log all.ref

echo $INDENT basic-n
greport -n LOG > n.log
diff n.log n.ref

# Branch and loop filtering
echo $INDENT gfilter1
greport -all LOG | gfilter -branch -loop > gfilter1.log
diff gfilter1.log gfilter1.ref

# multi filtering
echo $INDENT gfilter2
greport -all LOG | gfilter -multi > gfilter2.log
diff gfilter2.log gfilter2.ref

# operator routine call filtering
echo $INDENT gfilter3
greport -all LOG | gfilter -routine -call -operator > gfilter3.log
diff gfilter3.log gfilter3.ref

# Check greport after addition of a test.
echo $INDENT greport-addition
echo "{" | lc -\{ > /dev/null
greport LOG > greport2.log
diff greport2.log greport2.ref

# Gedit
echo $INDENT gedit
gedit < gedit.input
echo $INDENT gedit-gsummary
gsummary LOG > gsummaryE.log
diff gsummaryE.log gsummaryE.ref

# Does gsummary -files work?
echo $INDENT gedit-gsummary-f
gsummary -f LOG > gsummaryfE.log
diff gsummaryfE.log gsummaryfE.ref

# Does gsummary -routines work?
echo $INDENT gedit-gsummary-r
gsummary -r LOG > gsummaryrE.log
diff gsummaryrE.log gsummaryrE.ref

echo $INDENT gedit-greport
# Greport should show nothing.
greport LOG

exit 0
