cgal/Packages/Arrangement/test/Arrangement_2/cgal_test

231 lines
6.7 KiB
Bash
Executable File

#! /bin/sh
# This is a script for the CGAL test suite. Such a script must obey
# the following rules:
#
# - the name of the script is cgal_test
# - for every target two one line messages are written to the file 'error.txt'
# the first one indicates if the compilation was successful
# the second one indicates if the execution was successful
# if one of the two was not successful, the line should start with 'ERROR:'
# - running the script should not require any user interaction
# - the script should clean up object files and executables
ERRORFILE=error.txt
#---------------------------------------------------------------------#
# compile_and_run <target>
#---------------------------------------------------------------------#
compile()
{
EXTRA_FLAGS="-DCGAL_ARR_TEST_POINT_LOCATION=$2 -DCGAL_ARR_TEST_TRAITS=$3 \
$EXTRA_FLAGS "
export EXTRA_FLAGS
echo "Compiling $1 with point location $2 and traits $3... "
eval 'make CGAL_MAKEFILE=$CGAL_MAKEFILE \
TESTSUITE_CXXFLAGS="$TESTSUITE_CXXFLAGS" \
TESTSUITE_LDFLAGS="$TESTSUITE_LDFLAGS" $1'
}
compile_and_run()
{
echo "---$1---"
# running general test
if compile test_arr $2 $3 ; then
echo " compilation of $1 succeeded" >> $ERRORFILE
REVERSE="no"
run test_arr $2 $3
REVERSE="reverse"
run test_arr $2 $3
else
echo " ERROR: compilation of $1 failed" >> $ERRORFILE
fi
# running io test (not for conic_traits).
if [ $3 -ne $CGAL_CONIC_TRAITS ]; then
if compile test_io $2 $3 ; then
echo " compilation of $1_io succeeded" >> $ERRORFILE
run_io test_io $2 $3
else
echo " ERROR: compilation of $1_io failed" >> $ERRORFILE
fi
fi
eval "2>&1 make CGAL_MAKEFILE=$CGAL_MAKEFILE clean > /dev/null "
}
run()
{
OUTPUTFILE=ProgramOutput.$1.$PLATFORM
if [ ! -f $OUTPUTFILE ] ; then
touch $OUTPUTFILE
fi
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $OUTPUTFILE
if [ $3 -eq $CGAL_SEGMENT_TRAITS -o $3 -eq $CGAL_SEGMENT_LEDA_TRAITS ] ; then
datafiles="DATA/segments/*"
elif [ $3 -eq $CGAL_POLYLINE_TRAITS ]; then
datafiles="DATA/polylines/*"
elif [ $3 -eq $CGAL_CONIC_TRAITS ]; then
datafiles="DATA/segment_circles/*"
fi
for DATAFILE in ${datafiles}
do
if [ -d $DATAFILE ]; then
echo "$DATEFILE is a directory"
continue
fi
if [ -f $1 ] ; then
DATANAME=`basename $DATAFILE`
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $OUTPUTFILE
echo "Output of $1 Traits=$3 and PL=$2 with $DATANAME" >> $OUTPUTFILE
if test $REVERSE = "reverse" ; then
echo "Curves in reversed order." >> $OUTPUTFILE
fi
COMMAND="./$1 $DATAFILE $REVERSE"
echo "Executing $1 $DATANAME $REVERSE ... "
echo
if eval $COMMAND >> $OUTPUTFILE 2>&1 ; then
echo " execution of $1 $DATAFILE $REVERSE succeeded" >> $ERRORFILE
else
echo " ERROR: execution of $1 $DATAFILE $REVERSE failed" >> $ERRORFILE
fi
else
echo " ERROR: could not execute $1 $DATAFILE $REVERSE" >> $ERRORFILE
fi
done
}
run_io()
{
OUTPUTFILE=ProgramOutput.$1.$PLATFORM
if [ ! -f $OUTPUTFILE ] ; then
touch $OUTPUTFILE
fi
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $OUTPUTFILE
if [ $3 -eq $CGAL_SEGMENT_TRAITS -o $3 -eq $CGAL_SEGMENT_LEDA_TRAITS ] ; then
datafiles="DATA/IO/segments/*"
elif [ $3 -eq $CGAL_POLYLINE_TRAITS ]; then
datafiles="DATA/IO/polylines/*"
fi
if [ $3 -eq $CGAL_SEGMENT_TRAITS ] ; then
iofiles="DATA/IO/segments/exact_io/"
SUFFIO="exact_io"
elif [ $3 -eq $CGAL_SEGMENT_LEDA_TRAITS ] ; then
iofiles="DATA/IO/segments/leda_io/"
SUFFIO="leda_io"
elif [ $3 -eq $CGAL_POLYLINE_TRAITS ]; then
iofiles="DATA/IO/polylines/exact_io/"
SUFFIO="exact_io"
elif [ $3 -eq $CGAL_CONIC_TRAITS ]; then
# Avoid running test_io with conic_traits
return
fi
for DATAFILE in ${datafiles}
do
if [ -d $DATAFILE ]; then
echo "$DATEFILE is a directory"
continue
fi
IOFILE="${iofiles}`basename ${DATAFILE}`_${SUFFIO}"
if [ -f $1 ] ; then
rm -f arr.txt
DATANAME=`basename $DATAFILE`
IONAME=`basename $IOFILE`
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $OUTPUTFILE
echo "Output of $1 Traits=$3 and PL=$2 with $DATANAME" >> $OUTPUTFILE
COMMAND="./$1 $IOFILE $DATAFILE"
echo "Executing $1 $IONAME $DATANAME ... "
echo
if eval $COMMAND >> $OUTPUTFILE 2>&1 ; then
echo " execution of $1 $DATAFILE succeeded" >> $ERRORFILE
else
echo " ERROR: execution of $1 $DATAFILE failed" >> $ERRORFILE
fi
else
echo " ERROR: could not execute $1 $DATAFILE " >> $ERRORFILE
fi
done
}
#---------------------------------------------------------------------#
# remove the previous error file
#---------------------------------------------------------------------#
rm -f $ERRORFILE
touch $ERRORFILE
rm -f ProgramOutput.*.$PLATFORM
#---------------------------------------------------------------------#
# compile and run the tests
#---------------------------------------------------------------------#
if [ $# -ne 0 ] ; then
for file in $* ; do
compile_and_run $file
done
else
CGAL_SEGMENT_TRAITS=1
CGAL_SEGMENT_CACHED_TRAITS=2
CGAL_POLYLINE_TRAITS=11
CGAL_POLYLINE_CACHED_TRAITS=12
CGAL_SEGMENT_LEDA_TRAITS=21
CGAL_SEGMENT_CACHED_LEDA_TRAITS=22
CGAL_POLYLINE_LEDA_TRAITS=31
CGAL_POLYLINE_CACHED_LEDA_TRAITS=32
CGAL_CONIC_TRAITS=41
TRAP=1 # Trapezoidal decomposition
NAIVE=2
WALK=3
SIMPLE=4
# run test with generic segment traits
(compile_and_run test $TRAP $CGAL_SEGMENT_TRAITS)
(compile_and_run test $NAIVE $CGAL_SEGMENT_TRAITS)
(compile_and_run test $WALK $CGAL_SEGMENT_TRAITS)
(compile_and_run test $SIMPLE $CGAL_SEGMENT_TRAITS)
# run test with generic segment traits
(compile_and_run test $TRAP $CGAL_SEGMENT_CACHED_TRAITS)
(compile_and_run test $NAIVE $CGAL_SEGMENT_CACHED_TRAITS)
(compile_and_run test $WALK $CGAL_SEGMENT_CACHED_TRAITS)
(compile_and_run test $SIMPLE $CGAL_SEGMENT_CACHED_TRAITS)
# run test with generic polyline traits
(compile_and_run test $TRAP $CGAL_POLYLINE_TRAITS)
(compile_and_run test $NAIVE $CGAL_POLYLINE_TRAITS)
(compile_and_run test $WALK $CGAL_POLYLINE_TRAITS)
(compile_and_run test $SIMPLE $CGAL_POLYLINE_TRAITS)
# run test with generic polyline traits
(compile_and_run test $TRAP $CGAL_POLYLINE_CACHED_TRAITS)
(compile_and_run test $NAIVE $CGAL_POLYLINE_CACHED_TRAITS)
(compile_and_run test $WALK $CGAL_POLYLINE_CACHED_TRAITS)
(compile_and_run test $SIMPLE $CGAL_POLYLINE_CACHED_TRAITS)
# run test with segment conic traits
(compile_and_run test $WALK $CGAL_CONIC_TRAITS)
fi