#!/bin/csh
# Some Basic Tests including Kernel Classes
#
# Usage : basic_test [args_for_compile]
#
#set verbose = 1
if (!($?SmallEiffel)) then
	echo "Environment Variable 'SmallEiffel' not set."
	exit 1
endif
set compile=${SmallEiffel}/bin/compile
echo Testing ${compile} $* > /dev/tty
echo Options : $*
###################################################################
/bin/rm -f ./a.out
${compile} $* HELLO_WORLD make > /dev/null
./a.out
###################################################################
cd ${SmallEiffel}/lib_test
echo -n "Testing ."
foreach t (vide.e test_*.e)
#	echo $t
	${compile} $* $t make > /dev/null
	if (${status}) then
		echo Error While Compiling ${t}
	else
		echo -n "."
	endif
	if (!(-x ./a.out)) then
		echo No a.out for file ${t}
	else
		echo -n "."
	endif
	./a.out
	if (${status}) then
		echo Error While Running ${t}
	else
		echo -n "."
		/bin/rm -f ./a.out
	endif
end
cd ${SmallEiffel}/bin
###################################################################
/bin/rm -f ./a.out
${compile} -boost BOOST_IS_STATIC make > /dev/null
echo -n "."
./a.out
echo -n "."
###################################################################
/bin/rm -f testargs
${compile} $* -o testargs TESTARGS make > /dev/null
testargs
echo -n "."
testargs 1
echo -n "."
testargs 2 arg2
echo "."
/bin/rm -f testargs
###################################################################
/bin/rm -f ./a.out
echo "TRY_ANIMAL"
${compile} $* TRY_ANIMAL make > /dev/null
./a.out
###################################################################
/bin/rm -f ./a.out
echo "TRY_PRINT_ON"
${compile} $* TRY_PRINT_ON make > /dev/null
./a.out
###################################################################
echo "Compiling SmallEiffel/lib_show"
cd ${SmallEiffel}/bin
${compile} $* PYRAMID make > /dev/null
echo -n "."
${compile} $* PYRAMID2 make > /dev/null
echo -n "."
${compile} $* SPREAD_ILLNESS make > /dev/null
echo -n "."
/bin/rm -f ./a.out
################################
cd ${SmallEiffel}/lib_show/parking
${compile} $* RUN_PARKING make > /dev/null
/bin/rm -f a.out
echo -n "."
################################
cd ${SmallEiffel}/lib_show/gcd
${compile} $* TEST_GCD make > /dev/null
echo -n "."
./a.out
/bin/rm -f ./a.out
echo -n "."
###################################################################
cd ${SmallEiffel}/lib_show/external
${compile} $* EXTERNAL_DEMO make src.c > /dev/null
./a.out >! tmp$$
if ($status) then
   echo "Error in lib_show/external."
   exit 1
endif
/bin/rm -f tmp* src.o ./a.out
echo -n "."
###################################################################
cd ${SmallEiffel}/lib_show/bench1
foreach b (*_bench1.e)
	/bin/rm -f a.out
	${compile} $* $b make > /dev/null
	./a.out > /dev/null
	if ($status) then
	   echo "Error in lib_show/${b}.e"
	   exit 1
	endif
	echo -n "."
	/bin/rm -f a.out
end
###################################################################
cd ${SmallEiffel}/lib_show/bench2
foreach b (*_bench2.e)
	/bin/rm -f a.out
	${compile} $* $b make > /dev/null
	./a.out > /dev/null
	if ($status) then
	   echo "Error in lib_show/${b}.e"
	   exit 1
	endif
	echo -n "."
	/bin/rm -f a.out
end
echo " Done."

