#!/bin/sh
lookupfile=$BALL_PATH/source/config/tests_lookup.txt
testdir=$BALL_PATH/source/TEST
HEADER_DIR=$BALL_PATH
length=$(cat $lookupfile | wc -l)

for ((i=1; i<=length ;i++))
do
	line=$(sed -n $(($i))p $lookupfile)

	headerfile=""
	nr=$(echo $line | wc -w)
	if [ nr > 2 ]
	then
		rm -f /tmp/$USER-script-tmp
		touch /tmp/$USER-script-tmp
	fi

	j=1
	for w in $line
	do
		if [ "$w" = '#' ]
		then
			break
		fi
		#echo $w

		if [ $j = 1 ]
		then
			headerfile=$w
			echo ----------------------- $headerfile -----------------------------
			if [ ! -e $HEADER_DIR/$headerfile ]
			then 
				echo File not found $HEADER_DIR/$headerfile +++++++++++++++++++++++++++++++++++++++++++++++++++++++
			fi
			let "j+=1"
			continue
		fi

		if [ $j = 2 ]
		then
			if [ $nr -le 3 ]
			then
				check_test $HEADER_DIR/$headerfile $testdir/$w 2>/dev/null
				break
			fi
		fi

		if [ $nr > 2 ]
		then
			cat $testdir/$w >> /tmp/$USER-script-tmp
		fi

		if [ $j = $nr ]
		then
			check_test $HEADER_DIR/$headerfile /tmp/$USER-script-tmp 2>/dev/null
		fi

		let "j+=1"
			
	done
done
