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

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

minor

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