Skip to content
Snippets Groups Projects
Commit ff2a3353 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: add tutorials/Allrun -collect option

- collects the log information only, without running any cases.
  This can be useful if the user has terminated the test prematurely
  but nonetheless wishes to summarize the log output.
parent 26cd9ae1
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,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-2016 OpenFOAM Foundation
# \\/ M anipulation | # \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM. # This file is part of OpenFOAM.
...@@ -26,71 +26,135 @@ ...@@ -26,71 +26,135 @@
# Allrun # Allrun
# #
# Description # Description
# Runs tutorial cases and summarizes the outcome as 'testLoopReport'
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
cd ${0%/*} || exit 1 # Run from this directory cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run functions usage()
. $WM_PROJECT_DIR/bin/tools/RunFunctions {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: ${0##*/} [OPTION]
options:
-collect Collect logs only. Can be useful for aborted runs.
-help print the usage
* Runs tutorial cases and summarizes the outcome as 'testLoopReport'
USAGE
exit 1
}
#------------------------------------------------------------------------------
unset optCollectOnly
# parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-collect)
optCollectOnly=true
;;
-*)
usage "unknown option: $1"
;;
*)
break
;;
esac
shift
done
#------------------------------------------------------------------------------
# logReport <logfile> # logReport <logfile>
# Extracts useful info from log file. # Extracts useful info from log file.
logReport() logReport()
{ {
caseName=`dirname $1 | sed s/"\(.*\)\.\/"/""/g` local logfile=$1
app=`echo $1 | sed s/"\(.*\)log\."/""/g`
appAndCase="Application $app - case $caseName"
fatalError=`grep "FOAM FATAL" $1` # logfile is path/to/case/log.application
UxSS=`grep -E "Ux[:| ]*solution singularity" $1` caseName=$(dirname $logfile | sed -e 's/\(.*\)\.\///g')
UySS=`grep -E "Uy[:| ]*solution singularity" $1` app=$(echo $logfile | sed -e 's/\(.*\)log\.//g')
UzSS=`grep -E "Uz[:| ]*solution singularity" $1` appAndCase="Application $app - case $caseName"
completed=`grep -E "^[\t ]*[eE]nd" $1`
if [ "$fatalError" ] if grep -q "FOAM FATAL" $logfile
then then
echo "$appAndCase: ** FOAM FATAL ERROR **" echo "$appAndCase: ** FOAM FATAL ERROR **"
elif [ "$UxSS" -a "$UySS" -a "$UzSS" ] return 1
then fi
echo "$appAndCase: ** Solution singularity **"
elif [ "$completed" ] # Check for solution singularity on U equation
then for eqn in Ux Uy Uz
completionTime=`tail -10 $log | grep Execution | cut -d= -f2 | sed 's/^[ \t]*//'` do
if [ "$completionTime" ] if grep -q -E "${eqn}[:| ]*solution singularity" $logfile
then then
completionTime="in $completionTime" if [ "$eqn" = Uz ]
then
# Can only get here if Ux,Uy,Uz all failed
echo "$appAndCase: ** Solution singularity **"
return 1
fi
else
break
fi fi
echo "$appAndCase: completed $completionTime" done
if grep -q -E "^[\t ]*[Ee]nd" $logfile
then
# Extract time from this type of content
## ExecutionTime = 60.2 s ClockTime = 63 s --> "60.2 s"
completionTime=$(tail -10 $logfile | \
sed -n -e '/Execution/{s/^[^=]*=[ \t]*//; s/\( s\) .*$/\1/; p}')
echo "$appAndCase: completed${completionTime:+ in }$completionTime"
else else
echo "$appAndCase: unconfirmed completion" echo "$appAndCase: unconfirmed completion"
fi fi
} }
if [ -z "$optCollectOnly" ]
# Recursively run all tutorials then
foamRunTutorials -test -skipFirst # Recursively run all tutorials
foamRunTutorials -test -skipFirst
fi
# Analyse all log files # Analyse all log files
rm testLoopReport > /dev/null 2>&1 & echo "Collecting log files..." 1>&2
touch testLoopReport rm -f logs testLoopReport > /dev/null 2>&1
touch logs testLoopReport
for appDir in * for appDir in *
do do
( [ -d $appDir ] || continue
[ -d $appDir ] && cd $appDir || exit echo -n " $appDir..." 1>&2
logs=`find . -name "log.*"` logs=$(find -L $appDir -type f -name 'log.*')
[ -n "$logs" ] || exit if [ -n "$logs" ]
then
echo 1>&2
else
echo " (no logs)" 1>&2
continue
fi
for log in `echo $logs | xargs ls -rt` # Sort logs by time-stamp
for log in $(echo $logs | xargs ls -rt)
do do
logReport $log >> ../testLoopReport # Concatenate and summarize logs
cat "$log" >> logs 2>/dev/null
logReport $log
done done
echo "" >> ../testLoopReport echo
) done > testLoopReport
done
find . -name "log.*" -exec cat {} \; >> logs
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment