#!/bin/bash #generate html report from nightly.log output file #Process log cat nightly.log | grep 'ERROR' | grep -v "PETSC ERROR" > errors.log cat nightly.log | grep 'SUCCESS' > success.log cat nightly.log | grep 'FAILURE' > failures.log #create some variables if [ $(ls -1 $ISSM_DIR/bin | wc -l) -le 20 ]; then IS_INSTALL=0 else IS_INSTALL=1 fi if [ $(wc -l nightly.log | awk '{printf("%s",$1);}') -eq 0 ] then IS_RUN=0 else IS_RUN=1 fi #style H1_STYLE='width="800px" cellpadding="20"' H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"' H2_STYLE='width="840px" cellpadding="20"' H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"' TABLE_STYLE='width="820px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"' TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14; font-weight: normal;" align="left"' MATLAB_STYLE='width="820px" rules=none' MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"' BODY_STYLE='width="820px"' BODY_FONT="style=\"color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;\"" NOTEST_STYLE='width="650px"' NOTEST_FONT='style="color:#FF0000; font-family:Arial, Verdana, Tahoma; font-size:14px;" align="left"' FOOTER_STYLE='width="800px" cellpadding="10"' FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"' #build report.html #first: summary cat << END > summary.html
ISSM Nightly run report
$(#print status if [ $(echo $IS_INSTALL) -eq 0 ]; then #installation failed, end of report echo "" echo "" echo "" echo "
host: $HOST_NAME date: $TODAY
user: $(whoami) total elapsed time: $ELAPSED_TOTAL
OS: $OS installation elapsed time: $ELAPSED_INSTAL
status: installation failedexecution elapsed time: $ELAPSED_RUN
" rm errors.log success.log else #installation successful. Did we go to the end? if [ $(echo $IS_RUN) -eq 0 ]; then #run failed, end of report echo "status: installation successful but tests runs failed" echo "execution elapsed time: $ELAPSED_RUN" echo "" echo "" rm errors.log success.log failures.log else echo "status: all test desks have been run" echo "execution elapsed time: $ELAPSED_RUN" echo "" echo "" echo "number of errors: $(wc -l errors.log | awk '{printf("%s",$1);}')/$(wc -l nightly.log | awk '{printf("%s",$1);}'; rm errors.log)" echo " " echo "" echo "" echo "number of success: $(wc -l success.log | awk '{printf("%s",$1);}')/$(wc -l nightly.log | awk '{printf("%s",$1);}'; rm success.log)" echo " " echo "" echo "" #draw a line and clean up echo "

" fi fi) END #Matlab error report cat << END > matlaberror.html
Matlab error
$(more matlaberror.log)
END #report content if [ $(echo $IS_INSTALL) = 1 ]; then cat << END > content.html
List of tests
$( COUNTER=0 MAX=`wc -l nightly.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) RESULT="$(cat nightly.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$COUNTER'o/ {printf("%s\n",$2);}';)" if [ "$RESULT" = "SUCCESS" ]; then color="bgcolor=#ddffdd"; else if [ "$RESULT" = "ERROR" ]; then color="bgcolor=#ffdddd"; else color="bgcolor=#ddddff"; fi fi FONT=$(echo "$BODY_FONT $color") #build html corresponding line cat nightly.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk -v FONT="$FONT" ' /line'$COUNTER'o/ { printf("",FONT,$2,FONT,$4,$5,$6,FONT,$8,FONT,$10,FONT,$12,FONT,$14,FONT,$16,FONT,$18,FONT,$20);} '; echo "" done)
Result Tolerance Test name Analysis type Sub type Qmu control Control fit Parallel
%s%s%s%s%s%s%s%s%s%s%s

END else mktemp content.html fi #last footer cat << END > footer.html
ISSM nightly run report
END #concatenate files if [ $IS_RUN -eq 0 ]; then cat summary.html matlaberror.html content.html footer.html > report.html else cat summary.html content.html footer.html > report.html fi rm summary.html content.html footer.html matlaberror.html