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

say()
{
	echo "$INDENT" " $1"
}

doit()
{
	say $1
	/bin/rm -f dummy.c; touch dummy.c
	${GCTLIB}gct -c -B$GCTLIB -test-show-ctrl dummy.c 2>&1 |\
	sed -e "s=${GCTLIB}gct:=gct:=" > $1.OUT 
	diff $1.OUT $1.ref
}

# For when the set of printable options changes
fixit()
{
	say $1
	${GCTLIB}gct -c -B$GCTLIB -test-show-ctrl dummy.c 2>&1 |\
	sed -e "s=${GCTLIB}gct:=gct:=" > $1.ref
}


make clean
gct-init $GCTLIB
rm -f gct-ctrl; doit test1
cat /dev/null > gct-ctrl; doit test2
cp test3.ctrl gct-ctrl; doit test3
cp test4.ctrl gct-ctrl; doit test4
cp test5.ctrl gct-ctrl; doit test5
cp test6.ctrl gct-ctrl; doit test6

cp check_set.ctrl gct-ctrl; doit check_set

cp errtest1.ctrl gct-ctrl; doit errtest1
cp errtest2.ctrl gct-ctrl; doit errtest2
cp errtest3.ctrl gct-ctrl; doit errtest3
cp errtest4.ctrl gct-ctrl; doit errtest4
cp errtest5.ctrl gct-ctrl; doit errtest5
cp errtest6.ctrl gct-ctrl; doit errtest6
cp errtest7.ctrl gct-ctrl; doit errtest7
cp errtest8.ctrl gct-ctrl; doit errtest8
cp errtest9.ctrl gct-ctrl; doit errtest9
cp errtest10.ctrl gct-ctrl; doit errtest10
cp errtest11.ctrl gct-ctrl; doit errtest11
cp errtest12.ctrl gct-ctrl; doit errtest12
cp errtest13.ctrl gct-ctrl; doit errtest13
cp errtest14.ctrl gct-ctrl; doit errtest14
cp errtest15.ctrl gct-ctrl; doit errtest15
cp errtest16.ctrl gct-ctrl; doit errtest16
cp errtest17.ctrl gct-ctrl; doit errtest17
cp errtest18.ctrl gct-ctrl; doit errtest18
cp errtest19.ctrl gct-ctrl; doit errtest19
cp errtest20.ctrl gct-ctrl; doit errtest20

cp fileset1.ctrl gct-ctrl; doit fileset1
cp fileset2.ctrl gct-ctrl; doit fileset2
cp macroset.ctrl gct-ctrl; doit macroset

cp warning.ctrl gct-ctrl; doit warning

cp deeply.ctrl gct-ctrl; doit deeply
cp deeply2.ctrl gct-ctrl; doit deeply2

cp dash.ctrl gct-ctrl; doit dash
cp dash2.ctrl gct-ctrl; doit dash2
cp dash3.ctrl gct-ctrl; doit dash3

exit 0
