source: issm/trunk/cron/report.sh@ 1588

Last change on this file since 1588 was 1588, checked in by Mathieu Morlighem, 16 years ago

minor flags not needed

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