#!/bin/sh

# Note:  use sed to strip blanks because not all systems have same version
# of diff.

if [ "x$GCTLIB" = "x" ]
then
  GCTLIB=`pwd`/../../../
  PATH=.:`pwd`/../../..:$PATH
fi

ROOT=..
. $ROOT/run.source

clean


# Second argument usually used to make note about a bug.
doit()
{
	echo "$INDENT" " $1" " $2"
	gct -B$GCTLIB $1.c > $1.OUT 2>&1
	diff $1.OUT $1.ref
}

# Like doit, but also check the output.
temp_doit()
{
	doit $1 $2
	diff -b T$1.c $1.Tref
}

# Automatic creation of initializers.
cp auto-ctrl gct-ctrl; gct-init $GCTLIB; doit autoinit; 
grep '/\*GCT\*/' Tautoinit.c | wc -l > autoinit.OUT; diff -b autoinit.OUT autoinit.gref

# Tests for new shadowing code.
cp curl-ctrl gct-ctrl
make_constant_objects
std_test curl-bug
std_test curl-str


if [ "$GCT_UNPORTABLE_OK" = "true" ]
then
   OLD_TEST_CC=$TEST_CC
   TEST_CC=gcc
   std_test curl-init
   TEST_CC=$OLD_TEST_CC
else 
  echo $INDENT "Skipping curl_init (not portable)"
fi

std_test vis-bug2
std_test vis-bug2a




if [ -f MASTER_LOG ]
then
	breport -test-map ${GCTLIB}btool_map MASTER_LOG > REPORT
fi

exit 0
