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
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
[1605]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
[882]13
[1568]14#create some variables
[1635]15if [ $(ls -1 $ISSM_DIR/bin | wc -l) -le 20 ];
[1576]16then
17 IS_INSTALL=0
18else
19 IS_INSTALL=1
20fi
[1636]21if [ $(wc -l nightly.log | awk '{printf("%s",$1);}') -eq 0 ]
[1568]22then
[1636]23 IS_RUN=0
24else
25 IS_RUN=1
26fi
27if [ $(wc -l check.log | awk '{printf("%s",$1);}') -eq 0 ]
28then
[1568]29 IS_END=0
30else
31 IS_END=1
32fi
33
[1605]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"'
[1568]37
[1605]38H2_STYLE='width="840px" cellpadding="20"'
39H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'
[1074]40
[1605]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"'
[882]43
[1605]44BODY_STYLE='width="820px"'
45BODY_FONT="style=\"color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;\""
[882]46
[1605]47NOTEST_STYLE='width="650px"'
48NOTEST_FONT='style="color:#FF0000; font-family:Arial, Verdana, Tahoma; font-size:14px;" align="left"'
[1074]49
[1605]50FOOTER_STYLE='width="800px" cellpadding="10"'
51FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'
[1574]52
[1855]53MATLAB_STYLE='width="820px"'
54MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'
55
[1605]56#build report.html
57
58#first: summary
[1574]59cat << END > summary.html
[1605]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 ];
[882]79then
[1568]80 #installation failed, end of report
[1605]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>"
[1574]85 rm check.log errors.log success.log tests.log
[882]86else
[1605]87 #installation successful. Did we go to the end?
88
[1636]89 if [ $(echo $IS_RUN) -eq 0 ];
[1568]90 then
[1636]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
[1568]98 else
[1636]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
[1568]121 fi
[1574]122fi)
123END
[882]124
[1855]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
[1605]132
[1574]133#report content
[1576]134if [ $(echo $IS_INSTALL) = 1 ];
[1574]135then
136 cat << END > content.html
[882]137$(for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
138
139 #enter title
[1605]140 if [ $package == "macayeal" ];
141 then
142 echo "<table $H2_STYLE><tr><td $H2_FONT>Macayeal package</td></tr></table>"
[882]143 fi
[1605]144 if [ $package == "ice" ];
145 then
146 echo "<table $H2_STYLE><tr><td $H2_FONT>Ice package</td></tr></table>"
[882]147 fi
[1605]148 if [ $package == "cielo_serial" ];
149 then
150 echo "<table $H2_STYLE><tr><td $H2_FONT>Cielo serial package</td></tr></table>"
[882]151 fi
[1605]152 if [ $package == "cielo_parallel" ];
153 then
154 echo "<table $H2_STYLE><tr><td $H2_FONT>Cielo parallel package</td></tr></table>"
[882]155 fi
156
[1074]157 #check that at least one Test exists
[882]158 if [ `wc -l $package.log | awk '{printf("%s",$1);}'` = "0" ]; then
[1074]159
160 #No Test: use a table to fix entourage bug.
[1605]161 echo "<table $NOTEST_STYLE><tr><td $NOTEST_FONT>No test found.</td></tr></table>"
[1074]162
[882]163 else
164
[1605]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>"
[882]167
168 # go through the lines of $package.log
[1521]169 COUNTER=0
[1435]170 MAX=`wc -l $package.log | awk '{printf("%s",$1);}'`
171 while [ $COUNTER -lt $MAX ]; do
172 let COUNTER=COUNTER+1
[882]173
174 echo "<tr>"
175
176 #see wether it is success or error (get color: red or green)
[1435]177 if [ "`cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$COUNTER'o/ {printf("%s\n",$2);}';`" == "SUCCESS" ];
[882]178 then
179 color="bgcolor=#ddffdd";
180 else
181 color="bgcolor=#ffdddd";
182 fi
[1605]183 FONT=$(echo "$BODY_FONT $color")
[882]184
185 #build html corresponding line
[1605]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 ';
[882]189 echo "</tr>"
190 done
191
192 echo "</table>"
193 fi
[1074]194
[1605]195 #remove log file
[882]196 rm $package.log
[1074]197
[882]198done)
[1574]199<br>
200END
201else
[1855]202 mktemp content.html
[1574]203 for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
204 rm $package.log
205 done
206fi
[882]207
[1574]208#last footer
209cat << END > footer.html
[1074]210<br>
[1605]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>
[882]213END
[1574]214
215#concatenate files
[1855]216if [ $IS_RUN -eq 0 ] || [ $IS_END -eq 0 ];
[1574]217then
[1855]218 cat summary.html matlaberror.html content.html footer.html > report.html
[1574]219else
[1855]220 cat summary.html content.html footer.html > report.html
[1574]221fi
[1855]222rm summary.html content.html footer.html matlaberror.html
Note: See TracBrowser for help on using the repository browser.