source: issm/branches/trunk-jpl-damage/scripts/report.sh@ 12878

Last change on this file since 12878 was 12878, checked in by cborstad, 13 years ago

merged trunk-jpl into trunk-jpl-damage through revision 12877

  • Property svn:executable set to *
File size: 6.9 KB
Line 
1#!/bin/bash
2#generate html report from info.log output file
3
4#----------------------------#
5# Initialize local variables #
6#----------------------------#
7
8#process info.log
9TODAY=` cat info.log | grep "today" | awk '{printf("%s %s",$2,$3);}'`
10USER=` cat info.log | grep "user" | awk '{print $2}'`
11HOST_NAME=` cat info.log | grep "host" | awk '{print $2}'`
12OS=` cat info.log | grep "OS" | awk '{print $2}'`
13RELEASE=` cat info.log | grep "release" | awk '{print $2}'`
14EL_INSTALL=`cat info.log | grep "elapsed_install" | awk '{print $2}'`
15EL_RUN=` cat info.log | grep "elapsed_run" | awk '{print $2}'`
16EL_TOTAL=` cat info.log | grep "elapsed_total" | awk '{print $2}'`
17CRASH=` cat info.log | grep "matlab_crash:" | awk '{print $2}'`
18
19#Process matlab_log.log
20cat matlab_log.log | egrep 'ERROR|SUCCESS|FAILURE' | grep -v "PETSC" | sed -e "s/>/\&gt;/g" | sed -e "s/</\&lt;/g" > matlab.log
21cat matlab.log | grep -v "SUCCESS" > matlab_short.log
22cat matlab_log.log | grep "PETSC" | sed -e "s/>/\&gt;/g" | sed -e "s/</\&lt;/g" > petscerror.log
23NUM_TOT=`wc -l matlab.log | awk '{print $1}'`
24NUM_ERR=`cat matlab.log | grep 'ERROR' | grep -v "PETSC" | wc -l`
25NUM_SUC=`cat matlab.log | grep 'SUCCESS' | wc -l`
26NUM_FAI=`cat matlab.log | grep 'FAILURE' | wc -l`
27
28#style
29H1_STYLE='width="1000px" cellpadding="20"'
30H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"'
31
32H2_STYLE='width="900px" cellpadding="20"'
33H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'
34
35TABLE_STYLE='width="800px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'
36TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'
37
38MATLAB_STYLE='width="1000px" rules=none'
39MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="left"'
40
41BODY_STYLE='width="800px"'
42BODY_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;"'
43
44FOOTER_STYLE='width="800px" cellpadding="10"'
45FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'
46
47#style 2
48BODY_FONTC=`echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:center; /g"`
49BODY_FONTL=`echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:left; /g"`
50
51#Did installation work?
52if [ $(ls -1 $ISSM_DIR/bin | wc -l) -le 20 ]; then
53 IS_INSTALL=0
54else
55 IS_INSTALL=1
56fi
57
58#display table ONLY if installation worked and there has been at leat one FAILURE or ERROR
59IS_TABLE=0
60if [ $IS_INSTALL -eq 1 ]; then
61 if [ $NUM_TOT -gt 1 ]; then
62 if [ $NUM_SUC -ne $NUM_TOT ]; then
63 IS_TABLE=1
64 fi
65 fi
66fi
67
68#-------------------#
69# build report.html #
70#-------------------#
71
72#first: summary
73cat << END > summary.html
74<div align="center">
75<table $H1_STYLE><tr><td $H1_FONT>ISSM Nightly run report</td></tr></table>
76
77<table $TABLE_STYLE>
78<tr>
79<td $TABLE_FONT>host: $HOST_NAME</td>
80<td $TABLE_FONT>date: $TODAY</td>
81</tr>
82<tr>
83<td $TABLE_FONT>OS: $OS</td>
84<td $TABLE_FONT>user: $USER</td>
85</tr>
86<tr>
87<td $TABLE_FONT>status: STATUS</td>
88<td $TABLE_FONT>release: $RELEASE</td>
89</tr>
90<tr>
91<td $TABLE_FONT>number of successes: $NUM_SUC/$NUM_TOT
92<td $TABLE_FONT>total elapsed time: $EL_TOTAL</td>
93</tr>
94<tr>
95<td $TABLE_FONT>number of <a href="#ERROR">errors</a>: $NUM_ERR/$NUM_TOT
96
97<td $TABLE_FONT>installation elapsed time: $EL_INSTALL</td>
98</tr>
99<tr>
100<td $TABLE_FONT>number of <a href="#FAILURE">failures</a>: $NUM_FAI/$NUM_TOT
101<td $TABLE_FONT>execution elapsed time: $EL_RUN</td>
102</tr>
103</table>
104<br><hr width="1000px">
105END
106
107#update status
108if [ $IS_INSTALL -eq 1 ];
109then
110 if [ $CRASH -eq 0 ];
111 then
112 cat summary.html | sed -e "s/STATUS/<span style=\"color:#008000\">all test desks have been run<\/span>/g" > summary2.html
113 else
114 cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation successful but Matlab crashed<\/span>/g" > summary2.html
115 fi
116else
117 cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation failed<\/span>/g" > summary2.html
118fi
119mv summary2.html summary.html
120
121#report table
122if [ $IS_TABLE -eq 1 ];
123then
124 cat << END > content.html
125<table $(echo $H2_STYLE)><tr><td $(echo $H2_FONT)>List of tests</td></tr></table>
126<table $(echo $BODY_STYLE) style="border-collapse:collapse;">
127<tr>
128<th $(echo $BODY_FONT)>Result</th>
129<th $(echo $BODY_FONT)>Tolerance</th>
130<th $(echo $BODY_FONT)>Test id</th>
131<th $(echo $BODY_FONT)>Test name</th>
132<th $(echo $BODY_FONT)>Field checked</th>
133</tr>
134$(cat matlab_short.log | while read line
135 do
136 echo "<tr>"
137
138 #get status
139 STATUS=`echo $line | awk '{print $1}'`
140
141 #FAILURE
142 if [ "$STATUS" = "FAILURE" ]
143 then
144
145 FONTC=$(echo "$BODY_FONTC bgcolor=#ffff00");
146 FONTL=$(echo "$BODY_FONTL bgcolor=#ffff00");
147 echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
148 { printf("<td %s id=FAILURE>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n\n",FONTL,$1,FONTC,$3,FONTC,$6,FONTL,$9,FONTL,$11);}
149 ';
150
151 else
152
153 #SUCCESS
154 if [ "$STATUS" = "SUCCESS" ]
155 then
156 FONTC=$(echo "$BODY_FONTC bgcolor=#ddffdd")
157 FONTL=$(echo "$BODY_FONTL bgcolor=#ddffdd")
158 #do not write anything
159 #ERROR
160 else
161 FONTC=$(echo "$BODY_FONTC bgcolor=#ffdddd id=ERROR")
162 FONTL=$(echo "$BODY_FONTL bgcolor=#ffdddd")
163 echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
164 { printf("<td %s>%s</td>\n<td %s>%s%s%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n\n",FONTL,$1,FONTL,$3,$4,$5,FONTC,$8,FONTL,$11,FONTL,$13);}
165 ';
166 fi
167
168 fi
169 echo "</tr>"
170 done
171 )
172</table>
173<br>
174END
175else
176 mktemp content.html
177fi
178
179#Matlab error report
180if [ -e matlaberror.log ]
181then
182 cat << END > matlaberror.html
183<table $H2_STYLE><tr><td $H2_FONT>Matlab errors</td></tr></table>
184<table $MATLAB_STYLE><tr><td $MATLAB_FONT>
185<pre style="
186white-space: -moz-pre-wrap;
187white-space: -pre-wrap;
188white-space: -o-pre-wrap;
189white-space: pre-wrap;
190word-wrap: break-word;
191">$(cat matlaberror.log)</pre>
192</td></tr></table>
193END
194else
195 mktemp matlaberror.html
196fi
197
198#Matlab error report
199if test -s petscerror.log
200then
201 cat << END > petscerror.html
202<table $H2_STYLE><tr><td $H2_FONT>PETSc errors</td></tr></table>
203<table $MATLAB_STYLE><tr><td $MATLAB_FONT>
204<pre style="
205white-space: -moz-pre-wrap;
206white-space: -pre-wrap;
207white-space: -o-pre-wrap;
208white-space: pre-wrap;
209word-wrap: break-word;
210">$(cat petscerror.log)</pre>
211</td></tr></table>
212END
213else
214 mktemp petscerror.html
215fi
216
217#last footer
218cat << END > footer.html
219<br>
220<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>
221</div>
222END
223
224#concatenate files
225cat summary.html content.html matlaberror.html petscerror.html footer.html > report.html
226rm summary.html content.html footer.html matlaberror.html petscerror.html matlab.log
Note: See TracBrowser for help on using the repository browser.