1 | #!/bin/bash
|
---|
2 | #generate html report from nightly.log output file
|
---|
3 |
|
---|
4 | #Process log
|
---|
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
|
---|
9 | cat nightly.log | grep 'NIGHTLYRUNTERMINATEDCORRECTLY' > check.log
|
---|
10 | cat nightly.log | grep 'ERROR' | grep -v "PETSC ERROR" > errors.log
|
---|
11 | cat nightly.log | grep 'SUCCESS' > success.log
|
---|
12 | cat errors.log success.log > tests.log
|
---|
13 |
|
---|
14 | #create some variables
|
---|
15 | if [ $(ls -1 $ISSM_DIR/bin | wc -l) -le 20 ];
|
---|
16 | then
|
---|
17 | IS_INSTALL=0
|
---|
18 | else
|
---|
19 | IS_INSTALL=1
|
---|
20 | fi
|
---|
21 | if [ $(wc -l nightly.log | awk '{printf("%s",$1);}') -eq 0 ]
|
---|
22 | then
|
---|
23 | IS_RUN=0
|
---|
24 | else
|
---|
25 | IS_RUN=1
|
---|
26 | fi
|
---|
27 | if [ $(wc -l check.log | awk '{printf("%s",$1);}') -eq 0 ]
|
---|
28 | then
|
---|
29 | IS_END=0
|
---|
30 | else
|
---|
31 | IS_END=1
|
---|
32 | fi
|
---|
33 |
|
---|
34 | #style
|
---|
35 | H1_STYLE='width="800px" cellpadding="20"'
|
---|
36 | H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"'
|
---|
37 |
|
---|
38 | H2_STYLE='width="840px" cellpadding="20"'
|
---|
39 | H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'
|
---|
40 |
|
---|
41 | TABLE_STYLE='width="820px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'
|
---|
42 | TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14; font-weight: normal;" align="left"'
|
---|
43 |
|
---|
44 | BODY_STYLE='width="820px"'
|
---|
45 | BODY_FONT="style=\"color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;\""
|
---|
46 |
|
---|
47 | NOTEST_STYLE='width="650px"'
|
---|
48 | NOTEST_FONT='style="color:#FF0000; font-family:Arial, Verdana, Tahoma; font-size:14px;" align="left"'
|
---|
49 |
|
---|
50 | FOOTER_STYLE='width="800px" cellpadding="10"'
|
---|
51 | FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'
|
---|
52 |
|
---|
53 | MATLAB_STYLE='width="820px"'
|
---|
54 | MATLAB_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
|
---|
59 | cat << 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
|
---|
78 | if [ $(echo $IS_INSTALL) = 0 ];
|
---|
79 | then
|
---|
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
|
---|
86 | else
|
---|
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
|
---|
122 | fi)
|
---|
123 | END
|
---|
124 |
|
---|
125 | #Matlab error report
|
---|
126 | cat << 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>
|
---|
131 | END
|
---|
132 |
|
---|
133 | #report content
|
---|
134 | if [ $(echo $IS_INSTALL) = 1 ];
|
---|
135 | then
|
---|
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 |
|
---|
198 | done)
|
---|
199 | <br>
|
---|
200 | END
|
---|
201 | else
|
---|
202 | mktemp content.html
|
---|
203 | for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
|
---|
204 | rm $package.log
|
---|
205 | done
|
---|
206 | fi
|
---|
207 |
|
---|
208 | #last footer
|
---|
209 | cat << 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>
|
---|
213 | END
|
---|
214 |
|
---|
215 | #concatenate files
|
---|
216 | if [ $IS_RUN -eq 0 ] || [ $IS_END -eq 0 ];
|
---|
217 | then
|
---|
218 | cat summary.html matlaberror.html content.html footer.html > report.html
|
---|
219 | else
|
---|
220 | cat summary.html content.html footer.html > report.html
|
---|
221 | fi
|
---|
222 | rm summary.html content.html footer.html matlaberror.html
|
---|