#! /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 #---------------------------------------------------------------------# 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 $1 $2 $3 ; then echo " compilation of $1 succeeded" >> $ERRORFILE SUBCURVES="" run $1 $2 $3 $4 SUBCURVES="subcurves" run $1 $2 $3 $4 else echo " ERROR: compilation of $1 failed" >> $ERRORFILE fi eval "2>&1 make CGAL_MAKEFILE=$CGAL_MAKEFILE clean > /dev/null " } compile_and_run_sweep() { echo "---$1---" # running general test if compile $1 $2 $3 ; then echo " compilation of $1 succeeded" >> $ERRORFILE run $1 $2 $3 $4 else echo " ERROR: compilation of $1 failed" >> $ERRORFILE fi eval "2>&1 make CGAL_MAKEFILE=$CGAL_MAKEFILE clean > /dev/null " } run() { datafiles="$4/*" for DATAFILE in ${datafiles} do if [ -d $DATAFILE ]; then echo "$DATEFILE is a directory" continue fi if [ -f $1 ] ; then DATANAME=`basename $DATAFILE` if [ $SUBCURVES="subcurves" ] ; then OUTPUTFILE=ProgramOutput.$3.$1.$DATANAME.$SUBCURVES.$PLATFORM.$2 else OUTPUTFILE=ProgramOutput.$3.$1.$DATANAME.$PLATFORM.$2 fi rm -f $OUTPUTFILE COMMAND="./$1 $DATAFILE $SUBCURVES" echo "Executing $1 $DATANAME $SUBCURVES ... " echo if eval $COMMAND > $OUTPUTFILE 2>&1 ; then echo " execution of $1 $DATAFILE $SUBCURVES succeeded" >> $ERRORFILE else echo " ERROR: execution of $1 $DATAFILE $SUBCURVES failed" >> $ERRORFILE fi else echo " ERROR: could not execute $1 $DATAFILE $SUBCURVES" >> $ERRORFILE fi done } run_io() { datafiles="$4/*" 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" 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 arr.txt DATANAME=`basename $DATAFILE` IONAME=`basename $IOFILE` OUTPUTFILE=ProgramOutput.$3.$1.$DATANAME.$PLATFORM.$2 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_LEDA_TRAITS=2 CGAL_POLYLINE_TRAITS=11 CGAL_CONIC_TRAITS=21 TRAP=1 # Trapezoidal decomposition NAIVE=2 WALK=3 #run the test for new sweep (compile_and_run_sweep test_sweep $NAIVE $CGAL_SEGMENT_TRAITS "DATA/segments_tight") (compile_and_run_sweep test_sweep_conic $NAIVE $CGAL_CONIC_TRAITS "DATA/conics") exit 0 # run test with generic segment traits (compile_and_run test $TRAP $CGAL_SEGMENT_TRAITS "DATA/segments") (compile_and_run test $NAIVE $CGAL_SEGMENT_TRAITS "DATA/segments") (compile_and_run test $WALK $CGAL_SEGMENT_TRAITS "DATA/segments") # run test with leda segment traits (compile_and_run test $TRAP $CGAL_SEGMENT_LEDA_TRAITS "DATA/segments") (compile_and_run test $NAIVE $CGAL_SEGMENT_LEDA_TRAITS "DATA/segments") (compile_and_run test $WALK $CGAL_SEGMENT_LEDA_TRAITS "DATA/segments") # run test with generic polyline traits (compile_and_run test $TRAP $CGAL_POLYLINE_TRAITS "DATA/polylines") (compile_and_run test $NAIVE $CGAL_POLYLINE_TRAITS "DATA/polylines") (compile_and_run test $WALK $CGAL_POLYLINE_TRAITS "DATA/polylines") # run test with conic traits (compile_and_run test $WALK $CGAL_CONIC_TRAITS "DATA/segment_circles") fi