[882] | 1 | #!/bin/bash
|
---|
| 2 | #generate html report from nightly.log output file
|
---|
| 3 |
|
---|
[3132] | 4 | #First go to the nightly run directory (created by nightlyrun.sh)
|
---|
[5068] | 5 | cd $ISSM_DIR/nightlylog/
|
---|
[882] | 6 |
|
---|
[3132] | 7 | #----------------------------#
|
---|
| 8 | # Initialize local variables #
|
---|
| 9 | #----------------------------#
|
---|
| 10 |
|
---|
[2185] | 11 | #process nightly.log
|
---|
| 12 | TODAY=` cat nightly.log | grep "today" | awk '{printf("%s %s",$2,$3);}'`
|
---|
| 13 | USER=` cat nightly.log | grep "user" | awk '{print $2}'`
|
---|
| 14 | HOST_NAME=` cat nightly.log | grep "host" | awk '{print $2}'`
|
---|
| 15 | OS=` cat nightly.log | grep "OS" | awk '{print $2}'`
|
---|
| 16 | RELEASE=` cat nightly.log | grep "release" | awk '{print $2}'`
|
---|
| 17 | EL_INSTALL=`cat nightly.log | grep "elapsed_install" | awk '{print $2}'`
|
---|
| 18 | EL_RUN=` cat nightly.log | grep "elapsed_run" | awk '{print $2}'`
|
---|
| 19 | EL_TOTAL=` cat nightly.log | grep "elapsed_total" | awk '{print $2}'`
|
---|
[1568] | 20 |
|
---|
[2185] | 21 | #Process matlab_log.log
|
---|
[4679] | 22 | cat matlab_log.log | egrep 'ERROR|SUCCESS|FAILURE' | sed -e "s/>/\>/g" | sed -e "s/</\</g" > matlab.log
|
---|
[2185] | 23 | NUM_TOT=`wc -l matlab.log | awk '{print $1}'`
|
---|
| 24 | NUM_ERR=`cat matlab.log | grep 'ERROR' | grep -v "PETSC ERROR" | wc -l`
|
---|
| 25 | NUM_SUC=`cat matlab.log | grep 'SUCCESS' | wc -l`
|
---|
| 26 | NUM_FAI=`cat matlab.log | grep 'FAILURE' | wc -l`
|
---|
| 27 |
|
---|
[1605] | 28 | #style
|
---|
[2185] | 29 | H1_STYLE='width="1000px" cellpadding="20"'
|
---|
[1605] | 30 | H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"'
|
---|
[1568] | 31 |
|
---|
[2185] | 32 | H2_STYLE='width="900px" cellpadding="20"'
|
---|
[1605] | 33 | H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'
|
---|
[1074] | 34 |
|
---|
[2185] | 35 | TABLE_STYLE='width="800px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'
|
---|
[1605] | 36 | TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14; font-weight: normal;" align="left"'
|
---|
[882] | 37 |
|
---|
[2185] | 38 | MATLAB_STYLE='width="1000px" rules=none'
|
---|
[1857] | 39 | MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'
|
---|
| 40 |
|
---|
[5068] | 41 | BODY_STYLE='width="800px"'
|
---|
| 42 | BODY_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;"'
|
---|
[882] | 43 |
|
---|
[1605] | 44 | FOOTER_STYLE='width="800px" cellpadding="10"'
|
---|
| 45 | FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'
|
---|
[1574] | 46 |
|
---|
[2185] | 47 | #style 2
|
---|
| 48 | BODY_FONTC=`echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:center; /g"`
|
---|
| 49 | BODY_FONTL=`echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:left; /g"`
|
---|
| 50 |
|
---|
| 51 | #create some variables
|
---|
| 52 | if [ $(ls -1 $ISSM_DIR/bin | wc -l) -le 20 ];
|
---|
| 53 | then
|
---|
| 54 | IS_INSTALL=0
|
---|
| 55 | else
|
---|
| 56 | IS_INSTALL=1
|
---|
| 57 | fi
|
---|
| 58 | if [ $(wc -l matlab.log | awk '{printf("%s",$1);}') -eq 0 ]
|
---|
| 59 | then
|
---|
| 60 | IS_RUN=0
|
---|
| 61 | else
|
---|
| 62 | IS_RUN=1
|
---|
| 63 | fi
|
---|
| 64 |
|
---|
[3132] | 65 | #-------------------#
|
---|
| 66 | # build report.html #
|
---|
| 67 | #-------------------#
|
---|
[1605] | 68 |
|
---|
| 69 | #first: summary
|
---|
[1574] | 70 | cat << END > summary.html
|
---|
[1605] | 71 | <div align="center">
|
---|
| 72 | <table $H1_STYLE><tr><td $H1_FONT>ISSM Nightly run report</td></tr></table>
|
---|
| 73 |
|
---|
| 74 | <table $TABLE_STYLE>
|
---|
| 75 | <tr>
|
---|
| 76 | <td $TABLE_FONT>host: $HOST_NAME</td>
|
---|
| 77 | <td $TABLE_FONT>date: $TODAY</td>
|
---|
| 78 | </tr>
|
---|
| 79 | <tr>
|
---|
[2185] | 80 | <td $TABLE_FONT>OS: $OS</td>
|
---|
| 81 | <td $TABLE_FONT>user: $USER</td>
|
---|
[1605] | 82 | </tr>
|
---|
| 83 | <tr>
|
---|
[2185] | 84 | <td $TABLE_FONT>status: STATUS</td>
|
---|
| 85 | <td $TABLE_FONT>release: $RELEASE</td>
|
---|
[1605] | 86 | </tr>
|
---|
| 87 | <tr>
|
---|
[2185] | 88 | <td $TABLE_FONT>number of success: $NUM_SUC/$NUM_TOT
|
---|
| 89 | <td $TABLE_FONT>total elapsed time: $EL_TOTAL</td>
|
---|
| 90 | </tr>
|
---|
| 91 | <tr>
|
---|
| 92 | <td $TABLE_FONT>number of errors: $NUM_ERR/$NUM_TOT
|
---|
| 93 |
|
---|
| 94 | <td $TABLE_FONT>installation elapsed time: $EL_INSTALL</td>
|
---|
| 95 | </tr>
|
---|
| 96 | <tr>
|
---|
| 97 | <td $TABLE_FONT>number of failures: $NUM_FAI/$NUM_TOT
|
---|
[2194] | 98 | <td $TABLE_FONT>execution elapsed time: $EL_RUN</td>
|
---|
[2185] | 99 | </tr>
|
---|
| 100 | </table>
|
---|
| 101 | <br><hr width="1000px">
|
---|
| 102 | END
|
---|
| 103 |
|
---|
| 104 | #update status
|
---|
| 105 | if [ $IS_RUN -eq 1 ]
|
---|
[882] | 106 | then
|
---|
[2185] | 107 | cat summary.html | sed -e "s/STATUS/<span style=\"color:#008000\">all test desks have been run<\/span>/g" > summary2.html
|
---|
| 108 | mv summary2.html summary.html
|
---|
[882] | 109 | else
|
---|
[2185] | 110 | if [ $IS_INSTALL -eq 1 ]
|
---|
[1568] | 111 | then
|
---|
[2185] | 112 | cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation successful but tests runs failed<\/span>/g" > summary2.html
|
---|
| 113 | mv summary2.html summary.html
|
---|
[1568] | 114 | else
|
---|
[2185] | 115 | cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation failed<\/span>/g" > summary2.html
|
---|
| 116 | mv summary2.html summary.html
|
---|
[1568] | 117 | fi
|
---|
[2185] | 118 | fi
|
---|
[882] | 119 |
|
---|
[1605] | 120 |
|
---|
[3132] | 121 | #report table
|
---|
[2186] | 122 | if [ $IS_RUN -eq 1 ];
|
---|
[1574] | 123 | then
|
---|
| 124 | cat << END > content.html
|
---|
[2182] | 125 | <table $(echo $H2_STYLE)><tr><td $(echo $H2_FONT)>List of tests</td></tr></table>
|
---|
[4679] | 126 | <table $(echo $BODY_STYLE) style="border-collapse:collapse;">
|
---|
[2182] | 127 | <tr>
|
---|
| 128 | <th $(echo $BODY_FONT)>Result</th>
|
---|
| 129 | <th $(echo $BODY_FONT)>Tolerance</th>
|
---|
[5068] | 130 | <th $(echo $BODY_FONT)>Test id</th>
|
---|
| 131 | <th $(echo $BODY_FONT)>Test name</th>
|
---|
[2185] | 132 | <th $(echo $BODY_FONT)>Field checked</th>
|
---|
[2182] | 133 | </tr>
|
---|
[2185] | 134 | $(cat matlab.log | while read line
|
---|
| 135 | do
|
---|
| 136 | echo "<tr>"
|
---|
[882] | 137 |
|
---|
[2185] | 138 | #get status
|
---|
| 139 | STATUS=`echo $line | awk '{print $1}'`
|
---|
[882] | 140 |
|
---|
[2185] | 141 | #FAILURE
|
---|
| 142 | if [ "$STATUS" = "FAILURE" ]
|
---|
| 143 | then
|
---|
[882] | 144 |
|
---|
[2185] | 145 | FONTC=$(echo "$BODY_FONTC bgcolor=#ffff00");
|
---|
| 146 | FONTL=$(echo "$BODY_FONTL bgcolor=#ffff00");
|
---|
| 147 | echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
|
---|
[5068] | 148 | { printf("<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n\n",FONTL,$1,FONTC,$3,FONTC,$6,FONTL,$9,FONTL,$11);}
|
---|
[2185] | 149 | ';
|
---|
[882] | 150 |
|
---|
[2185] | 151 | else
|
---|
[882] | 152 |
|
---|
[2185] | 153 | #SUCCESS
|
---|
| 154 | if [ "$STATUS" = "SUCCESS" ]
|
---|
| 155 | then
|
---|
| 156 | color="bgcolor=#ddffdd";
|
---|
| 157 |
|
---|
| 158 | #ERROR
|
---|
| 159 | else
|
---|
| 160 | color="bgcolor=#ffdddd";
|
---|
| 161 | fi
|
---|
| 162 |
|
---|
| 163 | FONTC=$(echo "$BODY_FONTC $color")
|
---|
| 164 | FONTL=$(echo "$BODY_FONTL $color")
|
---|
| 165 | echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
|
---|
[5068] | 166 | { printf("<td %s>%s</td>\n<td %s>%s%s%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n\n",FONTL,$1,FONTL,$3,$4,$5,FONTC,$8,FONTL,$11,FONTL,$13);}
|
---|
[2185] | 167 | ';
|
---|
| 168 | fi
|
---|
| 169 |
|
---|
| 170 | echo "</tr>"
|
---|
| 171 |
|
---|
| 172 | done
|
---|
| 173 | )
|
---|
[2182] | 174 | </table>
|
---|
[1574] | 175 | <br>
|
---|
| 176 | END
|
---|
| 177 | else
|
---|
[1855] | 178 | mktemp content.html
|
---|
[1574] | 179 | fi
|
---|
[882] | 180 |
|
---|
[3132] | 181 | #Matlab error report
|
---|
| 182 | if [ -e matlaberror.log ]
|
---|
| 183 | then
|
---|
[3133] | 184 | cat << END > matlaberror.html
|
---|
[3132] | 185 | <table $H2_STYLE><tr><td $H2_FONT>Matlab error</td></tr></table>
|
---|
| 186 | <table $MATLAB_STYLE><tr><td $MATLAB_FONT>
|
---|
| 187 | <pre>$(cat matlaberror.log)</pre>
|
---|
| 188 | </td></tr></table>
|
---|
| 189 | END
|
---|
| 190 | else
|
---|
| 191 | mktemp matlaberror.html
|
---|
| 192 | fi
|
---|
| 193 |
|
---|
[1574] | 194 | #last footer
|
---|
| 195 | cat << END > footer.html
|
---|
[1074] | 196 | <br>
|
---|
[1605] | 197 | <table $FOOTER_STYLE><tr><td $FOOTER_FONT><a href="http://issm.jpl.nasa.gov" title="ISSM website" target="_blank">ISSM</a> nightly run report</td></tr></table>
|
---|
| 198 | </div>
|
---|
[882] | 199 | END
|
---|
[1574] | 200 |
|
---|
| 201 | #concatenate files
|
---|
[3133] | 202 | cat summary.html content.html matlaberror.html footer.html > report.html
|
---|
[2185] | 203 | rm summary.html content.html footer.html matlaberror.html matlab.log
|
---|