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