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