#! /bin/sh # # ============================================================================= # $URL: svn+ssh://fcacciola@scm.gforge.inria.fr/svn/cgal/trunk/Scripts/developer_scripts/create_cgal_test $ # $Id: create_cgal_test 36975 2007-03-09 22:52:40Z spion $ # # author(s) : Wieger Wesselink, Geert-Jan Giezeman # # coordinator : Utrecht University # ============================================================================= # # This script creates a cgal_test_with_cmake 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_with_cmake [--no-run]' echo echo ' --help : prints this usage help' echo ' --no-run : produces a cgal_test_with_cmake 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_with_cmake" 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 cat << EOF ERRORFILE=error.txt DO_RUN=${DO_RUN} if [ -z "\${MAKE_CMD}" ]; then MAKE_CMD=make fi NEED_CLEAN= EOF header "configure" cat << EOF configure() { echo "Configuring... " if eval 'cmake "\$CMAKE_GENERATOR" -DRUNNING_CGAL_AUTO_TEST=TRUE \\ -DCGAL_DIR="\$CGAL_DIR" \\ .' ; then echo " successful configuration" >> \$ERRORFILE else echo " ERROR: configuration" >> \$ERRORFILE fi } EOF header "compile_and_run " cat << EOF compile_and_run() { echo "Compiling \$1 ... " SUCCESS="y" if eval '\${MAKE_CMD} VERBOSE=ON -fMakefile \$1' ; then echo " successful compilation of \$1" >> \$ERRORFILE else echo " ERROR: compilation of \$1" >> \$ERRORFILE SUCCESS="" fi if [ -n "\$DO_RUN" ] ; then if [ -n "\${SUCCESS}" ] ; 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 " successful execution of \$1" >> \$ERRORFILE else echo " ERROR: execution of \$1" >> \$ERRORFILE fi else echo " ERROR: not executed \$1" >> \$ERRORFILE fi fi } EOF header "remove the previous error file" cat << EOF rm -f \$ERRORFILE touch \$ERRORFILE EOF header "configure, compile and run the tests" cat << EOF configure 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` cat < /dev/null; then compile_and_run $tmp NEED_CLEAN=y fi EOF fi done cat << EOF fi # # The clean target generated by CMake under cygwin # always fails for some reason # if [ -n "\${NEED_CLEAN}" ]; then if ! ( uname | grep -q "CYGWIN" ) ; then \${MAKE_CMD} -fMakefile clean fi fi EOF } if [ -f cgal_test_with_cmake ] ; then echo "moving cgal_test_with_cmake to cgal_test_with_cmake.bak ..." mv -f cgal_test_with_cmake cgal_test_with_cmake.bak fi create_script > cgal_test_with_cmake chmod 755 cgal_test_with_cmake echo "created cgal_test_with_cmake, version $VERSION, in $PWD ..."