[882] | 1 | #!/bin/bash
|
---|
| 2 | #generate html report from nightly.log output file
|
---|
| 3 |
|
---|
[1568] | 4 | #Process log
|
---|
[2182] | 5 | cat nightly.log | grep 'ERROR' | grep -v "PETSC ERROR" > errors.log
|
---|
| 6 | cat nightly.log | grep 'SUCCESS' > success.log
|
---|
| 7 | cat nightly.log | grep 'FAILURE' > failures.log
|
---|
[882] | 8 |
|
---|
[1568] | 9 | #create some variables
|
---|
[1635] | 10 | if [ $(ls -1 $ISSM_DIR/bin | wc -l) -le 20 ];
|
---|
[1576] | 11 | then
|
---|
| 12 | IS_INSTALL=0
|
---|
| 13 | else
|
---|
| 14 | IS_INSTALL=1
|
---|
| 15 | fi
|
---|
[1636] | 16 | if [ $(wc -l nightly.log | awk '{printf("%s",$1);}') -eq 0 ]
|
---|
[1568] | 17 | then
|
---|
[1636] | 18 | IS_RUN=0
|
---|
| 19 | else
|
---|
| 20 | IS_RUN=1
|
---|
| 21 | fi
|
---|
[1568] | 22 |
|
---|
[1605] | 23 | #style
|
---|
| 24 | H1_STYLE='width="800px" cellpadding="20"'
|
---|
| 25 | H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"'
|
---|
[1568] | 26 |
|
---|
[1605] | 27 | H2_STYLE='width="840px" cellpadding="20"'
|
---|
| 28 | H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'
|
---|
[1074] | 29 |
|
---|
[1605] | 30 | TABLE_STYLE='width="820px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'
|
---|
| 31 | TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14; font-weight: normal;" align="left"'
|
---|
[882] | 32 |
|
---|
[1873] | 33 | MATLAB_STYLE='width="820px" rules=none'
|
---|
[1857] | 34 | MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'
|
---|
| 35 |
|
---|
[1605] | 36 | BODY_STYLE='width="820px"'
|
---|
| 37 | BODY_FONT="style=\"color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;\""
|
---|
[882] | 38 |
|
---|
[1605] | 39 | NOTEST_STYLE='width="650px"'
|
---|
| 40 | NOTEST_FONT='style="color:#FF0000; font-family:Arial, Verdana, Tahoma; font-size:14px;" align="left"'
|
---|
[1074] | 41 |
|
---|
[1605] | 42 | FOOTER_STYLE='width="800px" cellpadding="10"'
|
---|
| 43 | FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'
|
---|
[1574] | 44 |
|
---|
[1605] | 45 | #build report.html
|
---|
| 46 |
|
---|
| 47 | #first: summary
|
---|
[1574] | 48 | cat << END > summary.html
|
---|
[1605] | 49 | <div align="center">
|
---|
| 50 | <table $H1_STYLE><tr><td $H1_FONT>ISSM Nightly run report</td></tr></table>
|
---|
| 51 |
|
---|
| 52 | <table $TABLE_STYLE>
|
---|
| 53 | <tr>
|
---|
| 54 | <td $TABLE_FONT>host: $HOST_NAME</td>
|
---|
| 55 | <td $TABLE_FONT>date: $TODAY</td>
|
---|
| 56 | </tr>
|
---|
| 57 | <tr>
|
---|
[2105] | 58 | <td $TABLE_FONT>user: $(whoami)</td>
|
---|
[1605] | 59 | <td $TABLE_FONT>total elapsed time: $ELAPSED_TOTAL</td>
|
---|
| 60 | </tr>
|
---|
| 61 | <tr>
|
---|
[2105] | 62 | <td $TABLE_FONT>OS: $OS</td>
|
---|
[1605] | 63 | <td $TABLE_FONT>installation elapsed time: $ELAPSED_INSTAL</td>
|
---|
| 64 | </tr>
|
---|
| 65 | <tr>
|
---|
| 66 | $(#print status
|
---|
[2182] | 67 | if [ $(echo $IS_INSTALL) -eq 0 ];
|
---|
[882] | 68 | then
|
---|
[1568] | 69 | #installation failed, end of report
|
---|
[1605] | 70 | echo "<td $TABLE_FONT>status: <span style=\"color:#FF0000\">installation failed</span></td>"
|
---|
| 71 | echo "<td $TABLE_FONT>execution elapsed time: $ELAPSED_RUN</td>"
|
---|
| 72 | echo "</tr>"
|
---|
| 73 | echo "</table>"
|
---|
[2182] | 74 | rm errors.log success.log
|
---|
[882] | 75 | else
|
---|
[1605] | 76 | #installation successful. Did we go to the end?
|
---|
| 77 |
|
---|
[1636] | 78 | if [ $(echo $IS_RUN) -eq 0 ];
|
---|
[1568] | 79 | then
|
---|
[1636] | 80 | #run failed, end of report
|
---|
| 81 | echo "<td $TABLE_FONT>status: <span style=\"color:#FF0000\">installation successful but tests runs failed</span></td>"
|
---|
| 82 | echo "<td $TABLE_FONT>execution elapsed time: $ELAPSED_RUN</td>"
|
---|
| 83 | echo "</tr>"
|
---|
| 84 | echo "</table>"
|
---|
[2182] | 85 | rm errors.log success.log failures.log
|
---|
[1636] | 86 |
|
---|
[1568] | 87 | else
|
---|
[1636] | 88 |
|
---|
[2182] | 89 | echo "<td $TABLE_FONT>status: <span style=\"color:#008000\">all test desks have been run</span></td>"
|
---|
[1636] | 90 | echo "<td $TABLE_FONT>execution elapsed time: $ELAPSED_RUN</td>"
|
---|
| 91 | echo "</tr>"
|
---|
| 92 | echo "<tr>"
|
---|
[2182] | 93 | echo "<td $TABLE_FONT>number of errors: $(wc -l errors.log | awk '{printf("%s",$1);}')/$(wc -l nightly.log | awk '{printf("%s",$1);}'; rm errors.log)</td>"
|
---|
[1636] | 94 | echo "<td $TABLE_FONT> </td>"
|
---|
| 95 | echo "</tr>"
|
---|
| 96 | echo "<tr>"
|
---|
[2182] | 97 | echo "<td $TABLE_FONT>number of success: $(wc -l success.log | awk '{printf("%s",$1);}')/$(wc -l nightly.log | awk '{printf("%s",$1);}'; rm success.log)</td>"
|
---|
[1636] | 98 | echo "<td $TABLE_FONT> </td>"
|
---|
| 99 | echo "</tr>"
|
---|
| 100 | echo "</table>"
|
---|
| 101 |
|
---|
| 102 | #draw a line and clean up
|
---|
| 103 | echo "<br><hr width=\"900px\">"
|
---|
[1568] | 104 | fi
|
---|
[1574] | 105 | fi)
|
---|
| 106 | END
|
---|
[882] | 107 |
|
---|
[1855] | 108 | #Matlab error report
|
---|
| 109 | cat << END > matlaberror.html
|
---|
| 110 | <table $H2_STYLE><tr><td $H2_FONT>Matlab error</td></tr></table>
|
---|
| 111 | <table $MATLAB_STYLE><tr><td $MATLAB_FONT>
|
---|
| 112 | <pre>$(more matlaberror.log)</pre>
|
---|
| 113 | </td></tr></table>
|
---|
| 114 | END
|
---|
[1605] | 115 |
|
---|
[1574] | 116 | #report content
|
---|
[1576] | 117 | if [ $(echo $IS_INSTALL) = 1 ];
|
---|
[1574] | 118 | then
|
---|
| 119 | cat << END > content.html
|
---|
[2182] | 120 | <table $(echo $H2_STYLE)><tr><td $(echo $H2_FONT)>List of tests</td></tr></table>
|
---|
| 121 | <table $(echo $BODY_STYLE) cellspacing="-1">
|
---|
| 122 | <tr>
|
---|
| 123 | <th $(echo $BODY_FONT)>Result</th>
|
---|
| 124 | <th $(echo $BODY_FONT)>Tolerance</th>
|
---|
| 125 | <th $(echo $BODY_FONT)>Test name</th>
|
---|
| 126 | <th $(echo $BODY_FONT)>Analysis type</th>
|
---|
| 127 | <th $(echo $BODY_FONT)>Sub type</th>
|
---|
| 128 | <th $(echo $BODY_FONT)>Qmu</th>
|
---|
| 129 | <th $(echo $BODY_FONT)>control</th>
|
---|
| 130 | <th $(echo $BODY_FONT)>Control fit</th>
|
---|
| 131 | <th $(echo $BODY_FONT)>Parallel</th>
|
---|
| 132 | </tr>
|
---|
| 133 | $( COUNTER=0
|
---|
| 134 | MAX=`wc -l nightly.log | awk '{printf("%s",$1);}'`
|
---|
| 135 | while [ $COUNTER -lt $MAX ]; do
|
---|
| 136 | let COUNTER=COUNTER+1
|
---|
[882] | 137 |
|
---|
[2182] | 138 | echo "<tr>"
|
---|
[882] | 139 |
|
---|
[2182] | 140 | #see wether it is success or error (get color: red or green)
|
---|
| 141 | RESULT="$(cat nightly.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$COUNTER'o/ {printf("%s\n",$2);}';)"
|
---|
| 142 | if [ "$RESULT" = "SUCCESS" ];
|
---|
| 143 | then
|
---|
| 144 | color="bgcolor=#ddffdd";
|
---|
[882] | 145 | else
|
---|
[2182] | 146 | if [ "$RESULT" = "ERROR" ];
|
---|
| 147 | then
|
---|
| 148 | color="bgcolor=#ffdddd";
|
---|
| 149 | else
|
---|
| 150 | color="bgcolor=#ddddff";
|
---|
| 151 | fi
|
---|
| 152 | fi
|
---|
| 153 | FONT=$(echo "$BODY_FONT $color")
|
---|
[882] | 154 |
|
---|
[2182] | 155 | #build html corresponding line
|
---|
| 156 | cat nightly.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk -v FONT="$FONT" '
|
---|
| 157 | /line'$COUNTER'o/ { printf("<td %s>%s</td><td %s>%s%s%s</td><td %s>%s</td><td %s>%s</td><td %s>%s</td><td %s>%s</td><td %s>%s</td><td %s>%s</td><td %s>%s</td>",FONT,$2,FONT,$4,$5,$6,FONT,$8,FONT,$10,FONT,$12,FONT,$14,FONT,$16,FONT,$18,FONT,$20);}
|
---|
| 158 | ';
|
---|
[882] | 159 |
|
---|
[2182] | 160 | echo "</tr>"
|
---|
[882] | 161 |
|
---|
| 162 | done)
|
---|
[2182] | 163 | </table>
|
---|
[1574] | 164 | <br>
|
---|
| 165 | END
|
---|
| 166 | else
|
---|
[1855] | 167 | mktemp content.html
|
---|
[1574] | 168 | fi
|
---|
[882] | 169 |
|
---|
[1574] | 170 | #last footer
|
---|
| 171 | cat << END > footer.html
|
---|
[1074] | 172 | <br>
|
---|
[1605] | 173 | <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>
|
---|
| 174 | </div>
|
---|
[882] | 175 | END
|
---|
[1574] | 176 |
|
---|
| 177 | #concatenate files
|
---|
[2182] | 178 | if [ $IS_RUN -eq 0 ];
|
---|
[1574] | 179 | then
|
---|
[1855] | 180 | cat summary.html matlaberror.html content.html footer.html > report.html
|
---|
[1574] | 181 | else
|
---|
[1855] | 182 | cat summary.html content.html footer.html > report.html
|
---|
[1574] | 183 | fi
|
---|
[1855] | 184 | rm summary.html content.html footer.html matlaberror.html
|
---|