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

ROOT=..
. $ROOT/run.source

clean
make_constant_objects

std_test id
std_test id_weak
std_test array1
std_test array2
std_test array3
std_test array_weak
std_test arra_weak2
std_test constant
std_test const_rel
std_test sizeof
std_test sizeof_rel
std_test dotref1
std_test dotref2

# Error tests.  Do not compile.
init dotref3; gct -B$GCTLIB dotref3.c > dotref3.out 2>&1 
echo $? >> dotref3.out; diff dotref3.out dotref3.ref

init dotref4; gct -B$GCTLIB dotref4.c > dotref4.out 2>&1 
echo $? >> dotref4.out; diff dotref4.out dotref4.ref

init doterr; gct -B$GCTLIB doterr.c > doterr.out 2>&1 
echo $? >> doterr.out; diff doterr.out doterr.ref

std_test dot.nest
std_test dot.nest2
std_test dot_weak
std_test union
std_test arrowref1
std_test arrowref2
std_test arrowref3
std_test arrowref4
std_test arrow.nest
std_test arrow_weak
std_test deref
std_test deref2
std_test deref_weak
std_test null_guard
std_test no_deref
std_test 2level
std_test 3level

# Error test.  Expect compile to fail.
init 2D.check; gct -B$GCTLIB 2D.check.c > 2D.check.out 2>&1
echo $? >> 2D.check.out
cc -c T2D.check.c > /dev/null 2>&1
echo $? >> 2D.check.out; diff 2D.check.out 2D.check.ref

init 2D.nowork; gct -B$GCTLIB 2D.nowork.c > 2D.nowork.out 2>&1
echo $? >> 2D.nowork.out
cc -c T2D.nowork.c > /dev/null 2>&1
echo $? >> 2D.nowork.out; diff 2D.nowork.out 2D.nowork.ref

# NOTE:  For the following tests, there are no reference files."
# Testing whether instrumented program has same results as "
# original, not whether instrumentation is correct."

silent_compile=TRUE	# Following tests generate uninteresting warnings.
silent_gct=TRUE

std_test_noref 2D.dot
std_test_noref 2D.arrow
std_test_noref 2D.star
std_test_noref 2D.array
std_test_noref 2D.address


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

exit 0
