tutorials: Added exit code to Allrun and Alltest scripts

Patch contributed by Institute of Fluid Dynamics, Helmholtz-Zentrum
Dresden - Rossendorf (HZDR)
This commit is contained in:
Will Bainbridge
2018-04-26 09:45:50 +01:00
parent b7d5bc98de
commit c14303bd51
2 changed files with 31 additions and 14 deletions

View File

@ -39,6 +39,7 @@ dir=${PWD##*/}
# Extracts useful info from log file. # Extracts useful info from log file.
logReport() logReport()
{ {
err=0
caseName=`dirname $1 | sed s/"\(.*\)\.\/"/""/g` caseName=`dirname $1 | sed s/"\(.*\)\.\/"/""/g`
app=`echo $1 | sed s/"\(.*\)log\."/""/g` app=`echo $1 | sed s/"\(.*\)log\."/""/g`
appAndCase="Application $app - case $caseName" appAndCase="Application $app - case $caseName"
@ -52,9 +53,11 @@ logReport()
if [ "$fatalError" ] if [ "$fatalError" ]
then then
echo "$appAndCase: ** FOAM FATAL ERROR **" echo "$appAndCase: ** FOAM FATAL ERROR **"
err=1
elif [ "$UxSS" -a "$UySS" -a "$UzSS" ] elif [ "$UxSS" -a "$UySS" -a "$UzSS" ]
then then
echo "$appAndCase: ** Solution singularity **" echo "$appAndCase: ** Solution singularity **"
err=1
elif [ "$completed" ] elif [ "$completed" ]
then then
completionTime=`tail -10 $log | grep Execution | cut -d= -f2 | sed 's/^[ \t]*//'` completionTime=`tail -10 $log | grep Execution | cut -d= -f2 | sed 's/^[ \t]*//'`
@ -65,7 +68,10 @@ logReport()
echo "$appAndCase: completed $completionTime" echo "$appAndCase: completed $completionTime"
else else
echo "$appAndCase: unconfirmed completion" echo "$appAndCase: unconfirmed completion"
err=1
fi fi
return $err
} }
@ -76,10 +82,12 @@ foamRunTutorials -test -skipFirst
# Analyse all log files # Analyse all log files
rm testLoopReport > /dev/null 2>&1 & rm testLoopReport > /dev/null 2>&1 &
touch testLoopReport touch testLoopReport
runErr=0
for appDir in * for appDir in *
do do
( appDirErr=$(
logErr=0
[ -d $appDir ] && cd $appDir || exit [ -d $appDir ] && cd $appDir || exit
logs=`find . -name "log.*"` logs=`find . -name "log.*"`
@ -88,11 +96,17 @@ do
for log in `echo $logs | xargs ls -rt` for log in `echo $logs | xargs ls -rt`
do do
logReport $log >> ../testLoopReport logReport $log >> ../testLoopReport
[ $? -gt 0 ] && logErr=$((logErr+1))
done done
echo "" >> ../testLoopReport echo "" >> ../testLoopReport
) echo $logErr
)
[ -n "$appDirErr" ] && [ $appDirErr -gt 0 ] && runErr=1
done done
find . -name "log.*" -exec cat {} \; >> logs find . -name "log.*" -exec cat {} \; >> logs
exit $runErr
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
# ========= | # ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation # \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
@ -164,7 +164,7 @@ then
fi fi
# Clean up on termination and on Ctrl-C # Clean up on termination and on Ctrl-C
trap 'mv ${MAIN_CONTROL_DICT}.orig ${MAIN_CONTROL_DICT} 2>/dev/null; exit 0' \ trap 'mv ${MAIN_CONTROL_DICT}.orig ${MAIN_CONTROL_DICT} 2>/dev/null; exit $runErr' \
EXIT TERM INT EXIT TERM INT
cp ${MAIN_CONTROL_DICT} ${MAIN_CONTROL_DICT}.orig cp ${MAIN_CONTROL_DICT} ${MAIN_CONTROL_DICT}.orig
@ -204,9 +204,9 @@ then
done done
fi fi
cp -f $FOAM_TUTORIALS/Allrun . #cp -f $FOAM_TUTORIALS/Allrun .
./Allrun ./Allrun
[ $? -gt 0 ] && runErr=1 || runErr=0
sed -e :a -e '/\\$/N; s/\\\n//; ta' Allrun > temp sed -e :a -e '/\\$/N; s/\\\n//; ta' Allrun > temp
APPLICATIONS=\ APPLICATIONS=\
@ -238,4 +238,7 @@ do
echo "" >> $SOLVERS_FILE echo "" >> $SOLVERS_FILE
done done
echo $runErr
exit $runErr
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------