From 26c79928b5e0861075dded9f8f13afe577f2ef9e Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Thu, 26 Apr 2018 10:44:52 +0100 Subject: [PATCH] tutorials: Clean up of Allrun and Alltest scripts --- tutorials/Allrun | 60 +++++++++++++++++++++++++---------------------- tutorials/Alltest | 10 ++++---- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/tutorials/Allrun b/tutorials/Allrun index 18bf296ada..190b4623c4 100755 --- a/tutorials/Allrun +++ b/tutorials/Allrun @@ -33,13 +33,11 @@ cd ${0%/*} || exit 1 # Run from this directory # Source tutorial run functions . $WM_PROJECT_DIR/bin/tools/RunFunctions -dir=${PWD##*/} # logReport -# Extracts useful info from log file. +# Extracts useful info from log file logReport() { - err=0 caseName=`dirname $1 | sed s/"\(.*\)\.\/"/""/g` app=`echo $1 | sed s/"\(.*\)log\."/""/g` appAndCase="Application $app - case $caseName" @@ -53,11 +51,11 @@ logReport() if [ "$fatalError" ] then echo "$appAndCase: ** FOAM FATAL ERROR **" - err=1 + return 1 elif [ "$UxSS" -a "$UySS" -a "$UzSS" ] then echo "$appAndCase: ** Solution singularity **" - err=1 + return 1 elif [ "$completed" ] then completionTime=`tail -10 $log | grep Execution | cut -d= -f2 | sed 's/^[ \t]*//'` @@ -66,12 +64,34 @@ logReport() completionTime="in $completionTime" fi echo "$appAndCase: completed $completionTime" + return 0 else echo "$appAndCase: unconfirmed completion" - err=1 + return 1 fi +} - return $err + +# logReportDir +# Extracts useful info from all log files in a directory +logReportDir() +{ + [ -d $1 ] || return 0 + + cd $1 || return 1 + + logs=`find . -name "log.*"` + [ -n "$logs" ] || return 0 + + retVal=0 + + for log in `echo $logs | xargs ls -rt` + do + logReport $log >> ../testLoopReport || retVal=1 + done + echo "" >> ../testLoopReport + + return $retVal } @@ -80,33 +100,17 @@ foamRunTutorials -test -skipFirst # Analyse all log files -rm testLoopReport > /dev/null 2>&1 & -touch testLoopReport -runErr=0 +rm -f testLoopReport && touch testLoopReport + +retVal=0 for appDir in * do - appDirErr=$( - logErr=0 - [ -d $appDir ] && cd $appDir || exit - - logs=`find . -name "log.*"` - [ -n "$logs" ] || exit - - for log in `echo $logs | xargs ls -rt` - do - logReport $log >> ../testLoopReport - [ $? -gt 0 ] && logErr=$((logErr+1)) - done - echo "" >> ../testLoopReport - echo $logErr - ) - - [ -n "$appDirErr" ] && [ $appDirErr -gt 0 ] && runErr=1 + logReportDir $appDir || retVal=1 done find . -name "log.*" -exec cat {} \; >> logs -exit $runErr +exit $retVal #------------------------------------------------------------------------------ diff --git a/tutorials/Alltest b/tutorials/Alltest index 374a8cfe25..b0b30767a7 100755 --- a/tutorials/Alltest +++ b/tutorials/Alltest @@ -164,7 +164,7 @@ then fi # Clean up on termination and on Ctrl-C -trap 'mv ${MAIN_CONTROL_DICT}.orig ${MAIN_CONTROL_DICT} 2>/dev/null; exit $runErr' \ +trap 'mv ${MAIN_CONTROL_DICT}.orig ${MAIN_CONTROL_DICT} 2>/dev/null; exit $retVal' \ EXIT TERM INT cp ${MAIN_CONTROL_DICT} ${MAIN_CONTROL_DICT}.orig @@ -204,9 +204,8 @@ then done fi -#cp -f $FOAM_TUTORIALS/Allrun . -./Allrun -[ $? -gt 0 ] && runErr=1 || runErr=0 +cp -f $FOAM_TUTORIALS/Allrun . +./Allrun || retVal=1 sed -e :a -e '/\\$/N; s/\\\n//; ta' Allrun > temp APPLICATIONS=\ @@ -238,7 +237,6 @@ do echo "" >> $SOLVERS_FILE done -echo $runErr +exit $retVal -exit $runErr #------------------------------------------------------------------------------