source: issm/trunk/cron/report.sh@ 4679

Last change on this file since 4679 was 4679, checked in by Mathieu Morlighem, 15 years ago

Fixed table border and special characters (< and >)

  • Property svn:executable set to *
File size: 6.5 KB
RevLine 
[882]1#!/bin/bash
2#generate html report from nightly.log output file
3
[3132]4#First go to the nightly run directory (created by nightlyrun.sh)
[2185]5cd $ISSM_DIR/test/Verification/NightlyRun/
[882]6
[3132]7#----------------------------#
8# Initialize local variables #
9#----------------------------#
10
[2185]11#process nightly.log
12TODAY=` cat nightly.log | grep "today" | awk '{printf("%s %s",$2,$3);}'`
13USER=` cat nightly.log | grep "user" | awk '{print $2}'`
14HOST_NAME=` cat nightly.log | grep "host" | awk '{print $2}'`
15OS=` cat nightly.log | grep "OS" | awk '{print $2}'`
16RELEASE=` cat nightly.log | grep "release" | awk '{print $2}'`
17EL_INSTALL=`cat nightly.log | grep "elapsed_install" | awk '{print $2}'`
18EL_RUN=` cat nightly.log | grep "elapsed_run" | awk '{print $2}'`
19EL_TOTAL=` cat nightly.log | grep "elapsed_total" | awk '{print $2}'`
[1568]20
[2185]21#Process matlab_log.log
[4679]22cat matlab_log.log | egrep 'ERROR|SUCCESS|FAILURE' | sed -e "s/>/\&gt;/g" | sed -e "s/</\&lt;/g" > matlab.log
[2185]23NUM_TOT=`wc -l matlab.log | awk '{print $1}'`
24NUM_ERR=`cat matlab.log | grep 'ERROR' | grep -v "PETSC ERROR" | wc -l`
25NUM_SUC=`cat matlab.log | grep 'SUCCESS' | wc -l`
26NUM_FAI=`cat matlab.log | grep 'FAILURE' | wc -l`
27
[1605]28#style
[2185]29H1_STYLE='width="1000px" cellpadding="20"'
[1605]30H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"'
[1568]31
[2185]32H2_STYLE='width="900px" cellpadding="20"'
[1605]33H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'
[1074]34
[2185]35TABLE_STYLE='width="800px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'
[1605]36TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14; font-weight: normal;" align="left"'
[882]37
[2185]38MATLAB_STYLE='width="1000px" rules=none'
[1857]39MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'
40
[3615]41BODY_STYLE='width="1050px"'
[1605]42BODY_FONT="style=\"color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;\""
[882]43
[1605]44FOOTER_STYLE='width="800px" cellpadding="10"'
45FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'
[1574]46
[2185]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#create some variables
52if [ $(ls -1 $ISSM_DIR/bin | wc -l) -le 20 ];
53then
54 IS_INSTALL=0
55else
56 IS_INSTALL=1
57fi
58if [ $(wc -l matlab.log | awk '{printf("%s",$1);}') -eq 0 ]
59then
60 IS_RUN=0
61else
62 IS_RUN=1
63fi
64
[3132]65#-------------------#
66# build report.html #
67#-------------------#
[1605]68
69#first: summary
[1574]70cat << END > summary.html
[1605]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>
[2185]80<td $TABLE_FONT>OS: $OS</td>
81<td $TABLE_FONT>user: $USER</td>
[1605]82</tr>
83<tr>
[2185]84<td $TABLE_FONT>status: STATUS</td>
85<td $TABLE_FONT>release: $RELEASE</td>
[1605]86</tr>
87<tr>
[2185]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
[2194]98<td $TABLE_FONT>execution elapsed time: $EL_RUN</td>
[2185]99</tr>
100</table>
101<br><hr width="1000px">
102END
103
104#update status
105if [ $IS_RUN -eq 1 ]
[882]106then
[2185]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
[882]109else
[2185]110 if [ $IS_INSTALL -eq 1 ]
[1568]111 then
[2185]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
[1568]114 else
[2185]115 cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation failed<\/span>/g" > summary2.html
116 mv summary2.html summary.html
[1568]117 fi
[2185]118fi
[882]119
[1605]120
[3132]121#report table
[2186]122if [ $IS_RUN -eq 1 ];
[1574]123then
124 cat << END > content.html
[2182]125<table $(echo $H2_STYLE)><tr><td $(echo $H2_FONT)>List of tests</td></tr></table>
[4679]126<table $(echo $BODY_STYLE) style="border-collapse:collapse;">
[2182]127<tr>
128<th $(echo $BODY_FONT)>Result</th>
129<th $(echo $BODY_FONT)>Tolerance</th>
130<th $(echo $BODY_FONT)>Test name</th>
[2194]131<th $(echo $BODY_FONT)>Analysis</th>
132<th $(echo $BODY_FONT)>Subanalysis </th>
[2182]133<th $(echo $BODY_FONT)>Qmu</th>
[2194]134<th $(echo $BODY_FONT)>Control</th>
[2182]135<th $(echo $BODY_FONT)>Control fit</th>
136<th $(echo $BODY_FONT)>Parallel</th>
[2185]137<th $(echo $BODY_FONT)>Field checked</th>
[2182]138</tr>
[2185]139$(cat matlab.log | while read line
140 do
141 echo "<tr>"
[882]142
[2185]143 #get status
144 STATUS=`echo $line | awk '{print $1}'`
[882]145
[2185]146 #FAILURE
147 if [ "$STATUS" = "FAILURE" ]
148 then
[882]149
[2185]150 FONTC=$(echo "$BODY_FONTC bgcolor=#ffff00");
151 FONTL=$(echo "$BODY_FONTL bgcolor=#ffff00");
152 echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
[2195]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");}
[2185]154 ';
[882]155
[2185]156 else
[882]157
[2185]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" '
[2195]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);}
[2185]172 ';
173 fi
174
175 echo "</tr>"
176
177 done
178 )
[2182]179</table>
[1574]180<br>
181END
182else
[1855]183 mktemp content.html
[1574]184fi
[882]185
[3132]186#Matlab error report
187if [ -e matlaberror.log ]
188then
[3133]189 cat << END > matlaberror.html
[3132]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>
194END
195else
196 mktemp matlaberror.html
197fi
198
[1574]199#last footer
200cat << END > footer.html
[1074]201<br>
[1605]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>
[882]204END
[1574]205
206#concatenate files
[3133]207cat summary.html content.html matlaberror.html footer.html > report.html
[2185]208rm summary.html content.html footer.html matlaberror.html matlab.log
Note: See TracBrowser for help on using the repository browser.