#! /bin/sh # # ============================================================================= # $URL$ # $Id$ # # author(s) : Wieger Wesselink, Geert-Jan Giezeman # # coordinator : Utrecht University # ============================================================================= # # This script creates a cgal_test script with entries for all .C and .cpp # files in the current test directory. VERSION=1.1 DO_RUN="y" while [ $1 ]; do case "$1" in -h|-help|--h|--help) echo 'Usage : create_cgal_test [--no-run]' echo echo ' --help : prints this usage help' echo ' --no-run : produces a cgal_test script that only does compilation, no execution' exit ;; --no-run) DO_RUN="" shift; continue ;; esac done header() { echo "#---------------------------------------------------------------------#" echo "# $1" echo "#---------------------------------------------------------------------#" } create_script() { echo "#! /bin/sh" echo echo "# This is a script for the CGAL test suite. Such a script must obey" echo "# the following rules:" echo "#" echo "# - the name of the script is cgal_test" echo "# - for every target two one line messages are written to the file 'error.txt'" echo "# the first one indicates if the compilation was successful" echo "# the second one indicates if the execution was successful" echo "# if one of the two was not successful, the line should start with 'ERROR:'" echo "# - running the script should not require any user interaction" echo "# - the script should clean up object files and executables" echo echo "ERRORFILE=error.txt" echo "DO_RUN=${DO_RUN}" echo header "compile_and_run " echo cat << EOF compile_and_run() { echo "Compiling \$1 ... " SUCCES="y" if eval 'make CGAL_MAKEFILE=\$CGAL_MAKEFILE \\ TESTSUITE_CXXFLAGS="\$TESTSUITE_CXXFLAGS" \\ TESTSUITE_LDFLAGS="\$TESTSUITE_LDFLAGS" \$1' ; then echo " succesful compilation of \$1" >> \$ERRORFILE else echo " ERROR: compilation of \$1" >> \$ERRORFILE SUCCES="" fi if [ -n "\$DO_RUN" ] ; then if [ -n "\${SUCCES}" ] ; then OUTPUTFILE=ProgramOutput.\$1.\$PLATFORM rm -f \$OUTPUTFILE COMMAND="./\$1" if [ -f \$1.cmd ] ; then COMMAND="\$COMMAND \`cat \$1.cmd\`" fi if [ -f \$1.cin ] ; then COMMAND="cat \$1.cin | \$COMMAND" fi echo "Executing \$1 ... " echo ulimit -t 3600 2> /dev/null if eval \$COMMAND > \$OUTPUTFILE 2>&1 ; then echo " succesful execution of \$1" >> \$ERRORFILE else echo " ERROR: execution of \$1" >> \$ERRORFILE fi else echo " ERROR: not executed \$1" >> \$ERRORFILE fi fi eval "make CGAL_MAKEFILE=\$CGAL_MAKEFILE clean > /dev/null 2>&1 " } EOF header "remove the previous error file" echo echo "rm -f \$ERRORFILE" echo "touch \$ERRORFILE" echo header "compile and run the tests" echo cat << EOF if [ \$# -ne 0 ] ; then for file in \$* ; do compile_and_run \$file done else echo "Run all tests." EOF for file in `ls *.C *.cpp 2>/dev/null | sort` ; do if [ -n "`grep '\' $file`" ] ; then tmp=`basename $file .C` tmp=`basename $tmp .cpp` echo " compile_and_run $tmp" fi done echo "fi" } echo "create_cgal_test version $VERSION" if [ -f cgal_test ] ; then echo "moving cgal_test to cgal_test.bak ..." mv -f cgal_test cgal_test.bak fi create_script > cgal_test chmod 755 cgal_test echo "created cgal_test ..."