#!/bin/sh # ---------------------------------------------------- # ---------------------------------------------------- # autotest_cgal: a script to automagically install and # test internal CGAL releases # ---------------------------------------------------- # You will need # * GNU wget and ftp # * or alternatively curl # # Furthermore you have to edit .autocgalrc in order to # cutomize it for your environment. # In particular you have to change the BUILHOSTS # variable to contain the names of your hosts and # set the COMPILERS_ variables to the # os-compilers descriptions on which you want to run # the testsuite. # ---------------------------------------------------- # ---------------------------------------------------- # # $URL $ # $Id $ #sets the umask to 022 & 0777 umask 022 SCP="scp" WGET="wget" WGET_OPTS="--no-check-certificate" CURL="curl" CURL_OPTS="-k --remote-name --silent --location-trusted" CGAL_URL="https://cgal.geometryfactory.com/CGAL/Members/Releases" LATEST_LOCATION="${CGAL_URL}/LATEST" TAR="tar" GZIP="gzip" GUNZIP="gunzip" COMPRESSOR="${GZIP}" SENDMAIL="mail" CGAL_TESTER=`whoami` CGAL_TESTER_NAME="${CGAL_TESTER}" CGAL_TESTER_ADDRESS="${CGAL_TESTER}" CONSOLE_OUTPUT="y" CGAL_ROOT=`pwd` FTP_SERVER="ftp-sop.inria.fr" FTP_STORE_DIR="geometrica/Incoming" FTP_OPTS="-p -v -n" UPLOAD_RESULT_DESTINATION="cgaltest@cgal.geometryfactory.com:incoming" BUILD_HOSTS="must_be_set_in_.autocgalrc" MAIL_ADDRESS="must_be_set_in_.autocgalrc" MYSHELL="must_be_set_in_.autocgalrc" ACTUAL_DIR=`pwd` FTP="ftp" LOGS_DIR="${CGAL_ROOT}/AUTOTEST_LOGS" RSH="rsh" LOCK_FILE="${CGAL_ROOT}/autotest_cgal.lock" NICE_OPTIONS="-19" for arg in "$@" do if [ "$arg" = "-c" ]; then echo "Using latest unzipped release instead of getting a new one from the server" USE_LATEST_UNZIPPED="y" fi if [ "$arg" = "-l" ]; then echo "Not uploading results to dashboard" DO_NOT_UPLOAD="y" fi if [ "$arg" = "-n" ]; then echo "Not testsuite will be launched. Compilation only." DO_NOT_TEST="y" fi done # Now loading autocgalrc. if [ -f $HOME/.autocgalrc ]; then . $HOME/.autocgalrc else echo "CONFIGURATION FILE .autocgalrc NOT FOUND"; fi # # write to logfile # # $1 = logfile log() { LOGFILE=${1} shift if [ -n "${CONSOLE_OUTPUT}" ]; then printf "${*} ..." fi printf "\n-------------------------------------------------------\n" \ >> ${LOGFILE} printf " ${*} ...\n" \ >> ${LOGFILE} printf "\n-------------------------------------------------------\n" \ >> ${LOGFILE} } # $1 = logfile log_done() { if [ -n "${CONSOLE_OUTPUT}" ]; then printf \ " done\n-------------------------------------------------------\n" fi printf "\n-------------------------------------------------------\n" \ >> ${1} printf " **DONE**\n" \ >> ${1} printf "\n-------------------------------------------------------\n" \ >> ${1} } # # produce a string containing the actual date/time # (used to identify files) # datestr() { date +%d%m%Y%H%M } # # function to put result files on the web # # $1 = source filename (full path) # $2 = target filename (basename only) put_on_web() { "$SCP" "${1}" "$UPLOAD_RESULT_DESTINATION"/$2 >> ${ACTUAL_LOGFILE} 2>&1 # if [ -n "${USE_CURL}" ]; then # $CURL --upload-file ${1} --user anonymous:${MAIL_ADDRESS} \ # ftp://${FTP_SERVER}/${FTP_STORE_DIR}/${2} >> ${ACTUAL_LOGFILE} 2>&1 # else # $FTP $FTP_OPTS $FTP_SERVER >> ${ACTUAL_LOGFILE} 2>&1 <> ${ACTUAL_LOGFILE} ${COMPRESSOR} -9f ${ACTUAL_LOGFILE} FILENAME="${CGAL_RELEASE_ID}-log`datestr`.gz" mv ${ACTUAL_LOGFILE}.gz ${LOGS_DIR}/${FILENAME} if [ ! "${MAIL_ADDRESS}" = "must_be_set_in_.autocgalrc" ]; then for i in ${MAIL_ADDRESS}; do printf "ERROR\n${LOGS_DIR}/${FILENAME}\n" | \ ${SENDMAIL} -s "completed autotest" ${i} done fi rm -rf $LOCK_FILE; exit 1 } # # function to print the value of variable $1 # value_of() { _value=`eval "printf '$'${1}"` eval "printf \"${_value}\"" } # # function for executing a command remotely # # $1 = HOST # $2 = COMMAND remote_command() { if [ "${1}" = "localhost" ]; then eval $2 else printf "** Logging into host ${1} **\n" ${RSH} ${1} ${MYSHELL} \"${2}\" fi } # # function for building the CGAL libs # # $1 = HOST build_cgal_libs() { if [ -z "`value_of BUILD_ON_${1}`" ]; then eval "BUILD_ON_${1}=\"`value_of COMPILERS_${1}`\"" fi if [ "`value_of BUILD_ON_${1}`" = "all" ]; then remote_command ${1} \ "cd ${CGAL_DIR}; export MAKEFLAGS=${MAKEFLAGS}; ${CGAL_DIR}/install_cgal --CGAL_DIR ${CGAL_DIR} --rebuild-all" \ >> ${ACTUAL_LOGFILE} 2>&1 else for j in `value_of BUILD_ON_${1}`; do remote_command ${1} \ "cd ${CGAL_DIR}; export MAKEFLAGS=${MAKEFLAGS}; ${CGAL_DIR}/install_cgal --CGAL_DIR ${CGAL_DIR} --rebuild ${j}" \ >> ${ACTUAL_LOGFILE} 2>&1 done fi cp ${CGAL_DIR}/install.log* ${CGAL_TEST_DIR}/ } #----------------------------------------------- # testsuite script parallel #----------------------------------------------- # $1 = HOST # $2 = COMPILERS run_testsuite() { for i in ${2}; do test_script ${1} ${i} done } # --------------------------------------------------- # test script NEW # create additional directories to test in parallel # on multiple platforms # the variable PROCESSORS_electra, where electra is the # name of the machine, is used to specify the number of # processors to use # --------------------------------------------------- # $1 = HOST # $2 = COMPILER test_script() { NUMBER_OF_PROCESSORS="`value_of PROCESSORS_${1}`" cd ${CGAL_TEST_DIR} TEST_DIR_ROOT=${TEST_DIR_ROOT:-${CGAL_DIR}} LOCAL_TEST_DIR=${TEST_DIR_ROOT}/test_${2} log ${ACTUAL_LOGFILE}.${1} "Testing on ${1} with ${2}" if [ "${NUMBER_OF_PROCESSORS}" = "1" ] ; then MAKE_OPTS="" else MAKE_OPTS="-j ${NUMBER_OF_PROCESSORS}" fi cat > ${CGAL_TEST_DIR}/localtestscript.${1} <> ${ACTUAL_LOGFILE}.${1} 2>&1 log_done ${ACTUAL_LOGFILE}.${1} #PLATFORM=`basename $CGAL_MAKEFILE | sed -e "s/makefile_//g"` # # collect results and put them on the web # cd ${CGAL_TEST_DIR} log ${ACTUAL_LOGFILE}.${1} "PUTTING RESULTS ON THE WEB" log ${ACTUAL_LOGFILE}.${1} "RESULTS COLLECTED "${2}"-"${1} ${TAR} cf test_results-${1}.tar "results_"$CGAL_TESTER"_"${2}".tar.gz" "results_"$CGAL_TESTER"_"${2}".txt" ${COMPRESSOR} -9f test_results-${1}.tar COMPILER=`echo $2 | tr -c '[A-Za-z0-9]./[=-=]*_\'\''\":?() ' 'x'` FILENAME="${CGAL_RELEASE_ID}_${CGAL_TESTER}-test`datestr`-${COMPILER}.tar.gz" LOGFILENAME="${CGAL_RELEASE_ID}-log`datestr`-${1}.gz" ${COMPRESSOR} -9f ${ACTUAL_LOGFILE}.${1} mv ${ACTUAL_LOGFILE}.${1}.gz ${LOGS_DIR}/${LOGFILENAME} if [ -z "${DO_NOT_UPLOAD}" ]; then put_on_web \ test_results-${1}.tar.gz \ "${FILENAME}" fi # # notify the CGAL world # if [ ! "${MAIL_ADDRESS}" = "must_be_set_in_.autocgalrc" ]; then for i in ${MAIL_ADDRESS}; do printf "result collection::\n${FILENAME}\n" | ${SENDMAIL} -s "autohandle" ${i} done fi } # ---------------------------------------------------- # get CGAL # get_cgal() { log ${ACTUAL_LOGFILE} "getting CGAL" rm -f ${CGAL_ZIPFILE} if [ -n "${USE_CURL}" ]; then ${CURL} ${CURL_OPTS} ${CGAL_LOCATION} >> ${ACTUAL_LOGFILE} 2>&1 else ${WGET} ${WGET_OPTS} ${CGAL_LOCATION} >> ${ACTUAL_LOGFILE} 2>&1 fi if [ ${?} != 0 ]; then error "Could not get CGAL" fi log_done ${ACTUAL_LOGFILE} } # ---------------------------------------------------- # unzip/untar CGAL # unzip_cgal() { cd ${CGAL_ROOT} log ${ACTUAL_LOGFILE} "unzipping CGAL" if [ "${USE_TARGZ}" = "y" ]; then DECOMPRESSOR="${GUNZIP}" log_done ${ACTUAL_LOGFILE} fi if [ "${USE_TARBZ}" = "y" ]; then DECOMPRESSOR="bunzip2" fi log ${ACTUAL_LOGFILE} "untarring CGAL" ${DECOMPRESSOR} -c ${CGAL_ZIPFILE} | ${TAR} xf - >> ${ACTUAL_LOGFILE} 2>&1 if [ ${?} != 0 ]; then error "Could not untar CGAL" fi log_done ${ACTUAL_LOGFILE} } # ---------------------------------------------------- # copy stuff from old CGAL installation # copy_old_stuff() { # copy config install files if [ ! ${OLD_CGAL_DIR} -ef ${CGAL_DIR} ]; then cd ${CGAL_DIR} ./install_cgal --upgrade ${OLD_CGAL_DIR} >> ${ACTUAL_LOGFILE} ## copy CMake cache files, if there exists any. cd ${OLD_CGAL_BINARY_DIR_BASE} for platform in * do if [ -d "${platform}" ]; then # if the platform folder doesn't exist in the tested release it is created now. if [ ! -d "${CGAL_BINARY_DIR_BASE}/${platform}" ]; then log ${ACTUAL_LOGFILE} "Creating platform folder ${platform} in ${CGAL_BINARY_DIR_BASE}/" mkdir "${CGAL_BINARY_DIR_BASE}/${platform}" fi # If there is any configuration cached in the old release, copy it if [ -f "${platform}/CMakeCache.txt" ]; then log ${ACTUAL_LOGFILE} "Copying old ${platform}/CMakeCache.txt into ${CGAL_BINARY_DIR_BASE}/${platform}/" cp "${platform}/CMakeCache.txt" "${CGAL_BINARY_DIR_BASE}/${platform}" >> ${ACTUAL_LOGFILE} fi fi done # update symbolic links rm ${OLD_CGAL_DIR} ln -s `basename ${CGAL_DIR}` ${OLD_CGAL_DIR} rm ${CURRENT_CGAL_DIR} ln -s `basename ${CGAL_DIR}` ${CURRENT_CGAL_DIR} log_done ${ACTUAL_LOGFILE} fi } # ---------------------------------------------------- # build cgal # build_cgal() { log ${ACTUAL_LOGFILE} "building cgal libs" for i in ${BUILD_HOSTS}; do build_cgal_libs ${i} done log_done ${ACTUAL_LOGFILE} ${COMPRESSOR} -9f ${ACTUAL_LOGFILE} mv ${ACTUAL_LOGFILE}.gz \ ${LOGS_DIR}/${CGAL_RELEASE_ID}-log`datestr`.gz } # ---------------------------------------------------- # run the testsuites # run_test() { log ${ACTUAL_LOGFILE} "running the testsuites" if [ -n "${CONSOLE_OUTPUT}" ]; then printf "\n-------------------------------------------------------\n" fi for i in ${BUILD_HOSTS}; do run_testsuite ${i} "`value_of COMPILERS_${i}`" & done } # ---------------------------------------------------- # START OF MAIN BODY # ---------------------------------------------------- USE_TARGZ="n" USE_TARBZ="n" # logfile ACTUAL_LOGFILE="${CGAL_ROOT}/`basename ${0}`.log" cd $CGAL_ROOT CRITICAL="n" if [ "${MYSHELL}" = "must_be_set_in_.autocgalrc" ]; then log ${ACTUAL_LOGFILE} "MYSHELL must be set in .autocgalrc" CRITICAL="y" fi if [ "${CRITICAL}" = "y" ]; then error "COULD NOT DETERMINE MYSHELL!" fi lockfile -r 5 $LOCK_FILE; if [ ${?} != 0 ]; then echo "COULD NOT AQUIRE LOCK!"; exit 1; fi if [ -r "LATEST" ]; then rm -rf LATEST fi log ${ACTUAL_LOGFILE} "getting LATEST" if [ -n "${USE_CURL}" ]; then ${CURL} ${CURL_OPTS} ${LATEST_LOCATION} >> ${ACTUAL_LOGFILE} 2>&1 else ${WGET} ${WGET_OPTS} ${LATEST_LOCATION} >> ${ACTUAL_LOGFILE} 2>&1 fi if [ ! -f "LATEST" ]; then error "COULD NOT DOWNLOAD LATEST!" fi if [ -r "RELEASE_NR" ]; then cmp LATEST RELEASE_NR > ${ACTUAL_LOGFILE} if [ ! ${?} != 0 ]; then rm -f $LOCK_FILE; exit 1; fi fi for i in `cat LATEST` do CGAL_LOCATION="${CGAL_URL}/${i}"; CGAL_ZIPFILE="${i}"; done CGAL_RELEASE_ID=`echo $CGAL_ZIPFILE | sed "s/.tar.gz//"` if [ ! "${CGAL_RELEASE_ID}" = "${CGAL_ZIPFILE}" ]; then USE_TARGZ="y" else CGAL_RELEASE_ID=`echo $CGAL_ZIPFILE | sed "s/.tar.bz2//"` if [ ! "${CGAL_RELEASE_ID}" = "${CGAL_ZIPFILE}" ]; then USE_TARBZ="y" fi fi CGAL_CURRENT_RELEASE_ID=`echo $CGAL_RELEASE_ID | sed -e 's/-I.*//'`-I # dir for the actual release CGAL_DIR=${CGAL_ROOT}/${CGAL_RELEASE_ID} # dir of the previous release # HAS TO exist ! # (used to copy config/install files and evt. gmp stuff) OLD_CGAL_DIR=${CGAL_ROOT}/CGAL-I CURRENT_CGAL_DIR=${CGAL_ROOT}/${CGAL_CURRENT_RELEASE_ID} # you will guess it :) CGAL_INCL_DIR=${CGAL_DIR}/include OLD_CGAL_INCL_DIR=${OLD_CGAL_DIR}/include CGAL_LIB_DIR=${CGAL_DIR}/lib OLD_CGAL_LIB_DIR=${OLD_CGAL_DIR}/lib CGAL_MAKE_DIR=${CGAL_DIR}/make CGAL_TEST_DIR=${CGAL_DIR}/test CGAL_RUN_TEST=${CGAL_TEST_DIR}/run_testsuite CGAL_COLLECT_TEST=${CGAL_TEST_DIR}/collect_cgal_testresults # variables used to copy cmake stuffs OLD_CGAL_BINARY_DIR_BASE=${OLD_CGAL_DIR}/cmake/platforms CGAL_BINARY_DIR_BASE=${CGAL_DIR}/cmake/platforms # ---------------------------------------------------- # some sanity checks # # remove old logfile rm -f ${ACTUAL_LOGFILE} # check, if OLD_CGAL_DIR exists and is a symbolic link if [ ! -r ${OLD_CGAL_DIR} -o ! -d ${OLD_CGAL_DIR} ]; then error "directory ${OLD_CGAL_DIR} does not exist" fi if [ ! -h ${OLD_CGAL_DIR} ]; then error "${OLD_CGAL_DIR} has to be a symbolic link" fi if [ ! -r ${LOGS_DIR} ]; then mkdir $LOGS_DIR fi if [ ! "${MAIL_ADDRESS}" = "must_be_set_in_.autocgalrc" ]; then for i in ${MAIL_ADDRESS}; do printf "subject says it all\n" | \ ${SENDMAIL} -s "Started autotest" ${i} done fi # do the job main_procedure() { if [ "${BUILD_HOSTS}" = "must_be_set_in_.autocgalrc" ]; then error "BUILD_HOSTS must be set in .autocgalrc" else for i in ${BUILD_HOSTS}; do TEXT="`value_of COMPILERS_${i}`" if [ -z "${TEXT}" ]; then error "COMPILERS_${i} must be defined in .autocgalrc" else TEXT="`value_of PROCESSORS_${i}`" TEMPVAR="PROCESSORS_${i}" if [ -z "${TEXT}" ]; then log ${ACTUAL_LOGFILE} "\ngiving default 1 values TO PROCESSORS_${i} ..."; eval $TEMPVAR="1"; fi fi done fi get_cgal unzip_cgal copy_old_stuff build_cgal if [ -z "${DO_NOT_TEST}" ]; then run_test fi } if [ "${BUILD_HOSTS}" = "localhost" ]; then TEXT="`value_of COMPILERS_localhost`" if [ -z "${TEXT}" ]; then # printf "\nWARNING: Only installing on localhost\n"; get_cgal unzip_cgal copy_old_stuff build_cgal; else main_procedure; fi else main_procedure; fi # restore settings: cd ${CGAL_ROOT} mv LATEST RELEASE_NR rm -f $LOCK_FILE; # EOF