#!/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
ISSM Nightly run report

END #then: summary cat << END > summary.html
date: $TODAY
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
" rm check.log errors.log success.log tests.log else if [ $(echo $IS_END) = 0 ]; then echo "stopped before the end" else echo "all test desks have been run" fi echo "
" echo "number of errors: $(wc -l errors.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}'; rm errors.log)
" echo "number of success: $(wc -l success.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}';rm success.log tests.log)" echo "
" echo "
" rm check.log fi) END #report content if [ $(echo $IS_INSTALL) = 1 ]; then cat << END > content.html $(for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do #enter title if [ $package == "macayeal" ]; then echo "
MacAyeal package
" fi if [ $package == "ice" ]; then echo "
Ice package
" fi if [ $package == "cielo_serial" ]; then echo "
Cielo Serial package
" fi if [ $package == "cielo_parallel" ]; then echo "
Cielo Parallel package
" fi #Print division echo "
" #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 "
No test found.
" else echo "" echo "" # 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("",$2,$4,$5,$6,$8,$10,$14);}'; echo "" done echo "
Result Tolerance Test Solution Field
%s %s%s%s %s %s %s
" fi #Print end division and remove log file echo "
" rm $package.log done)
END else for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do rm $package.log done fi #last footer cat << END > footer.html
ISSM nightly run report
END #concatenate files if [ $(echo $IS_INSTALL) = 1 ]; then cat header.html summary.html content.html footer.html > report.html rm header.html summary.html content.html footer.html else cat header.html summary.html footer.html > report.html rm header.html summary.html footer.html fi