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

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

Added matlab error in report.html

  • Property svn:executable set to *
File size: 7.0 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
53MATLAB_STYLE='width="820px"'
54MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'
55
56#build report.html
57
58#first: summary
59cat << END > summary.html
60<div align="center">
61<table $H1_STYLE><tr><td $H1_FONT>ISSM Nightly run report</td></tr></table>
62
63<table $TABLE_STYLE>
64<tr>
65<td $TABLE_FONT>host: $HOST_NAME</td>
66<td $TABLE_FONT>date: $TODAY</td>
67</tr>
68<tr>
69<td $TABLE_FONT>OS: $OS</td>
70<td $TABLE_FONT>total elapsed time: $ELAPSED_TOTAL</td>
71</tr>
72<tr>
73<td $TABLE_FONT>release: $ISSM_RELEASE</td>
74<td $TABLE_FONT>installation elapsed time: $ELAPSED_INSTAL</td>
75</tr>
76<tr>
77$(#print status
78if [ $(echo $IS_INSTALL) = 0 ];
79then
80 #installation failed, end of report
81 echo "<td $TABLE_FONT>status: <span style=\"color:#FF0000\">installation failed</span></td>"
82 echo "<td $TABLE_FONT>execution elapsed time: $ELAPSED_RUN</td>"
83 echo "</tr>"
84 echo "</table>"
85 rm check.log errors.log success.log tests.log
86else
87 #installation successful. Did we go to the end?
88
89 if [ $(echo $IS_RUN) -eq 0 ];
90 then
91 #run failed, end of report
92 echo "<td $TABLE_FONT>status: <span style=\"color:#FF0000\">installation successful but tests runs failed</span></td>"
93 echo "<td $TABLE_FONT>execution elapsed time: $ELAPSED_RUN</td>"
94 echo "</tr>"
95 echo "</table>"
96 rm check.log errors.log success.log tests.log
97
98 else
99
100 if [ $(echo $IS_END) -eq 0 ];
101 then
102 echo "<td $TABLE_FONT>status: <span style=\"color:#FFA500\">stopped before the end</span></td>"
103 else
104 echo "<td $TABLE_FONT>status: <span style=\"color:#008000\">all test desks have been run</span></td>"
105 fi
106 echo "<td $TABLE_FONT>execution elapsed time: $ELAPSED_RUN</td>"
107 echo "</tr>"
108 echo "<tr>"
109 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>"
110 echo "<td $TABLE_FONT> </td>"
111 echo "</tr>"
112 echo "<tr>"
113 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>"
114 echo "<td $TABLE_FONT> </td>"
115 echo "</tr>"
116 echo "</table>"
117
118 #draw a line and clean up
119 echo "<br><hr width=\"900px\">"
120 rm check.log
121 fi
122fi)
123END
124
125#Matlab error report
126cat << END > matlaberror.html
127<table $H2_STYLE><tr><td $H2_FONT>Matlab error</td></tr></table>
128<table $MATLAB_STYLE><tr><td $MATLAB_FONT>
129<pre>$(more matlaberror.log)</pre>
130</td></tr></table>
131END
132
133#report content
134if [ $(echo $IS_INSTALL) = 1 ];
135then
136 cat << END > content.html
137$(for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
138
139 #enter title
140 if [ $package == "macayeal" ];
141 then
142 echo "<table $H2_STYLE><tr><td $H2_FONT>Macayeal package</td></tr></table>"
143 fi
144 if [ $package == "ice" ];
145 then
146 echo "<table $H2_STYLE><tr><td $H2_FONT>Ice package</td></tr></table>"
147 fi
148 if [ $package == "cielo_serial" ];
149 then
150 echo "<table $H2_STYLE><tr><td $H2_FONT>Cielo serial package</td></tr></table>"
151 fi
152 if [ $package == "cielo_parallel" ];
153 then
154 echo "<table $H2_STYLE><tr><td $H2_FONT>Cielo parallel package</td></tr></table>"
155 fi
156
157 #check that at least one Test exists
158 if [ `wc -l $package.log | awk '{printf("%s",$1);}'` = "0" ]; then
159
160 #No Test: use a table to fix entourage bug.
161 echo "<table $NOTEST_STYLE><tr><td $NOTEST_FONT>No test found.</td></tr></table>"
162
163 else
164
165 echo "<table $BODY_STYLE cellspacing=\"-1\">"
166 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>"
167
168 # go through the lines of $package.log
169 COUNTER=0
170 MAX=`wc -l $package.log | awk '{printf("%s",$1);}'`
171 while [ $COUNTER -lt $MAX ]; do
172 let COUNTER=COUNTER+1
173
174 echo "<tr>"
175
176 #see wether it is success or error (get color: red or green)
177 if [ "`cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$COUNTER'o/ {printf("%s\n",$2);}';`" == "SUCCESS" ];
178 then
179 color="bgcolor=#ddffdd";
180 else
181 color="bgcolor=#ffdddd";
182 fi
183 FONT=$(echo "$BODY_FONT $color")
184
185 #build html corresponding line
186 cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk -v FONT="$FONT" '
187 /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);}
188 ';
189 echo "</tr>"
190 done
191
192 echo "</table>"
193 fi
194
195 #remove log file
196 rm $package.log
197
198done)
199<br>
200END
201else
202 mktemp content.html
203 for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
204 rm $package.log
205 done
206fi
207
208#last footer
209cat << END > footer.html
210<br>
211<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>
212</div>
213END
214
215#concatenate files
216if [ $IS_RUN -eq 0 ] || [ $IS_END -eq 0 ];
217then
218 cat summary.html matlaberror.html content.html footer.html > report.html
219else
220 cat summary.html content.html footer.html > report.html
221fi
222rm summary.html content.html footer.html matlaberror.html
Note: See TracBrowser for help on using the repository browser.