#!/bin/sh

dirname=`dirname $0`

case $dirname in
	/*)
		cd $dirname/.. > /dev/null
		path=`pwd`
		cd - > /dev/null
	;;
	*)
		cd `pwd`/$dirname/.. > /dev/null
		path=`pwd`
		cd - > /dev/null
	;;
esac

export PYTHONPATH=$path/lib

for conf in `ls $path/runtest/*conf`
do
	printf "       $conf"
	result=`env exabgp.tcp.bind='' exabgp.debug.selfcheck=true $path/../sbin/exabgp $conf 2>&1`
	retcode=$?
	problem=`echo $result | grep 'Problem with the configuration file'`

	if [ $retcode -eq 0 ] && [ "$problem" == "" ]
	then
		printf "\rok\n"
	else
		printf "\rfailed\n\n"
		echo "env exabgp.tcp.bind='' exabgp.debug.selfcheck=true exabgp.debug.configuration=1 $path/../sbin/exabgp $conf -p"
		printf "\n\n"
	fi
done
