Changeset 13198
- Timestamp:
- 08/30/12 15:42:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/scripts/report.sh
r13197 r13198 2 2 #generate html report from info.log output file 3 3 4 #----------------------------# 5 # Initialize local variables # 6 #----------------------------# 4 #style 5 #{{{ 6 H1_STYLE='width="900px" cellpadding="20"' 7 H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:30px;" align="center"' 8 H2_STYLE='width="800px" cellpadding="20"' 9 H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:25px; font-weight: bold;" align="left"' 10 TABLE_STYLE='width="700px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"' 11 TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"' 12 MATLAB_STYLE='width="9000px" rules=none' 13 MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="left"' 14 BODY_STYLE='width="700px"' 15 BODY_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;"' 16 BODY_FONTC=$(echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:center; /g") 17 BODY_FONTL=$(echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:left; /g") 18 FOOTER_STYLE='width="700px" cellpadding="10"' 19 FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"' 20 #}}} 7 21 8 22 #process info.log 23 #{{{ 24 if [ ! -f info.log ]; then 25 echo "File info.log not found!" >&2 # Error message to stderr. 26 exit 1 27 fi 9 28 TODAY=$( cat info.log | grep "today" | awk '{printf("%s %s",$2,$3);}') 10 29 USER=$( cat info.log | grep "user" | awk '{print $2}') … … 13 32 RELEASE=$( cat info.log | grep "release" | awk '{print $2}') 14 33 EL_INSTALL=$( cat info.log | grep "elapsed_install" | awk '{print $2}') 34 EL_TOTAL=$( cat info.log | grep "elapsed_total" | awk '{print $2}') 35 IS_MATLAB=$( cat info.log | grep "is_matlab" | awk '{print $2}') 36 IS_PYTHON=$( cat info.log | grep "is_python" | awk '{print $2}') 15 37 EL_MATLAB=$( cat info.log | grep "elapsed_matlab" | awk '{print $2}') 16 38 EL_PYTHON=$( cat info.log | grep "elapsed_python" | awk '{print $2}') 17 EL_TOTAL=$( cat info.log | grep "elapsed_total" | awk '{print $2}')18 39 CRASH_MATLAB=$(cat info.log | grep "matlab_crash:" | awk '{print $2}') 19 40 CRASH_PYTHON=$(cat info.log | grep "python_crash:" | awk '{print $2}') 20 21 #Process matlab_log.log22 cat matlab_log.log | egrep 'ERROR|SUCCESS|FAILURE' | grep -v "PETSC" | sed -e "s/>/\>/g" | sed -e "s/</\</g" > matlab.log23 cat matlab.log | grep -v "SUCCESS" > matlab_short.log24 cat matlab_log.log | grep "PETSC" | sed -e "s/>/\>/g" | sed -e "s/</\</g" > petscerror.log25 NUM_TOT=$(wc -l matlab.log | awk '{print $1}')26 NUM_ERR=$(cat matlab.log | grep 'ERROR' | grep -v "PETSC" | wc -l)27 NUM_SUC=$(cat matlab.log | grep 'SUCCESS' | wc -l)28 NUM_FAI=$(cat matlab.log | grep 'FAILURE' | wc -l)29 30 #style31 H1_STYLE='width="1000px" cellpadding="20"'32 H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"'33 34 H2_STYLE='width="900px" cellpadding="20"'35 H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'36 37 TABLE_STYLE='width="800px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'38 TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'39 40 MATLAB_STYLE='width="1000px" rules=none'41 MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="left"'42 43 BODY_STYLE='width="800px"'44 BODY_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;"'45 46 FOOTER_STYLE='width="800px" cellpadding="10"'47 FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'48 49 #style 250 BODY_FONTC=`echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:center; /g"`51 BODY_FONTL=`echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:left; /g"`52 41 53 42 #Did installation work? … … 57 46 IS_INSTALL=1 58 47 fi 59 60 #display table ONLY if installation worked and there has been at leat one FAILURE or ERROR 61 IS_TABLE=0 62 if [ $IS_INSTALL -eq 1 ]; then 63 if [ $NUM_TOT -gt 1 ]; then 64 if [ $NUM_SUC -ne $NUM_TOT ]; then 65 IS_TABLE=1 66 fi 67 fi 68 fi 69 70 #-------------------# 71 # build report.html # 72 #-------------------# 73 74 #first: summary 75 cat << END > summary.html 48 #}}} 49 50 #1. summary table 51 #{{{ 52 rm report.html 53 cat << END >> report.html 76 54 <div align="center"> 77 55 <table $H1_STYLE><tr><td $H1_FONT>ISSM Nightly run report</td></tr></table> … … 83 61 </tr> 84 62 <tr> 85 <td $TABLE_FONT>OS: $OS</td>86 63 <td $TABLE_FONT>user: $USER</td> 87 </tr>88 <tr>89 <td $TABLE_FONT>status: STATUS</td>90 64 <td $TABLE_FONT>release: $RELEASE</td> 91 65 </tr> 92 66 <tr> 93 <td $TABLE_FONT>number of successes: $NUM_SUC/$NUM_TOT94 67 <td $TABLE_FONT>total elapsed time: $EL_TOTAL</td> 95 </tr>96 <tr>97 <td $TABLE_FONT>number of <a href="#ERROR">errors</a>: $NUM_ERR/$NUM_TOT98 99 68 <td $TABLE_FONT>installation elapsed time: $EL_INSTALL</td> 100 69 </tr> 101 <tr> 102 <td $TABLE_FONT>number of <a href="#FAILURE">failures</a>: $NUM_FAI/$NUM_TOT 103 <td $TABLE_FONT>execution elapsed time: $EL_MATLAB</td> 104 </tr> 105 </table> 106 <br><hr width="1000px"> 107 END 108 109 #update status 110 if [ $IS_INSTALL -eq 1 ]; 70 </table> 71 <br><hr width="900px"> 72 END 73 # }}} 74 75 #stop if did not install 76 #{{{ 77 if [ $IS_INSTALL -eq 0 ]; then 78 cat << END >> report.html 79 <table $(echo $BODY_STYLE) style="border-collapse:collapse;"> 80 <tr><td $BODY_FONT>status: <span style=\"color:#ff0000\">Installation failed<\/span></td></tr> 81 </table> 82 <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> 83 </div> 84 END 85 exit 0 86 fi 87 #}}} 88 89 #2. matlab report 90 if [ $IS_MATLAB -eq 1 ]; then 91 #Process matlab_log.log {{{ 92 cat matlab_log.log | egrep 'ERROR|SUCCESS|FAILURE' | grep -v "PETSC" | sed -e "s/>/\>/g" | sed -e "s/</\</g" > matlab.log 93 cat matlab.log | grep -v "SUCCESS" > matlab_short.log 94 cat matlab_log.log | grep "PETSC" | sed -e "s/>/\>/g" | sed -e "s/</\</g" > petscerror.log 95 NUM_MATLAB_TOT=$(wc -l matlab.log | awk '{print $1}') 96 NUM_MATLAB_ERR=$(cat matlab.log | grep 'ERROR' | grep -v "PETSC" | wc -l) 97 NUM_MATLAB_SUC=$(cat matlab.log | grep 'SUCCESS' | wc -l) 98 NUM_MATLAB_FAI=$(cat matlab.log | grep 'FAILURE' | wc -l) 99 #}}} 100 #write report {{{ 101 cat << END >> report.html 102 <table $H2_STYLE><tr><td $H2_FONT>Matlab tests</td></tr></table> 103 <table $(echo $BODY_STYLE) style="border-collapse:collapse;"> 104 $(if [ $CRASH_MATLAB -eq 0 ]; then 105 echo "<tr><td $BODY_FONT>status: <span style=\"color:#008000\">all test desks have been run</span></td></tr>" 106 else 107 echo "<tr><td $BODY_FONT>status: <span style=\"color:#ff0000\">Matlab crashed</span></td></tr>" 108 fi) 109 <tr><td $BODY_FONT>Total execution time: $EL_PYTHON</td></tr> 110 <tr><td $BODY_FONT>Number of successes: $NUM_MATLAB_SUC/$NUM_MATLAB_TOT</td></tr> 111 <tr><td $BODY_FONT>Number of errors: $NUM_MATLAB_ERR/$NUM_MATLAB_TOT</td></tr> 112 <tr><td $BODY_FONT>Number of failures: $NUM_MATLAB_FAI/$NUM_MATLAB_TOT</td></tr> 113 </table> 114 END 115 #}}} 116 fi 117 118 #2. python report 119 if [ $IS_PYTHON -eq 1 ]; then 120 #Process python_log.log {{{ 121 cat python_log.log | egrep 'ERROR|SUCCESS|FAILURE' | grep -v "PETSC" | sed -e "s/>/\>/g" | sed -e "s/</\</g" > python.log 122 cat python.log | grep -v "SUCCESS" > python_short.log 123 cat python_log.log | grep "PETSC" | sed -e "s/>/\>/g" | sed -e "s/</\</g" > petscerror.log 124 NUM_PYTHON_TOT=$(wc -l python.log | awk '{print $1}') 125 NUM_PYTHON_ERR=$(cat python.log | grep 'ERROR' | grep -v "PETSC" | wc -l) 126 NUM_PYTHON_SUC=$(cat python.log | grep 'SUCCESS' | wc -l) 127 NUM_PYTHON_FAI=$(cat python.log | grep 'FAILURE' | wc -l) 128 #}}} 129 #write report {{{ 130 cat << END >> report.html 131 <table $H2_STYLE><tr><td $H2_FONT>Python tests</td></tr></table> 132 <table $(echo $BODY_STYLE) style="border-collapse:collapse;"> 133 $(if [ $CRASH_PYTHON -eq 0 ]; then 134 echo "<tr><td $BODY_FONT>status: <span style=\"color:#008000\">all test desks have been run</span></td></tr>" 135 else 136 echo "<tr><td $BODY_FONT>status: <span style=\"color:#ff0000\">Python crashed</span></td></tr>" 137 fi) 138 <tr><td $BODY_FONT>Total execution time: $EL_PYTHON</td></tr> 139 <tr><td $BODY_FONT>Number of successes: $NUM_PYTHON_SUC/$NUM_PYTHON_TOT</td></tr> 140 <tr><td $BODY_FONT>Number of errors: $NUM_PYTHON_ERR/$NUM_PYTHON_TOT</td></tr> 141 <tr><td $BODY_FONT>Number of failures: $NUM_PYTHON_FAI/$NUM_PYTHON_TOT</td></tr> 142 </table> 143 END 144 #}}} 145 fi 146 147 #3. Matlab and python tables 148 if [ $IS_MATLAB -eq 1 ]; then 149 #Matlab{{{ 150 #display table ONLY if installation worked and there has been at leat one FAILURE or ERROR 151 if [ $IS_INSTALL -eq 1 ] && [ $NUM_MATLAB_TOT -gt 1 ] && [ $NUM_MATLAB_SUC -ne $NUM_MATLAB_TOT ] 111 152 then 112 if [ $CRASH_MATLAB -eq 0 ]; 113 then 114 cat summary.html | sed -e "s/STATUS/<span style=\"color:#008000\">all test desks have been run<\/span>/g" > summary2.html 115 else 116 cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation successful but Matlab crashed<\/span>/g" > summary2.html 117 fi 118 else 119 cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation failed<\/span>/g" > summary2.html 120 fi 121 mv summary2.html summary.html 122 123 #report table 124 if [ $IS_TABLE -eq 1 ]; 125 then 126 cat << END > content.html 127 <table $(echo $H2_STYLE)><tr><td $(echo $H2_FONT)>List of tests</td></tr></table> 153 cat << END >> report.html 154 <table $(echo $H2_STYLE)><tr><td $(echo $H2_FONT)>List of Matlab tests</td></tr></table> 128 155 <table $(echo $BODY_STYLE) style="border-collapse:collapse;"> 129 156 <tr> … … 175 202 <br> 176 203 END 177 else 178 mktemp content.html 179 fi 180 181 #Matlab error report 182 if [ -e matlaberror.log ] 204 fi 205 #}}} 206 fi 207 if [ $IS_PYTHON -eq 1 ]; then 208 #python{{{ 209 #display table ONLY if installation worked and there has been at leat one FAILURE or ERROR 210 if [ $IS_INSTALL -eq 1 ] && [ $NUM_PYTHON_TOT -gt 1 ] && [ $NUM_PYTHON_SUC -ne $NUM_PYTHON_TOT ] 183 211 then 184 cat << END > matlaberror.html 212 cat << END >> report.html 213 <table $(echo $H2_STYLE)><tr><td $(echo $H2_FONT)>List of Python tests</td></tr></table> 214 <table $(echo $BODY_STYLE) style="border-collapse:collapse;"> 215 <tr> 216 <th $(echo $BODY_FONT)>Result</th> 217 <th $(echo $BODY_FONT)>Tolerance</th> 218 <th $(echo $BODY_FONT)>Test id</th> 219 <th $(echo $BODY_FONT)>Test name</th> 220 <th $(echo $BODY_FONT)>Field checked</th> 221 </tr> 222 $(cat matlab_short.log | while read line 223 do 224 echo "<tr>" 225 226 #get status 227 STATUS=`echo $line | awk '{print $1}'` 228 229 #FAILURE 230 if [ "$STATUS" = "FAILURE" ] 231 then 232 233 FONTC=$(echo "$BODY_FONTC bgcolor=#ffff00"); 234 FONTL=$(echo "$BODY_FONTL bgcolor=#ffff00"); 235 echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" ' 236 { printf("<td %s id=FAILURE>%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);} 237 '; 238 239 else 240 241 #SUCCESS 242 if [ "$STATUS" = "SUCCESS" ] 243 then 244 FONTC=$(echo "$BODY_FONTC bgcolor=#ddffdd") 245 FONTL=$(echo "$BODY_FONTL bgcolor=#ddffdd") 246 #do not write anything 247 #ERROR 248 else 249 FONTC=$(echo "$BODY_FONTC bgcolor=#ffdddd id=ERROR") 250 FONTL=$(echo "$BODY_FONTL bgcolor=#ffdddd") 251 echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" ' 252 { 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);} 253 '; 254 fi 255 256 fi 257 echo "</tr>" 258 done 259 ) 260 </table> 261 <br> 262 END 263 fi 264 #}}} 265 fi 266 267 #4. Error report 268 if [ $IS_MATLAB -eq 1 ]; then 269 #Matlab {{{ 270 cat << END >> report.html 185 271 <table $H2_STYLE><tr><td $H2_FONT>Matlab errors</td></tr></table> 186 272 <table $MATLAB_STYLE><tr><td $MATLAB_FONT> … … 194 280 </td></tr></table> 195 281 END 196 else 197 mktemp matlaberror.html 198 fi 199 200 #Matlab error report 282 #}}} 283 fi 201 284 if test -s petscerror.log 202 285 then 203 cat << END > petscerror.html 286 #PETSc{{{ 287 cat << END >> report.html 204 288 <table $H2_STYLE><tr><td $H2_FONT>PETSc errors</td></tr></table> 205 289 <table $MATLAB_STYLE><tr><td $MATLAB_FONT> … … 213 297 </td></tr></table> 214 298 END 215 else 216 mktemp petscerror.html 217 fi 218 219 # last footer220 cat << END > footer.html299 #}}} 300 fi 301 302 #last: footer 303 #{{{ 304 cat << END >> report.html 221 305 <br> 222 306 <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> 223 307 </div> 224 308 END 225 226 #concatenate files 227 cat summary.html content.html matlaberror.html petscerror.html footer.html > report.html 228 rm summary.html content.html footer.html matlaberror.html petscerror.html matlab.log 309 #}}}
Note:
See TracChangeset
for help on using the changeset viewer.