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

View File

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