1 | #!/bin/bash
|
---|
2 | #generate html report from nightly.log output file
|
---|
3 |
|
---|
4 | #Process log
|
---|
5 | cat nightly.log | grep 'ERROR' | grep -v "PETSC ERROR" > errors.log
|
---|
6 | cat nightly.log | grep 'SUCCESS' > success.log
|
---|
7 | cat nightly.log | grep 'FAILURE' > failures.log
|
---|
8 |
|
---|
9 | #create some variables
|
---|
10 | if [ $(ls -1 $ISSM_DIR/bin | wc -l) -le 20 ];
|
---|
11 | then
|
---|
12 | IS_INSTALL=0
|
---|
13 | else
|
---|
14 | IS_INSTALL=1
|
---|
15 | fi
|
---|
16 | if [ $(wc -l nightly.log | awk '{printf("%s",$1);}') -eq 0 ]
|
---|
17 | then
|
---|
18 | IS_RUN=0
|
---|
19 | else
|
---|
20 | IS_RUN=1
|
---|
21 | fi
|
---|
22 |
|
---|
23 | #style
|
---|
24 | H1_STYLE='width="800px" cellpadding="20"'
|
---|
25 | H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"'
|
---|
26 |
|
---|
27 | H2_STYLE='width="840px" cellpadding="20"'
|
---|
28 | H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'
|
---|
29 |
|
---|
30 | TABLE_STYLE='width="820px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'
|
---|
31 | TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14; font-weight: normal;" align="left"'
|
---|
32 |
|
---|
33 | MATLAB_STYLE='width="820px" rules=none'
|
---|
34 | MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'
|
---|
35 |
|
---|
36 | BODY_STYLE='width="820px"'
|
---|
37 | BODY_FONT="style=\"color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;\""
|
---|
38 |
|
---|
39 | NOTEST_STYLE='width="650px"'
|
---|
40 | NOTEST_FONT='style="color:#FF0000; font-family:Arial, Verdana, Tahoma; font-size:14px;" align="left"'
|
---|
41 |
|
---|
42 | FOOTER_STYLE='width="800px" cellpadding="10"'
|
---|
43 | FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'
|
---|
44 |
|
---|
45 | #build report.html
|
---|
46 |
|
---|
47 | #first: summary
|
---|
48 | cat << END > summary.html
|
---|
49 | <div align="center">
|
---|
50 | <table $H1_STYLE><tr><td $H1_FONT>ISSM Nightly run report</td></tr></table>
|
---|
51 |
|
---|
52 | <table $TABLE_STYLE>
|
---|
53 | <tr>
|
---|
54 | <td $TABLE_FONT>host: $HOST_NAME</td>
|
---|
55 | <td $TABLE_FONT>date: $TODAY</td>
|
---|
56 | </tr>
|
---|
57 | <tr>
|
---|
58 | <td $TABLE_FONT>user: $(whoami)</td>
|
---|
59 | <td $TABLE_FONT>total elapsed time: $ELAPSED_TOTAL</td>
|
---|
60 | </tr>
|
---|
61 | <tr>
|
---|
62 | <td $TABLE_FONT>OS: $OS</td>
|
---|
63 | <td $TABLE_FONT>installation elapsed time: $ELAPSED_INSTAL</td>
|
---|
64 | </tr>
|
---|
65 | <tr>
|
---|
66 | $(#print status
|
---|
67 | if [ $(echo $IS_INSTALL) -eq 0 ];
|
---|
68 | then
|
---|
69 | #installation failed, end of report
|
---|
70 | echo "<td $TABLE_FONT>status: <span style=\"color:#FF0000\">installation failed</span></td>"
|
---|
71 | echo "<td $TABLE_FONT>execution elapsed time: $ELAPSED_RUN</td>"
|
---|
72 | echo "</tr>"
|
---|
73 | echo "</table>"
|
---|
74 | rm errors.log success.log
|
---|
75 | else
|
---|
76 | #installation successful. Did we go to the end?
|
---|
77 |
|
---|
78 | if [ $(echo $IS_RUN) -eq 0 ];
|
---|
79 | then
|
---|
80 | #run failed, end of report
|
---|
81 | echo "<td $TABLE_FONT>status: <span style=\"color:#FF0000\">installation successful but tests runs failed</span></td>"
|
---|
82 | echo "<td $TABLE_FONT>execution elapsed time: $ELAPSED_RUN</td>"
|
---|
83 | echo "</tr>"
|
---|
84 | echo "</table>"
|
---|
85 | rm errors.log success.log failures.log
|
---|
86 |
|
---|
87 | else
|
---|
88 |
|
---|
89 | echo "<td $TABLE_FONT>status: <span style=\"color:#008000\">all test desks have been run</span></td>"
|
---|
90 | echo "<td $TABLE_FONT>execution elapsed time: $ELAPSED_RUN</td>"
|
---|
91 | echo "</tr>"
|
---|
92 | echo "<tr>"
|
---|
93 | echo "<td $TABLE_FONT>number of errors: $(wc -l errors.log | awk '{printf("%s",$1);}')/$(wc -l nightly.log | awk '{printf("%s",$1);}'; rm errors.log)</td>"
|
---|
94 | echo "<td $TABLE_FONT> </td>"
|
---|
95 | echo "</tr>"
|
---|
96 | echo "<tr>"
|
---|
97 | echo "<td $TABLE_FONT>number of success: $(wc -l success.log | awk '{printf("%s",$1);}')/$(wc -l nightly.log | awk '{printf("%s",$1);}'; rm success.log)</td>"
|
---|
98 | echo "<td $TABLE_FONT> </td>"
|
---|
99 | echo "</tr>"
|
---|
100 | echo "</table>"
|
---|
101 |
|
---|
102 | #draw a line and clean up
|
---|
103 | echo "<br><hr width=\"900px\">"
|
---|
104 | fi
|
---|
105 | fi)
|
---|
106 | END
|
---|
107 |
|
---|
108 | #Matlab error report
|
---|
109 | cat << END > matlaberror.html
|
---|
110 | <table $H2_STYLE><tr><td $H2_FONT>Matlab error</td></tr></table>
|
---|
111 | <table $MATLAB_STYLE><tr><td $MATLAB_FONT>
|
---|
112 | <pre>$(more matlaberror.log)</pre>
|
---|
113 | </td></tr></table>
|
---|
114 | END
|
---|
115 |
|
---|
116 | #report content
|
---|
117 | if [ $(echo $IS_INSTALL) = 1 ];
|
---|
118 | then
|
---|
119 | cat << END > content.html
|
---|
120 | <table $(echo $H2_STYLE)><tr><td $(echo $H2_FONT)>List of tests</td></tr></table>
|
---|
121 | <table $(echo $BODY_STYLE) cellspacing="-1">
|
---|
122 | <tr>
|
---|
123 | <th $(echo $BODY_FONT)>Result</th>
|
---|
124 | <th $(echo $BODY_FONT)>Tolerance</th>
|
---|
125 | <th $(echo $BODY_FONT)>Test name</th>
|
---|
126 | <th $(echo $BODY_FONT)>Analysis type</th>
|
---|
127 | <th $(echo $BODY_FONT)>Sub type</th>
|
---|
128 | <th $(echo $BODY_FONT)>Qmu</th>
|
---|
129 | <th $(echo $BODY_FONT)>control</th>
|
---|
130 | <th $(echo $BODY_FONT)>Control fit</th>
|
---|
131 | <th $(echo $BODY_FONT)>Parallel</th>
|
---|
132 | </tr>
|
---|
133 | $( COUNTER=0
|
---|
134 | MAX=`wc -l nightly.log | awk '{printf("%s",$1);}'`
|
---|
135 | while [ $COUNTER -lt $MAX ]; do
|
---|
136 | let COUNTER=COUNTER+1
|
---|
137 |
|
---|
138 | echo "<tr>"
|
---|
139 |
|
---|
140 | #see wether it is success or error (get color: red or green)
|
---|
141 | RESULT="$(cat nightly.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$COUNTER'o/ {printf("%s\n",$2);}';)"
|
---|
142 | if [ "$RESULT" = "SUCCESS" ];
|
---|
143 | then
|
---|
144 | color="bgcolor=#ddffdd";
|
---|
145 | else
|
---|
146 | if [ "$RESULT" = "ERROR" ];
|
---|
147 | then
|
---|
148 | color="bgcolor=#ffdddd";
|
---|
149 | else
|
---|
150 | color="bgcolor=#ddddff";
|
---|
151 | fi
|
---|
152 | fi
|
---|
153 | FONT=$(echo "$BODY_FONT $color")
|
---|
154 |
|
---|
155 | #build html corresponding line
|
---|
156 | cat nightly.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk -v FONT="$FONT" '
|
---|
157 | /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><td %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,$12,FONT,$14,FONT,$16,FONT,$18,FONT,$20);}
|
---|
158 | ';
|
---|
159 |
|
---|
160 | echo "</tr>"
|
---|
161 |
|
---|
162 | done)
|
---|
163 | </table>
|
---|
164 | <br>
|
---|
165 | END
|
---|
166 | else
|
---|
167 | mktemp content.html
|
---|
168 | fi
|
---|
169 |
|
---|
170 | #last footer
|
---|
171 | cat << END > footer.html
|
---|
172 | <br>
|
---|
173 | <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>
|
---|
174 | </div>
|
---|
175 | END
|
---|
176 |
|
---|
177 | #concatenate files
|
---|
178 | if [ $IS_RUN -eq 0 ];
|
---|
179 | then
|
---|
180 | cat summary.html matlaberror.html content.html footer.html > report.html
|
---|
181 | else
|
---|
182 | cat summary.html content.html footer.html > report.html
|
---|
183 | fi
|
---|
184 | rm summary.html content.html footer.html matlaberror.html
|
---|