
# this file is for sourcing in rhts test scripts

if [ -z "$FAMILY" ] ; then
	FAMILY=RedHatEnterpriseLinux3
fi
if [ -z "$TEST" ]; then
	TEST=DevelopersOwnTest
fi

if [ -z "$OUTPUTFILE" ]; then
	OUTPUTFILE=`mktemp /mnt/testarea/tmp.XXXXXX`
fi

if [ -z "$ARCH" ]; then
	ARCH=`uname -m`
fi

touch $OUTPUTFILE

function report_result {
	echo Reporting test $1 as $2 > /dev/stderr
	PKGSTRING=`rpm -qa $PACKAGE` ; [ -z $PKGSTRING ] && PKGSTRING=$PACKAGE
	rhts_db_submit_result -j $JOBID -d $DISTRO -a $ARCH -s $FAMILY -t $1 -p $PKGSTRING \
	-r $2 -v 0$3 -h `hostname` < $OUTPUTFILE
}


#
# Do a startup test of a program
# Assumption is that the program will wait for user input so we'll
# kill it after 15 seconds
#
function startup_test {

	wasrunning=`pidof Xvfb`

	if [ "0$wasrunning" -eq "0" ]; then
        	Xvfb :1 -screen 0 1600x1200x24 -fbdir /tmp &
		sleep 3
        	export DISPLAY=:1
	fi
        
	ulimit -c unlimited
        rm -rf core*
        
	timed_test.sh 15 $1 &> $OUTPUTFILE
	value=`ls core* | wc -l`
	if [ "$value" -ne "0" ]; then
 		result=FAIL
	fi
                          
        ulimit -c 0
                          
        if [ "0$wasrunning" -eq "0" ]; then
        	kill `pidof Xvfb`
        fi
}

