#!/bin/bash
#generate html report from nightly.log output file
#Process log
cat nightly.log | grep 'package: macayeal' | grep -v "not supported yet" > macayeal.log
cat nightly.log | grep 'package: ice' | grep -v "not supported yet" > ice.log
cat nightly.log | grep 'package: cielo_serial' | grep -v "not supported yet" > cielo_serial.log
cat nightly.log | grep 'package: cielo_parallel'| grep -v "not supported yet" > cielo_parallel.log
cat nightly.log | grep NIGHTLYRUNTERMINATEDCORRECTLY > check.log
cat nightly.log | grep ERROR | grep -v "PETSC ERROR" > errors.log
cat nightly.log | grep SUCCESS > success.log
cat errors.log success.log > tests.log
#create some variables
if [ `wc -l nightly.log | awk '{printf("%s",$1);}'` = "0" ]
then
IS_INSTALL=0
else
IS_INSTALL=1
fi
if [ `wc -l check.log | awk '{printf("%s",$1);}'` = "0" ]
then
IS_END=0
else
IS_END=1
fi
#build report.html
#first: header
cat << END > header.html
"
#check that at least one Test exists
if [ `wc -l $package.log | awk '{printf("%s",$1);}'` = "0" ]; then
#No Test: use a table to fix entourage bug.
echo "
"
else
echo "
"
echo " Result | Tolerance | Test | Solution | Field |
"
# go through the lines of $package.log
COUNTER=0
MAX=`wc -l $package.log | awk '{printf("%s",$1);}'`
while [ $COUNTER -lt $MAX ]; do
let COUNTER=COUNTER+1
echo ""
#see wether it is success or error (get color: red or green)
if [ "`cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$COUNTER'o/ {printf("%s\n",$2);}';`" == "SUCCESS" ];
then
color="bgcolor=#ddffdd";
else
color="bgcolor=#ffdddd";
fi
#build html corresponding line
cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$COUNTER'o/ {printf("%s | %s%s%s | %s | %s | %s | ",$2,$4,$5,$6,$8,$10,$14);}';
echo "
"
done
echo "
"
fi
#Print end division and remove log file
echo "
"
rm $package.log
done)
host: $HOST_NAME
OS: $OS
release: $ISSM_RELEASE
total elapsed time: $ELAPSED_TOTAL
installation elapsed time: $ELAPSED_INSTAL
runs elapsed time: $ELAPSED_RUN
status: $(if [ $(echo $IS_INSTALL) = 0 ]; then #installation failed, end of report echo "installation failed