cgal/Packages/Scripts/test/run_testsuite

162 lines
4.7 KiB
Bash
Executable File

#! /bin/sh
#
# This is the test script for the CGAL-library.
#
# Usage:
# run_testsuite for running the test suite in all subdirectories
# run_testsuite <directory-list> for running the test suite in the listed
# subdirectories
#
# To use this script you have to do two things:
#
# 1) enter the makefiles of the platforms that you want to test with (below)
# 2) set some additional compiler and or linker flags
TESTSUITE_CXXFLAGS=""
TESTSUITE_LDFLAGS=""
CURRENTDIR=`pwd`
ERRORFILE=${CURRENTDIR}/error.txt
#clear the error file
rm -f $ERRORFILE
touch $ERRORFILE
wait_for_process()
{
count=$2
while [ $count -ne 0 ]
do
count=`expr $count - 1`
if ps |grep $1 >/dev/null
then
sleep $3
else
count=0
fi
done
if ps |grep $1 >/dev/null
then
# Send signal Terminate (SIGTERM) to the whole process group.
# First disable the default action (quit) for the current process.
trap true 15
kill -15 0
trap 15
return 1
fi
return 0
}
run_local_cgal_test()
{
eval ./cgal_test >current_compiler_output 2>&1
exit_value=$?
if [ $exit_value -ne 0 ]
then
echo $exit_value > test_failure
fi
}
#test_directory <directory>
test_directory()
{
cd $CURRENTDIR
if [ -d $1 ] ; then
echo "DIRECTORY $1:"
echo
echo "DIRECTORY $1:" >> $ERRORFILE
echo >> $ERRORFILE
cd $1
COMPILER_OUTPUT=CompilerOutput_$PLATFORM
rm -f $COMPILER_OUTPUT
ERROR_OUTPUT=ErrorOutput_$PLATFORM
rm -f $ERROR_OUTPUT
echo "------------------------------------------------------------------" >> $COMPILER_OUTPUT
echo "- Compiler output from platform $PLATFORM" >> $COMPILER_OUTPUT
echo "------------------------------------------------------------------" >> $COMPILER_OUTPUT
echo >> $COMPILER_OUTPUT
echo "------------------------------------------------------------------" >> $ERROR_OUTPUT
echo "- Error output from platform $PLATFORM" >> $ERROR_OUTPUT
echo "------------------------------------------------------------------" >> $ERROR_OUTPUT
echo >> $ERROR_OUTPUT
if [ -f cgal_test -a -x cgal_test ] ; then
export PLATFORM CGAL_MAKEFILE TESTSUITE_CXXFLAGS TESTSUITE_LDFLAGS
rm -f error.txt
run_local_cgal_test &
if wait_for_process "$!" "60" "30"
then
if [ -f test_failure ] ; then
exit_failure=`cat test_failure`
rm -f test_failure
echo "ERROR: cgal_test exited with error condition $exit_value" >> $ERRORFILE
echo "ERROR: cgal_test exited with error condition $exit_value" >> $ERROR_OUTPUT
fi
else
echo "ERROR: cgal_test did not finish within the time bound set" >> $ERRORFILE
echo "ERROR: cgal_test did not finish within the time bound set" >> $ERROR_OUTPUT
fi
cat current_compiler_output >> $COMPILER_OUTPUT
cat current_compiler_output
rm -f current_compiler_output
if [ -f error.txt ] ; then
cat error.txt >> $ERRORFILE
cat error.txt >> $ERROR_OUTPUT
else
echo "ERROR: the script cgal_test failed to generate output" >> $ERRORFILE
fi
else
echo " Could not execute the script cgal_test in directory $1"
echo "ERROR: could not execute the script $1/cgal_test" >> $ERRORFILE
fi
echo >> $ERRORFILE
echo >> $ERROR_OUTPUT
fi
echo
}
#run_testsuite <makefile>
run_testsuite()
{
CGAL_MAKEFILE=$1
PLATFORM=`basename $1 | sed -e "s/makefile_//g"`
echo "---------------------------------------------------------------"
echo "- Testing platform $PLATFORM"
echo "---------------------------------------------------------------"
echo
echo "---------------------------------------------------------------" >> $ERRORFILE
echo "- TEST RESULTS FROM PLATFORM $PLATFORM" >> $ERRORFILE
echo "---------------------------------------------------------------" >> $ERRORFILE
echo >> $ERRORFILE
for DIR in $TEST_DIRECTORIES ; do
test_directory $DIR
done
}
if [ -z "$1" ] ; then
TEST_DIRECTORIES=`ls`
else
TEST_DIRECTORIES="$*"
fi
#-------------------------------------------------------------------$
# Add a line
#
# run_testsuite <include makefile>
#
# for all platforms that you want to test with.
#-------------------------------------------------------------------$
run_testsuite $CGAL_MAKEFILE