cgal/Packages/Planar_map/test/Planar_map_IO/cgal_test

135 lines
3.8 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_and_run()
{
EXTRA_FLAGS="-DCGAL_PM_TEST_POINT_LOCATION=$2 -DCGAL_PM_TEST_TRAITS=$3 \
$EXTRA_FLAGS "
export EXTRA_FLAGS
echo "Compiling $1 with point location $2 and traits $3... "
if eval 'make CGAL_MAKEFILE=$CGAL_MAKEFILE \
TESTSUITE_CXXFLAGS="$TESTSUITE_CXXFLAGS" \
TESTSUITE_LDFLAGS="$TESTSUITE_LDFLAGS" $1' ; then
echo " compilation of $1 succeeded" >> $ERRORFILE
run $1 $2 $3
else
echo " ERROR: compilation of $1 failed" >> $ERRORFILE
fi
eval "2>&1 make CGAL_MAKEFILE=$CGAL_MAKEFILE clean > /dev/null "
}
run()
{
#if [ $3 -eq $CGAL_SEGMENT_TRAITS -o $3 -eq $CGAL_SEGMENT_LEDA_TRAITS ] ; then
# datafiles="DATA/segments/*"
#elif [ $3 -eq $CGAL_POLYLINE_TRAITS -o $3 -eq $CGAL_POLYLINE_LEDA_TRAITS ]; then
# datafiles="DATA/polylines/*"
#fi
datafiles="DATA/*"
if [ $3 -eq $CGAL_SEGMENT_TRAITS ] ; then
iofiles="DATA/exact_io/"
SUFFIO="exact_io"
elif [ $3 -eq $CGAL_SEGMENT_CACHED_TRAITS ] ; then
iofiles="DATA/exact_io/"
SUFFIO="leda_io"
elif [ $3 -eq $CGAL_SEGMENT_LEDA_TRAITS ] ; then
iofiles="DATA/leda_io/"
SUFFIO="leda_io"
fi
for DATAFILE in ${datafiles}
do
if [ -d $DATAFILE ]; then
echo " $DATEFILE is a directory"
continue
fi
IOFILE="${iofiles}`basename ${DATAFILE}`_${SUFFIO}"
echo $IOFILE
if [ -f $1 ] ; then
rm -f pm.txt
DATANAME=`basename $DATAFILE`
IONAME=`basename $IOFILE`
#if [ $REVERSE="reverse" ] ; then
# OUTPUTFILE=ProgramOutput.$3.$1.$DATANAME.$REVERSE.$PLATFORM.$2
#else
OUTPUTFILE=ProgramOutput.$3.$1.$DATANAME.$PLATFORM.$2
#fi
rm -f $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
#---------------------------------------------------------------------#
# 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_SEGMENT_LEDA_TRAITS=3
# CGAL_POLYLINE_TRAITS=11
# CGAL_POLYLINE_CACHED_TRAITS=12
# CGAL_POLYLINE_LEDA_TRAITS=13
CGAL_PM_TEST_TRAITS=$CGAL_SEGMENT_TRAITS
(compile_and_run test 1 $CGAL_PM_TEST_TRAITS)
(compile_and_run test 2 $CGAL_PM_TEST_TRAITS)
(compile_and_run test 3 $CGAL_PM_TEST_TRAITS)
# CGAL_PM_TEST_TRAITS=$CGAL_SEGMENT_CACHED_TRAITS
# (compile_and_run test 1 $CGAL_PM_TEST_TRAITS)
# (compile_and_run test 2 $CGAL_PM_TEST_TRAITS)
# (compile_and_run test 3 $CGAL_PM_TEST_TRAITS)
fi