[5082] | 1 | #!/bin/bash
|
---|
| 2 | #generate html report from info.log output file
|
---|
| 3 |
|
---|
| 4 | #----------------------------#
|
---|
| 5 | # Initialize local variables #
|
---|
| 6 | #----------------------------#
|
---|
| 7 |
|
---|
| 8 | #process info.log
|
---|
| 9 | TODAY=` cat info.log | grep "today" | awk '{printf("%s %s",$2,$3);}'`
|
---|
| 10 | USER=` cat info.log | grep "user" | awk '{print $2}'`
|
---|
| 11 | HOST_NAME=` cat info.log | grep "host" | awk '{print $2}'`
|
---|
| 12 | OS=` cat info.log | grep "OS" | awk '{print $2}'`
|
---|
| 13 | RELEASE=` cat info.log | grep "release" | awk '{print $2}'`
|
---|
| 14 | EL_INSTALL=`cat info.log | grep "elapsed_install" | awk '{print $2}'`
|
---|
| 15 | EL_RUN=` cat info.log | grep "elapsed_run" | awk '{print $2}'`
|
---|
| 16 | EL_TOTAL=` cat info.log | grep "elapsed_total" | awk '{print $2}'`
|
---|
[5591] | 17 | CRASH=` cat info.log | grep "matlab_crash:" | awk '{print $2}'`
|
---|
[5082] | 18 |
|
---|
| 19 | #Process matlab_log.log
|
---|
[8810] | 20 | cat matlab_log.log | egrep 'ERROR|SUCCESS|FAILURE' | grep -v "PETSC" | sed -e "s/>/\>/g" | sed -e "s/</\</g" > matlab.log
|
---|
[12878] | 21 | cat matlab.log | grep -v "SUCCESS" > matlab_short.log
|
---|
[8811] | 22 | cat matlab_log.log | grep "PETSC" | sed -e "s/>/\>/g" | sed -e "s/</\</g" > petscerror.log
|
---|
[5082] | 23 | NUM_TOT=`wc -l matlab.log | awk '{print $1}'`
|
---|
[8721] | 24 | NUM_ERR=`cat matlab.log | grep 'ERROR' | grep -v "PETSC" | wc -l`
|
---|
[5082] | 25 | NUM_SUC=`cat matlab.log | grep 'SUCCESS' | wc -l`
|
---|
| 26 | NUM_FAI=`cat matlab.log | grep 'FAILURE' | wc -l`
|
---|
| 27 |
|
---|
| 28 | #style
|
---|
| 29 | H1_STYLE='width="1000px" cellpadding="20"'
|
---|
| 30 | H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"'
|
---|
| 31 |
|
---|
| 32 | H2_STYLE='width="900px" cellpadding="20"'
|
---|
| 33 | H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'
|
---|
| 34 |
|
---|
| 35 | TABLE_STYLE='width="800px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'
|
---|
[12004] | 36 | TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'
|
---|
[5082] | 37 |
|
---|
| 38 | MATLAB_STYLE='width="1000px" rules=none'
|
---|
[9382] | 39 | MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="left"'
|
---|
[5082] | 40 |
|
---|
| 41 | BODY_STYLE='width="800px"'
|
---|
| 42 | BODY_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;"'
|
---|
| 43 |
|
---|
| 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"'
|
---|
| 46 |
|
---|
| 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 |
|
---|
[12878] | 51 | #Did installation work?
|
---|
| 52 | if [ $(ls -1 $ISSM_DIR/bin | wc -l) -le 20 ]; then
|
---|
[5082] | 53 | IS_INSTALL=0
|
---|
| 54 | else
|
---|
| 55 | IS_INSTALL=1
|
---|
| 56 | fi
|
---|
| 57 |
|
---|
[12878] | 58 | #display table ONLY if installation worked and there has been at leat one FAILURE or ERROR
|
---|
| 59 | IS_TABLE=0
|
---|
| 60 | if [ $IS_INSTALL -eq 1 ]; then
|
---|
| 61 | if [ $NUM_TOT -gt 1 ]; then
|
---|
| 62 | if [ $NUM_SUC -ne $NUM_TOT ]; then
|
---|
| 63 | IS_TABLE=1
|
---|
| 64 | fi
|
---|
| 65 | fi
|
---|
| 66 | fi
|
---|
| 67 |
|
---|
[5082] | 68 | #-------------------#
|
---|
| 69 | # build report.html #
|
---|
| 70 | #-------------------#
|
---|
| 71 |
|
---|
| 72 | #first: summary
|
---|
| 73 | cat << END > summary.html
|
---|
| 74 | <div align="center">
|
---|
| 75 | <table $H1_STYLE><tr><td $H1_FONT>ISSM Nightly run report</td></tr></table>
|
---|
| 76 |
|
---|
| 77 | <table $TABLE_STYLE>
|
---|
| 78 | <tr>
|
---|
| 79 | <td $TABLE_FONT>host: $HOST_NAME</td>
|
---|
| 80 | <td $TABLE_FONT>date: $TODAY</td>
|
---|
| 81 | </tr>
|
---|
| 82 | <tr>
|
---|
| 83 | <td $TABLE_FONT>OS: $OS</td>
|
---|
| 84 | <td $TABLE_FONT>user: $USER</td>
|
---|
| 85 | </tr>
|
---|
| 86 | <tr>
|
---|
| 87 | <td $TABLE_FONT>status: STATUS</td>
|
---|
| 88 | <td $TABLE_FONT>release: $RELEASE</td>
|
---|
| 89 | </tr>
|
---|
| 90 | <tr>
|
---|
[7712] | 91 | <td $TABLE_FONT>number of successes: $NUM_SUC/$NUM_TOT
|
---|
[5082] | 92 | <td $TABLE_FONT>total elapsed time: $EL_TOTAL</td>
|
---|
| 93 | </tr>
|
---|
| 94 | <tr>
|
---|
[8719] | 95 | <td $TABLE_FONT>number of <a href="#ERROR">errors</a>: $NUM_ERR/$NUM_TOT
|
---|
[5082] | 96 |
|
---|
| 97 | <td $TABLE_FONT>installation elapsed time: $EL_INSTALL</td>
|
---|
| 98 | </tr>
|
---|
| 99 | <tr>
|
---|
[8720] | 100 | <td $TABLE_FONT>number of <a href="#FAILURE">failures</a>: $NUM_FAI/$NUM_TOT
|
---|
[5082] | 101 | <td $TABLE_FONT>execution elapsed time: $EL_RUN</td>
|
---|
| 102 | </tr>
|
---|
| 103 | </table>
|
---|
| 104 | <br><hr width="1000px">
|
---|
| 105 | END
|
---|
| 106 |
|
---|
| 107 | #update status
|
---|
[12878] | 108 | if [ $IS_INSTALL -eq 1 ];
|
---|
[5082] | 109 | then
|
---|
[12878] | 110 | if [ $CRASH -eq 0 ];
|
---|
[5082] | 111 | then
|
---|
[5591] | 112 | cat summary.html | sed -e "s/STATUS/<span style=\"color:#008000\">all test desks have been run<\/span>/g" > summary2.html
|
---|
[5082] | 113 | else
|
---|
[5591] | 114 | cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation successful but Matlab crashed<\/span>/g" > summary2.html
|
---|
[5082] | 115 | fi
|
---|
[5591] | 116 | else
|
---|
| 117 | cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation failed<\/span>/g" > summary2.html
|
---|
[5082] | 118 | fi
|
---|
[5591] | 119 | mv summary2.html summary.html
|
---|
[5082] | 120 |
|
---|
| 121 | #report table
|
---|
[12878] | 122 | if [ $IS_TABLE -eq 1 ];
|
---|
[5082] | 123 | then
|
---|
| 124 | cat << END > content.html
|
---|
| 125 | <table $(echo $H2_STYLE)><tr><td $(echo $H2_FONT)>List of tests</td></tr></table>
|
---|
| 126 | <table $(echo $BODY_STYLE) style="border-collapse:collapse;">
|
---|
| 127 | <tr>
|
---|
| 128 | <th $(echo $BODY_FONT)>Result</th>
|
---|
| 129 | <th $(echo $BODY_FONT)>Tolerance</th>
|
---|
| 130 | <th $(echo $BODY_FONT)>Test id</th>
|
---|
| 131 | <th $(echo $BODY_FONT)>Test name</th>
|
---|
| 132 | <th $(echo $BODY_FONT)>Field checked</th>
|
---|
| 133 | </tr>
|
---|
[12878] | 134 | $(cat matlab_short.log | while read line
|
---|
[5082] | 135 | do
|
---|
| 136 | echo "<tr>"
|
---|
| 137 |
|
---|
| 138 | #get status
|
---|
| 139 | STATUS=`echo $line | awk '{print $1}'`
|
---|
| 140 |
|
---|
| 141 | #FAILURE
|
---|
| 142 | if [ "$STATUS" = "FAILURE" ]
|
---|
| 143 | then
|
---|
| 144 |
|
---|
| 145 | FONTC=$(echo "$BODY_FONTC bgcolor=#ffff00");
|
---|
| 146 | FONTL=$(echo "$BODY_FONTL bgcolor=#ffff00");
|
---|
| 147 | echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
|
---|
[8719] | 148 | { 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);}
|
---|
[12878] | 149 | ';
|
---|
[5082] | 150 |
|
---|
[12878] | 151 | else
|
---|
[5082] | 152 |
|
---|
| 153 | #SUCCESS
|
---|
| 154 | if [ "$STATUS" = "SUCCESS" ]
|
---|
| 155 | then
|
---|
[8719] | 156 | FONTC=$(echo "$BODY_FONTC bgcolor=#ddffdd")
|
---|
| 157 | FONTL=$(echo "$BODY_FONTL bgcolor=#ddffdd")
|
---|
[12878] | 158 | #do not write anything
|
---|
[5082] | 159 | #ERROR
|
---|
| 160 | else
|
---|
[8719] | 161 | FONTC=$(echo "$BODY_FONTC bgcolor=#ffdddd id=ERROR")
|
---|
| 162 | FONTL=$(echo "$BODY_FONTL bgcolor=#ffdddd")
|
---|
[12878] | 163 | echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
|
---|
| 164 | { 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);}
|
---|
| 165 | ';
|
---|
[5082] | 166 | fi
|
---|
| 167 |
|
---|
| 168 | fi
|
---|
| 169 | echo "</tr>"
|
---|
| 170 | done
|
---|
| 171 | )
|
---|
| 172 | </table>
|
---|
| 173 | <br>
|
---|
| 174 | END
|
---|
| 175 | else
|
---|
| 176 | mktemp content.html
|
---|
| 177 | fi
|
---|
| 178 |
|
---|
| 179 | #Matlab error report
|
---|
| 180 | if [ -e matlaberror.log ]
|
---|
| 181 | then
|
---|
| 182 | cat << END > matlaberror.html
|
---|
[8811] | 183 | <table $H2_STYLE><tr><td $H2_FONT>Matlab errors</td></tr></table>
|
---|
[5082] | 184 | <table $MATLAB_STYLE><tr><td $MATLAB_FONT>
|
---|
[9382] | 185 | <pre style="
|
---|
| 186 | white-space: -moz-pre-wrap;
|
---|
| 187 | white-space: -pre-wrap;
|
---|
| 188 | white-space: -o-pre-wrap;
|
---|
| 189 | white-space: pre-wrap;
|
---|
| 190 | word-wrap: break-word;
|
---|
| 191 | ">$(cat matlaberror.log)</pre>
|
---|
[5082] | 192 | </td></tr></table>
|
---|
| 193 | END
|
---|
| 194 | else
|
---|
| 195 | mktemp matlaberror.html
|
---|
| 196 | fi
|
---|
| 197 |
|
---|
[8811] | 198 | #Matlab error report
|
---|
| 199 | if test -s petscerror.log
|
---|
| 200 | then
|
---|
| 201 | cat << END > petscerror.html
|
---|
| 202 | <table $H2_STYLE><tr><td $H2_FONT>PETSc errors</td></tr></table>
|
---|
| 203 | <table $MATLAB_STYLE><tr><td $MATLAB_FONT>
|
---|
[9382] | 204 | <pre style="
|
---|
| 205 | white-space: -moz-pre-wrap;
|
---|
| 206 | white-space: -pre-wrap;
|
---|
| 207 | white-space: -o-pre-wrap;
|
---|
| 208 | white-space: pre-wrap;
|
---|
| 209 | word-wrap: break-word;
|
---|
| 210 | ">$(cat petscerror.log)</pre>
|
---|
[8811] | 211 | </td></tr></table>
|
---|
| 212 | END
|
---|
| 213 | else
|
---|
| 214 | mktemp petscerror.html
|
---|
| 215 | fi
|
---|
| 216 |
|
---|
[5082] | 217 | #last footer
|
---|
| 218 | cat << END > footer.html
|
---|
| 219 | <br>
|
---|
| 220 | <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>
|
---|
| 221 | </div>
|
---|
| 222 | END
|
---|
| 223 |
|
---|
| 224 | #concatenate files
|
---|
[8811] | 225 | cat summary.html content.html matlaberror.html petscerror.html footer.html > report.html
|
---|
| 226 | rm summary.html content.html footer.html matlaberror.html petscerror.html matlab.log
|
---|