[882] | 1 | #!/bin/bash
|
---|
| 2 | #generate html report from nightly.log output file
|
---|
| 3 |
|
---|
[1568] | 4 | #Process log
|
---|
[884] | 5 | cat nightly.log | grep 'package: macayeal' | grep -v "not supported yet" > macayeal.log
|
---|
| 6 | cat nightly.log | grep 'package: ice' | grep -v "not supported yet" > ice.log
|
---|
| 7 | cat nightly.log | grep 'package: cielo_serial' | grep -v "not supported yet" > cielo_serial.log
|
---|
| 8 | cat nightly.log | grep 'package: cielo_parallel'| grep -v "not supported yet" > cielo_parallel.log
|
---|
[882] | 9 | cat nightly.log | grep NIGHTLYRUNTERMINATEDCORRECTLY > check.log
|
---|
[884] | 10 | cat nightly.log | grep ERROR | grep -v "PETSC ERROR" > errors.log
|
---|
[882] | 11 | cat nightly.log | grep SUCCESS > success.log
|
---|
| 12 | cat errors.log success.log > tests.log
|
---|
| 13 |
|
---|
[1568] | 14 | #create some variables
|
---|
| 15 | if [ `wc -l check.log | awk '{printf("%s",$1);}'` = "0" ]
|
---|
| 16 | then
|
---|
| 17 | IS_END=0
|
---|
| 18 | else
|
---|
| 19 | IS_END=1
|
---|
| 20 | fi
|
---|
| 21 | if [ `wc -l tests.log | awk '{printf("%s",$1);}'` = "0" ]
|
---|
| 22 | then
|
---|
| 23 | IS_INSTALL=0
|
---|
| 24 | else
|
---|
| 25 | IS_INSTALL=1
|
---|
| 26 | fi
|
---|
| 27 |
|
---|
[1574] | 28 | #build report.html
|
---|
[1568] | 29 |
|
---|
[1574] | 30 | #first: header
|
---|
| 31 | cat << END > header.html
|
---|
[882] | 32 | <html>
|
---|
| 33 | <title>ISSM - Nightly run Report</title>
|
---|
| 34 | <body>
|
---|
| 35 |
|
---|
| 36 | <style type="text/css">
|
---|
| 37 | <!--
|
---|
[1074] | 38 | .issmbody {
|
---|
| 39 | margin: auto;
|
---|
| 40 | width:800px;
|
---|
| 41 | background: none;
|
---|
| 42 | color: #404040;
|
---|
| 43 | font-family: Arial, Verdana, Tahoma;
|
---|
| 44 | font-size: 14px;
|
---|
| 45 | font-weight: normal;
|
---|
| 46 | text-align: left;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
[942] | 49 | .issmh1 {
|
---|
[1074] | 50 | margin:2em auto;
|
---|
| 51 | width:800px;
|
---|
[942] | 52 | background: none;
|
---|
[882] | 53 | color: #6495ed;
|
---|
[942] | 54 | font-family: Arial, Verdana, Tahoma;
|
---|
| 55 | font-size: 35px;
|
---|
[944] | 56 | font-weight: bold;
|
---|
[882] | 57 | text-align: center;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
[942] | 60 | .issmh2 {
|
---|
[1074] | 61 | margin:1.5em auto 1em auto;
|
---|
[943] | 62 | width:800px;
|
---|
[882] | 63 | background: transparent;
|
---|
| 64 | color: #6495ed;
|
---|
[942] | 65 | font-family: Arial, Verdana, Tahoma;
|
---|
[944] | 66 | font-weight: bold;
|
---|
[942] | 67 | font-size: 28px;
|
---|
[882] | 68 | text-align: left;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
[1074] | 71 | .issmfooter {
|
---|
| 72 | margin:auto;
|
---|
| 73 | width:800px;
|
---|
| 74 | background: none;
|
---|
| 75 | color: #404040;
|
---|
| 76 | font-family: Arial, Verdana, Tahoma;
|
---|
| 77 | font-size: 12px;
|
---|
| 78 | font-weight: normal;
|
---|
| 79 | text-align: center;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | .issmcomment {
|
---|
[882] | 83 | padding:4px;
|
---|
[1074] | 84 | margin:0 auto;
|
---|
[943] | 85 | width:800px;
|
---|
[882] | 86 | border:1px dashed #000000;
|
---|
[942] | 87 | text-align: left;
|
---|
| 88 | font-family: Arial, Verdana, Tahoma;
|
---|
| 89 | font-size: 14px;
|
---|
| 90 | color: #404040;
|
---|
[882] | 91 | background-color:#ffffdd}
|
---|
| 92 | -->
|
---|
| 93 | </style>
|
---|
[1074] | 94 | <div class="issmh1">ISSM Nightly run report</div>
|
---|
[882] | 95 | <br>
|
---|
[1574] | 96 | END
|
---|
| 97 |
|
---|
| 98 | #then: summary
|
---|
| 99 | cat << END > summary.html
|
---|
[1074] | 100 | <div class="issmcomment">
|
---|
[1530] | 101 | date: $TODAY<br>
|
---|
| 102 | host: $HOST_NAME<br>
|
---|
[1568] | 103 | OS: $OS<br>
|
---|
[1074] | 104 | release: $ISSM_RELEASE<br>
|
---|
[1566] | 105 | total elapsed time: $ELAPSED_TOTAL<br>
|
---|
| 106 | installation elapsed time: $ELAPSED_INSTAL<br>
|
---|
| 107 | runs elapsed time: $ELAPSED_RUN<br>
|
---|
[882] | 108 | <br>
|
---|
[1568] | 109 | status: $(if [ $IS_INSTALL==0 ];
|
---|
[882] | 110 | then
|
---|
[1568] | 111 | #installation failed, end of report
|
---|
[1574] | 112 | echo "<span style=\"color:#FF0000\">installation failed</span></div>"
|
---|
| 113 | rm check.log errors.log success.log tests.log
|
---|
[882] | 114 | else
|
---|
[1568] | 115 | if [ $IS_END==0 ];
|
---|
| 116 | then
|
---|
[1574] | 117 | echo "<span style=\"color:#FF0000\">stopped before the end</span>"
|
---|
[1568] | 118 | else
|
---|
| 119 | echo "all test desks have been run"
|
---|
| 120 | fi
|
---|
[1574] | 121 | echo "<br>"
|
---|
| 122 | echo "number of errors: $(wc -l errors.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}'; rm errors.log)<br>"
|
---|
| 123 | echo "number of success: $(wc -l success.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}';rm success.log tests.log)</div>"
|
---|
| 124 | echo "<br>"
|
---|
| 125 | echo "<hr width=\"900px\">"
|
---|
| 126 | rm check.log
|
---|
| 127 | fi)
|
---|
| 128 | END
|
---|
[882] | 129 |
|
---|
[1574] | 130 | #report content
|
---|
| 131 | if [ $IS_END != 0 ];
|
---|
| 132 | then
|
---|
| 133 | cat << END > content.html
|
---|
[882] | 134 | $(for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
|
---|
| 135 |
|
---|
| 136 | #enter title
|
---|
| 137 | if [ $package == "macayeal" ]; then
|
---|
[1074] | 138 | echo "<div class=\"issmh2\">MacAyeal package</div>"
|
---|
[882] | 139 | fi
|
---|
| 140 | if [ $package == "ice" ]; then
|
---|
[1074] | 141 | echo "<div class=\"issmh2\">Ice package</div>"
|
---|
[882] | 142 | fi
|
---|
| 143 | if [ $package == "cielo_serial" ]; then
|
---|
[1074] | 144 | echo "<div class=\"issmh2\">Cielo Serial package</div>"
|
---|
[882] | 145 | fi
|
---|
| 146 | if [ $package == "cielo_parallel" ]; then
|
---|
[1074] | 147 | echo "<div class=\"issmh2\">Cielo Parallel package</div>"
|
---|
[882] | 148 | fi
|
---|
| 149 |
|
---|
[1074] | 150 | #Print division
|
---|
| 151 | echo "<div class=\"issmbody\">"
|
---|
| 152 |
|
---|
| 153 | #check that at least one Test exists
|
---|
[882] | 154 | if [ `wc -l $package.log | awk '{printf("%s",$1);}'` = "0" ]; then
|
---|
[1074] | 155 |
|
---|
| 156 | #No Test: use a table to fix entourage bug.
|
---|
[1406] | 157 | echo "<table width=\"20%\" style=\"color:#FF0000; font-size:14px;\"><tr><td align=\"center\">No test found.</td></tr></table>"
|
---|
[1074] | 158 |
|
---|
[882] | 159 | else
|
---|
| 160 |
|
---|
[1406] | 161 | echo "<table cellspacing=\"-1\" width=\"100%\" style=\"font-family: Arial, Verdana, Tahoma; color: #404040;\">"
|
---|
[943] | 162 | echo "<tr> <th style=\"font-size:14px;\">Result</th> <th style=\"font-size:14px;\">Tolerance</th> <th style=\"font-size:14px;\">Test</th> <th style=\"font-size:14px;\">Solution</th> <th style=\"font-size:14px;\">Field</th> </tr>"
|
---|
[882] | 163 |
|
---|
| 164 | # go through the lines of $package.log
|
---|
[1521] | 165 | COUNTER=0
|
---|
[1435] | 166 | MAX=`wc -l $package.log | awk '{printf("%s",$1);}'`
|
---|
| 167 | while [ $COUNTER -lt $MAX ]; do
|
---|
| 168 | let COUNTER=COUNTER+1
|
---|
[882] | 169 |
|
---|
| 170 | echo "<tr>"
|
---|
| 171 |
|
---|
| 172 | #see wether it is success or error (get color: red or green)
|
---|
[1435] | 173 | if [ "`cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$COUNTER'o/ {printf("%s\n",$2);}';`" == "SUCCESS" ];
|
---|
[882] | 174 | then
|
---|
| 175 | color="bgcolor=#ddffdd";
|
---|
| 176 | else
|
---|
| 177 | color="bgcolor=#ffdddd";
|
---|
| 178 | fi
|
---|
| 179 |
|
---|
| 180 | #build html corresponding line
|
---|
[1435] | 181 | cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$COUNTER'o/ {printf("<td '$color' style=\"font-size:14px;\">%s</td><td '$color' style=\"font-size:14px;\"> %s%s%s</td><td '$color' style=\"font-size:14px;\"> %s</td><td '$color' style=\"font-size:14px;\"> %s</td><td '$color' style=\"font-size:14px;\"> %s</td>",$2,$4,$5,$6,$8,$10,$14);}';
|
---|
[882] | 182 | echo "</tr>"
|
---|
| 183 | done
|
---|
| 184 |
|
---|
| 185 | echo "</table>"
|
---|
| 186 | fi
|
---|
[1074] | 187 |
|
---|
| 188 | #Print end division and remove log file
|
---|
| 189 | echo "</div>"
|
---|
[882] | 190 | rm $package.log
|
---|
[1074] | 191 |
|
---|
[882] | 192 | done)
|
---|
[1574] | 193 | <br>
|
---|
| 194 | END
|
---|
| 195 | else
|
---|
| 196 | for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
|
---|
| 197 | rm $package.log
|
---|
| 198 | done
|
---|
| 199 | fi
|
---|
[882] | 200 |
|
---|
[1574] | 201 | #last footer
|
---|
| 202 | cat << END > footer.html
|
---|
[1074] | 203 | <br>
|
---|
| 204 | <div class="issmfooter"><a href="http://issm.jpl.nasa.gov" title="ISSM website" target="_blank">ISSM</a> nightly run report</div>
|
---|
| 205 | </body>
|
---|
| 206 | </html>
|
---|
[882] | 207 | END
|
---|
[1574] | 208 |
|
---|
| 209 | #concatenate files
|
---|
| 210 | if [ $IS_END != 0 ];
|
---|
| 211 | then
|
---|
| 212 | cat header.html summary.html content.html footer.html > report.html
|
---|
| 213 | rm header.html summary.html content.html footer.html
|
---|
| 214 | else
|
---|
| 215 | cat header.html summary.html footer.html > report.html
|
---|
| 216 | rm header.html summary.html footer.html
|
---|
| 217 | fi
|
---|