#!/bin/sh

ROOT=..

CAMV_RND="cd $ROOT/src; ./camv-rnd"
DIFF="diff -u"

good=0
bad=0

test_camv_rnd()
{
	echo "saveto design $1.out tedax" | eval $CAMV_RND $1 --gui batch
	sed -i "s/^begin camv_layer v1.*/begin camv_layer v1 TEST/" $1.out
	$DIFF $1.ref $1.out
	if test $? = 0
	then
		good=$(($good+1))
		rm $1.out
	else
		bad=$(($bad+1))
	fi
}

pwd=`pwd`
for n in *.gbr
do
	test_camv_rnd $pwd/$n
done

if test $bad = 0
then
	echo "*** QC PASS ***"
	exit 0
else
	echo "Passed: $good  FAILED: $bad"
	exit 1
fi
