1 | #!/bin/bash
|
---|
2 | #generate html report from nightly.log output file
|
---|
3 |
|
---|
4 | #First go to the nightly run directory (created by nightlyrun.sh)
|
---|
5 | cd $ISSM_DIR/test/Verification/NightlyRun/
|
---|
6 |
|
---|
7 | #----------------------------#
|
---|
8 | # Initialize local variables #
|
---|
9 | #----------------------------#
|
---|
10 |
|
---|
11 | #process nightly.log
|
---|
12 | TODAY=` cat nightly.log | grep "today" | awk '{printf("%s %s",$2,$3);}'`
|
---|
13 | USER=` cat nightly.log | grep "user" | awk '{print $2}'`
|
---|
14 | HOST_NAME=` cat nightly.log | grep "host" | awk '{print $2}'`
|
---|
15 | OS=` cat nightly.log | grep "OS" | awk '{print $2}'`
|
---|
16 | RELEASE=` cat nightly.log | grep "release" | awk '{print $2}'`
|
---|
17 | EL_INSTALL=`cat nightly.log | grep "elapsed_install" | awk '{print $2}'`
|
---|
18 | EL_RUN=` cat nightly.log | grep "elapsed_run" | awk '{print $2}'`
|
---|
19 | EL_TOTAL=` cat nightly.log | grep "elapsed_total" | awk '{print $2}'`
|
---|
20 |
|
---|
21 | #Process matlab_log.log
|
---|
22 | cat matlab_log.log | egrep 'ERROR|SUCCESS|FAILURE' > matlab.log
|
---|
23 | NUM_TOT=`wc -l matlab.log | awk '{print $1}'`
|
---|
24 | NUM_ERR=`cat matlab.log | grep 'ERROR' | grep -v "PETSC ERROR" | wc -l`
|
---|
25 | NUM_SUC=`cat matlab.log | grep 'SUCCESS' | wc -l`
|
---|
26 | NUM_FAI=`cat matlab.log | grep 'FAILURE' | wc -l`
|
---|
27 |
|
---|
28 | #style
|
---|
29 | H1_STYLE='width="1000px" cellpadding="20"'
|
---|
30 | H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"'
|
---|
31 |
|
---|
32 | H2_STYLE='width="900px" cellpadding="20"'
|
---|
33 | H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'
|
---|
34 |
|
---|
35 | TABLE_STYLE='width="800px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'
|
---|
36 | TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14; font-weight: normal;" align="left"'
|
---|
37 |
|
---|
38 | MATLAB_STYLE='width="1000px" rules=none'
|
---|
39 | MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'
|
---|
40 |
|
---|
41 | BODY_STYLE='width="1000px"'
|
---|
42 | BODY_FONT="style=\"color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;\""
|
---|
43 |
|
---|
44 | FOOTER_STYLE='width="800px" cellpadding="10"'
|
---|
45 | FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'
|
---|
46 |
|
---|
47 | #style 2
|
---|
48 | BODY_FONTC=`echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:center; /g"`
|
---|
49 | BODY_FONTL=`echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:left; /g"`
|
---|
50 |
|
---|
51 | #create some variables
|
---|
52 | if [ $(ls -1 $ISSM_DIR/bin | wc -l) -le 20 ];
|
---|
53 | then
|
---|
54 | IS_INSTALL=0
|
---|
55 | else
|
---|
56 | IS_INSTALL=1
|
---|
57 | fi
|
---|
58 | if [ $(wc -l matlab.log | awk '{printf("%s",$1);}') -eq 0 ]
|
---|
59 | then
|
---|
60 | IS_RUN=0
|
---|
61 | else
|
---|
62 | IS_RUN=1
|
---|
63 | fi
|
---|
64 |
|
---|
65 | #-------------------#
|
---|
66 | # build report.html #
|
---|
67 | #-------------------#
|
---|
68 |
|
---|
69 | #first: summary
|
---|
70 | cat << END > summary.html
|
---|
71 | <div align="center">
|
---|
72 | <table $H1_STYLE><tr><td $H1_FONT>ISSM Nightly run report</td></tr></table>
|
---|
73 |
|
---|
74 | <table $TABLE_STYLE>
|
---|
75 | <tr>
|
---|
76 | <td $TABLE_FONT>host: $HOST_NAME</td>
|
---|
77 | <td $TABLE_FONT>date: $TODAY</td>
|
---|
78 | </tr>
|
---|
79 | <tr>
|
---|
80 | <td $TABLE_FONT>OS: $OS</td>
|
---|
81 | <td $TABLE_FONT>user: $USER</td>
|
---|
82 | </tr>
|
---|
83 | <tr>
|
---|
84 | <td $TABLE_FONT>status: STATUS</td>
|
---|
85 | <td $TABLE_FONT>release: $RELEASE</td>
|
---|
86 | </tr>
|
---|
87 | <tr>
|
---|
88 | <td $TABLE_FONT>number of success: $NUM_SUC/$NUM_TOT
|
---|
89 | <td $TABLE_FONT>total elapsed time: $EL_TOTAL</td>
|
---|
90 | </tr>
|
---|
91 | <tr>
|
---|
92 | <td $TABLE_FONT>number of errors: $NUM_ERR/$NUM_TOT
|
---|
93 |
|
---|
94 | <td $TABLE_FONT>installation elapsed time: $EL_INSTALL</td>
|
---|
95 | </tr>
|
---|
96 | <tr>
|
---|
97 | <td $TABLE_FONT>number of failures: $NUM_FAI/$NUM_TOT
|
---|
98 | <td $TABLE_FONT>execution elapsed time: $EL_RUN</td>
|
---|
99 | </tr>
|
---|
100 | </table>
|
---|
101 | <br><hr width="1000px">
|
---|
102 | END
|
---|
103 |
|
---|
104 | #update status
|
---|
105 | if [ $IS_RUN -eq 1 ]
|
---|
106 | then
|
---|
107 | cat summary.html | sed -e "s/STATUS/<span style=\"color:#008000\">all test desks have been run<\/span>/g" > summary2.html
|
---|
108 | mv summary2.html summary.html
|
---|
109 | else
|
---|
110 | if [ $IS_INSTALL -eq 1 ]
|
---|
111 | then
|
---|
112 | cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation successful but tests runs failed<\/span>/g" > summary2.html
|
---|
113 | mv summary2.html summary.html
|
---|
114 | else
|
---|
115 | cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation failed<\/span>/g" > summary2.html
|
---|
116 | mv summary2.html summary.html
|
---|
117 | fi
|
---|
118 | fi
|
---|
119 |
|
---|
120 |
|
---|
121 | #report table
|
---|
122 | if [ $IS_RUN -eq 1 ];
|
---|
123 | then
|
---|
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) cellspacing="-1">
|
---|
127 | <tr>
|
---|
128 | <th $(echo $BODY_FONT)>Result</th>
|
---|
129 | <th $(echo $BODY_FONT)>Tolerance</th>
|
---|
130 | <th $(echo $BODY_FONT)>Test name</th>
|
---|
131 | <th $(echo $BODY_FONT)>Analysis</th>
|
---|
132 | <th $(echo $BODY_FONT)>Subanalysis </th>
|
---|
133 | <th $(echo $BODY_FONT)>Qmu</th>
|
---|
134 | <th $(echo $BODY_FONT)>Control</th>
|
---|
135 | <th $(echo $BODY_FONT)>Control fit</th>
|
---|
136 | <th $(echo $BODY_FONT)>Parallel</th>
|
---|
137 | <th $(echo $BODY_FONT)>Field checked</th>
|
---|
138 | </tr>
|
---|
139 | $(cat matlab.log | while read line
|
---|
140 | do
|
---|
141 | echo "<tr>"
|
---|
142 |
|
---|
143 | #get status
|
---|
144 | STATUS=`echo $line | awk '{print $1}'`
|
---|
145 |
|
---|
146 | #FAILURE
|
---|
147 | if [ "$STATUS" = "FAILURE" ]
|
---|
148 | then
|
---|
149 |
|
---|
150 | FONTC=$(echo "$BODY_FONTC bgcolor=#ffff00");
|
---|
151 | FONTL=$(echo "$BODY_FONTL bgcolor=#ffff00");
|
---|
152 | echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
|
---|
153 | { printf("<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n",FONTL,$1,FONTC,"N/A",FONTL,$3,FONTL,$5,FONTL,$7,FONTC,$9,FONTC,$11,FONTC,$13,FONTC,$15,FONTC,"N/A");}
|
---|
154 | ';
|
---|
155 |
|
---|
156 | else
|
---|
157 |
|
---|
158 | #SUCCESS
|
---|
159 | if [ "$STATUS" = "SUCCESS" ]
|
---|
160 | then
|
---|
161 | color="bgcolor=#ddffdd";
|
---|
162 |
|
---|
163 | #ERROR
|
---|
164 | else
|
---|
165 | color="bgcolor=#ffdddd";
|
---|
166 | fi
|
---|
167 |
|
---|
168 | FONTC=$(echo "$BODY_FONTC $color")
|
---|
169 | FONTL=$(echo "$BODY_FONTL $color")
|
---|
170 | echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
|
---|
171 | { 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<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n",FONTL,$1,FONTL,$3,$4,$5,FONTL,$7,FONTL,$9,FONTL,$11,FONTC,$13,FONTC,$15,FONTC,$17,FONTC,$19,FONTL,$21);}
|
---|
172 | ';
|
---|
173 | fi
|
---|
174 |
|
---|
175 | echo "</tr>"
|
---|
176 |
|
---|
177 | done
|
---|
178 | )
|
---|
179 | </table>
|
---|
180 | <br>
|
---|
181 | END
|
---|
182 | else
|
---|
183 | mktemp content.html
|
---|
184 | fi
|
---|
185 |
|
---|
186 | #Matlab error report
|
---|
187 | if [ -e matlaberror.log ]
|
---|
188 | then
|
---|
189 | cat << END > matlaberror.html
|
---|
190 | <table $H2_STYLE><tr><td $H2_FONT>Matlab error</td></tr></table>
|
---|
191 | <table $MATLAB_STYLE><tr><td $MATLAB_FONT>
|
---|
192 | <pre>$(cat matlaberror.log)</pre>
|
---|
193 | </td></tr></table>
|
---|
194 | END
|
---|
195 | else
|
---|
196 | mktemp matlaberror.html
|
---|
197 | fi
|
---|
198 |
|
---|
199 | #last footer
|
---|
200 | cat << END > footer.html
|
---|
201 | <br>
|
---|
202 | <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>
|
---|
203 | </div>
|
---|
204 | END
|
---|
205 |
|
---|
206 | #concatenate files
|
---|
207 | cat summary.html content.html matlaberror.html footer.html > report.html
|
---|
208 | rm summary.html content.html footer.html matlaberror.html matlab.log
|
---|