#! /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 REVERSE="no" run $1 $2 $3 REVERSE="reverse" 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() { OUTPUTFILE=ProgramOutput.$1.$PLATFORM if [ ! -f $OUTPUTFILE ] ; then touch $OUTPUTFILE fi echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $OUTPUTFILE if [ $3 -eq $CGAL_SEGMENT_TRAITS -o $3 -eq $CGAL_SEGMENT_CACHED_TRAITS -o \ $3 -eq $CGAL_SEGMENT_LEDA_TRAITS -o $3 -eq $CGAL_SEGMENT_CACHED_LEDA_TRAITS ] ; then datafiles="DATA/segments/*" elif [ $3 -eq $CGAL_POLYLINE_TRAITS ] ; then datafiles="DATA/polylines/*" 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 # if [ $REVERSE="reverse" ] ; then # OUTPUTFILE=ProgramOutput.$3.$1.$DATANAME.$REVERSE.$PLATFORM.$2 # else # OUTPUTFILE=ProgramOutput.$3.$1.$DATANAME.$PLATFORM.$2 # 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 } #---------------------------------------------------------------------# # 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 TRAP=1 # Trapezoidal decomposition NAIVE=2 WALK=3 SIMPLE=4 # run test with generic segment traits (compile_and_run test_pmwx $TRAP $CGAL_SEGMENT_TRAITS) (compile_and_run test_pmwx $NAIVE $CGAL_SEGMENT_TRAITS) (compile_and_run test_pmwx $WALK $CGAL_SEGMENT_TRAITS) (compile_and_run test_pmwx $SIMPLE $CGAL_SEGMENT_TRAITS) # run test with leda segment traits (compile_and_run test_pmwx $TRAP $CGAL_SEGMENT_CACHED_TRAITS) (compile_and_run test_pmwx $NAIVE $CGAL_SEGMENT_CACHED_TRAITS) (compile_and_run test_pmwx $WALK $CGAL_SEGMENT_CACHED_TRAITS) (compile_and_run test_pmwx $SIMPLE $CGAL_SEGMENT_CACHED_TRAITS) # run test with generic polyline traits (compile_and_run test_pmwx $TRAP $CGAL_POLYLINE_TRAITS) (compile_and_run test_pmwx $NAIVE $CGAL_POLYLINE_TRAITS) (compile_and_run test_pmwx $WALK $CGAL_POLYLINE_TRAITS) (compile_and_run test_pmwx $SIMPLE $CGAL_POLYLINE_TRAITS) # run test with generic polyline traits (compile_and_run test_pmwx $TRAP $CGAL_POLYLINE_CACHED_TRAITS) (compile_and_run test_pmwx $NAIVE $CGAL_POLYLINE_CACHED_TRAITS) (compile_and_run test_pmwx $WALK $CGAL_POLYLINE_CACHED_TRAITS) (compile_and_run test_pmwx $SIMPLE $CGAL_POLYLINE_CACHED_TRAITS) fi