: ${TEST?} ${C?}

where=$TEST/NEW
which=ALL
prog=Sqpe
check=
all='thorough arith basic basic2 apply prob large printer'
needed=.Data

case $# in
	0) ;;
	1) which=$1;;
	2) which=$1; prog=$2;;
	3) which=$1; prog=$2; check="$3";;
	*) echo "Usage $0 [testname] [program] [check=T]"; exit 1;;
esac

case $which in
ALL)
	for i in `echo $all`
	do
		$0 $i $prog "$check"
	done
	;;
*)
	cd $where
	if test ! -d current; then mkdir current; fi
	for i in `echo $needed`
	do
		if test ! -d $i
		then mkdir $i
		else rm $i/* > /dev/null 2>&1
		fi
	done
	case $check in
		"") ;;
		*) check="options($check)";;
	esac
	echo "Running $which test on version $prog $check" ...
	(echo $check; cat $where/$which) | time $C/$prog > $where/current/$which 2>&1
	echo Compare target/$which with current/$which in $where
	;;
esac
