Changeset 13198


Ignore:
Timestamp:
08/30/12 15:42:00 (13 years ago)
Author:
Mathieu Morlighem
Message:

NEW: added python tests in NR report

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/scripts/report.sh

    r13197 r13198  
    22#generate html report from info.log output file
    33
    4 #----------------------------#
    5 # Initialize local variables #
    6 #----------------------------#
     4#style
     5#{{{
     6H1_STYLE='width="900px" cellpadding="20"'
     7H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:30px;" align="center"'
     8H2_STYLE='width="800px" cellpadding="20"'
     9H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:25px; font-weight: bold;" align="left"'
     10TABLE_STYLE='width="700px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'
     11TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'
     12MATLAB_STYLE='width="9000px" rules=none'
     13MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="left"'
     14BODY_STYLE='width="700px"'
     15BODY_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;"'
     16BODY_FONTC=$(echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:center; /g")
     17BODY_FONTL=$(echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:left; /g")
     18FOOTER_STYLE='width="700px"  cellpadding="10"'
     19FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'
     20#}}}
    721
    822#process info.log
     23#{{{
     24if [ ! -f info.log ]; then
     25        echo "File info.log not found!" >&2   # Error message to stderr.
     26        exit 1
     27fi
    928TODAY=$(       cat info.log | grep "today"           | awk '{printf("%s %s",$2,$3);}')
    1029USER=$(        cat info.log | grep "user"            | awk '{print $2}')
     
    1332RELEASE=$(     cat info.log | grep "release"         | awk '{print $2}')
    1433EL_INSTALL=$(  cat info.log | grep "elapsed_install" | awk '{print $2}')
     34EL_TOTAL=$(    cat info.log | grep "elapsed_total"   | awk '{print $2}')
     35IS_MATLAB=$(   cat info.log | grep "is_matlab"       | awk '{print $2}')
     36IS_PYTHON=$(   cat info.log | grep "is_python"       | awk '{print $2}')
    1537EL_MATLAB=$(   cat info.log | grep "elapsed_matlab"  | awk '{print $2}')
    1638EL_PYTHON=$(   cat info.log | grep "elapsed_python"  | awk '{print $2}')
    17 EL_TOTAL=$(    cat info.log | grep "elapsed_total"   | awk '{print $2}')
    1839CRASH_MATLAB=$(cat info.log | grep "matlab_crash:"   | awk '{print $2}')
    1940CRASH_PYTHON=$(cat info.log | grep "python_crash:"   | awk '{print $2}')
    20 
    21 #Process matlab_log.log
    22 cat matlab_log.log        | egrep 'ERROR|SUCCESS|FAILURE' | grep -v "PETSC" | sed -e "s/>/\&gt;/g" | sed -e "s/</\&lt;/g" > matlab.log
    23 cat matlab.log        | grep -v "SUCCESS" > matlab_short.log
    24 cat matlab_log.log        | grep "PETSC" | sed -e "s/>/\&gt;/g" | sed -e "s/</\&lt;/g" > petscerror.log
    25 NUM_TOT=$(wc -l matlab.log | awk '{print $1}')
    26 NUM_ERR=$(cat matlab.log | grep 'ERROR'   | grep -v "PETSC" | wc -l)
    27 NUM_SUC=$(cat matlab.log | grep 'SUCCESS' | wc -l)
    28 NUM_FAI=$(cat matlab.log | grep 'FAILURE' | wc -l)
    29 
    30 #style
    31 H1_STYLE='width="1000px" cellpadding="20"'
    32 H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"'
    33 
    34 H2_STYLE='width="900px" cellpadding="20"'
    35 H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'
    36 
    37 TABLE_STYLE='width="800px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'
    38 TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'
    39 
    40 MATLAB_STYLE='width="1000px" rules=none'
    41 MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="left"'
    42 
    43 BODY_STYLE='width="800px"'
    44 BODY_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;"'
    45 
    46 FOOTER_STYLE='width="800px"  cellpadding="10"'
    47 FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'
    48 
    49 #style 2
    50 BODY_FONTC=`echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:center; /g"`
    51 BODY_FONTL=`echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:left; /g"`
    5241
    5342#Did installation work?
     
    5746        IS_INSTALL=1
    5847fi
    59 
    60 #display table ONLY if installation worked and there has been at leat one FAILURE or ERROR
    61 IS_TABLE=0
    62 if [ $IS_INSTALL -eq 1 ]; then
    63         if [ $NUM_TOT -gt 1 ]; then
    64                 if [ $NUM_SUC -ne $NUM_TOT  ]; then
    65                         IS_TABLE=1
    66                 fi
    67         fi
    68 fi
    69 
    70 #-------------------#
    71 # build report.html #
    72 #-------------------#
    73 
    74 #first: summary
    75 cat << END > summary.html
     48#}}}
     49
     50#1. summary table
     51#{{{
     52rm report.html
     53cat << END >> report.html
    7654<div align="center">
    7755<table $H1_STYLE><tr><td $H1_FONT>ISSM Nightly run report</td></tr></table>
     
    8361</tr>
    8462<tr>
    85 <td $TABLE_FONT>OS: $OS</td>
    8663<td $TABLE_FONT>user: $USER</td>
    87 </tr>
    88 <tr>
    89 <td $TABLE_FONT>status: STATUS</td>
    9064<td $TABLE_FONT>release: $RELEASE</td>
    9165</tr>
    9266<tr>
    93 <td $TABLE_FONT>number of successes: $NUM_SUC/$NUM_TOT
    9467<td $TABLE_FONT>total elapsed time: $EL_TOTAL</td>
    95 </tr>
    96 <tr>
    97 <td $TABLE_FONT>number of <a href="#ERROR">errors</a>: $NUM_ERR/$NUM_TOT
    98 
    9968<td $TABLE_FONT>installation elapsed time: $EL_INSTALL</td>
    10069</tr>
    101 <tr>
    102 <td $TABLE_FONT>number of <a href="#FAILURE">failures</a>: $NUM_FAI/$NUM_TOT
    103 <td $TABLE_FONT>execution elapsed time: $EL_MATLAB</td>
    104 </tr>
    105 </table>
    106 <br><hr width="1000px">
    107 END
    108 
    109 #update status
    110 if [ $IS_INSTALL -eq 1 ];
     70</table>
     71<br><hr width="900px">
     72END
     73# }}}
     74
     75#stop if did not install
     76#{{{
     77if [ $IS_INSTALL -eq 0 ]; then
     78        cat << END >> report.html
     79        <table $(echo $BODY_STYLE) style="border-collapse:collapse;">
     80        <tr><td $BODY_FONT>status: <span style=\"color:#ff0000\">Installation failed<\/span></td></tr>
     81        </table>
     82        <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>
     83        </div>
     84END
     85exit 0
     86fi
     87#}}}
     88
     89#2. matlab report
     90if [ $IS_MATLAB -eq 1 ]; then
     91#Process matlab_log.log {{{
     92cat matlab_log.log        | egrep 'ERROR|SUCCESS|FAILURE' | grep -v "PETSC" | sed -e "s/>/\&gt;/g" | sed -e "s/</\&lt;/g" > matlab.log
     93cat matlab.log        | grep -v "SUCCESS" > matlab_short.log
     94cat matlab_log.log        | grep "PETSC" | sed -e "s/>/\&gt;/g" | sed -e "s/</\&lt;/g" > petscerror.log
     95NUM_MATLAB_TOT=$(wc -l matlab.log | awk '{print $1}')
     96NUM_MATLAB_ERR=$(cat matlab.log | grep 'ERROR'   | grep -v "PETSC" | wc -l)
     97NUM_MATLAB_SUC=$(cat matlab.log | grep 'SUCCESS' | wc -l)
     98NUM_MATLAB_FAI=$(cat matlab.log | grep 'FAILURE' | wc -l)
     99#}}}
     100#write report {{{
     101cat << END >> report.html
     102<table $H2_STYLE><tr><td $H2_FONT>Matlab tests</td></tr></table>
     103<table $(echo $BODY_STYLE) style="border-collapse:collapse;">
     104$(if [ $CRASH_MATLAB -eq 0 ]; then
     105echo "<tr><td $BODY_FONT>status: <span style=\"color:#008000\">all test desks have been run</span></td></tr>"
     106else
     107        echo "<tr><td $BODY_FONT>status: <span style=\"color:#ff0000\">Matlab crashed</span></td></tr>"
     108fi)
     109<tr><td $BODY_FONT>Total execution time: $EL_PYTHON</td></tr>
     110<tr><td $BODY_FONT>Number of successes: $NUM_MATLAB_SUC/$NUM_MATLAB_TOT</td></tr>
     111<tr><td $BODY_FONT>Number of errors: $NUM_MATLAB_ERR/$NUM_MATLAB_TOT</td></tr>
     112<tr><td $BODY_FONT>Number of failures: $NUM_MATLAB_FAI/$NUM_MATLAB_TOT</td></tr>
     113</table>
     114END
     115#}}}
     116fi
     117
     118#2. python report
     119if [ $IS_PYTHON -eq 1 ]; then
     120#Process python_log.log {{{
     121cat python_log.log        | egrep 'ERROR|SUCCESS|FAILURE' | grep -v "PETSC" | sed -e "s/>/\&gt;/g" | sed -e "s/</\&lt;/g" > python.log
     122cat python.log        | grep -v "SUCCESS" > python_short.log
     123cat python_log.log        | grep "PETSC" | sed -e "s/>/\&gt;/g" | sed -e "s/</\&lt;/g" > petscerror.log
     124NUM_PYTHON_TOT=$(wc -l python.log | awk '{print $1}')
     125NUM_PYTHON_ERR=$(cat python.log | grep 'ERROR'   | grep -v "PETSC" | wc -l)
     126NUM_PYTHON_SUC=$(cat python.log | grep 'SUCCESS' | wc -l)
     127NUM_PYTHON_FAI=$(cat python.log | grep 'FAILURE' | wc -l)
     128#}}}
     129#write report {{{
     130cat << END >> report.html
     131<table $H2_STYLE><tr><td $H2_FONT>Python tests</td></tr></table>
     132<table $(echo $BODY_STYLE) style="border-collapse:collapse;">
     133$(if [ $CRASH_PYTHON -eq 0 ]; then
     134        echo "<tr><td $BODY_FONT>status: <span style=\"color:#008000\">all test desks have been run</span></td></tr>"
     135else
     136        echo "<tr><td $BODY_FONT>status: <span style=\"color:#ff0000\">Python crashed</span></td></tr>"
     137fi)
     138<tr><td $BODY_FONT>Total execution time: $EL_PYTHON</td></tr>
     139<tr><td $BODY_FONT>Number of successes: $NUM_PYTHON_SUC/$NUM_PYTHON_TOT</td></tr>
     140<tr><td $BODY_FONT>Number of errors: $NUM_PYTHON_ERR/$NUM_PYTHON_TOT</td></tr>
     141<tr><td $BODY_FONT>Number of failures: $NUM_PYTHON_FAI/$NUM_PYTHON_TOT</td></tr>
     142</table>
     143END
     144#}}}
     145fi
     146
     147#3. Matlab and python tables
     148if [ $IS_MATLAB -eq 1 ]; then
     149#Matlab{{{
     150#display table ONLY if installation worked and there has been at leat one FAILURE or ERROR
     151if [ $IS_INSTALL -eq 1 ] && [ $NUM_MATLAB_TOT -gt 1 ] && [ $NUM_MATLAB_SUC -ne $NUM_MATLAB_TOT ]
    111152then
    112         if [ $CRASH_MATLAB -eq 0 ];
    113         then
    114                 cat summary.html | sed -e "s/STATUS/<span style=\"color:#008000\">all test desks have been run<\/span>/g" > summary2.html
    115         else
    116                 cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation successful but Matlab crashed<\/span>/g" > summary2.html
    117         fi
    118 else
    119         cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation failed<\/span>/g" > summary2.html
    120 fi
    121 mv summary2.html summary.html
    122 
    123 #report table
    124 if [ $IS_TABLE -eq 1 ];
    125 then
    126         cat << END > content.html
    127 <table $(echo $H2_STYLE)><tr><td $(echo $H2_FONT)>List of tests</td></tr></table>
     153        cat << END >> report.html
     154<table $(echo $H2_STYLE)><tr><td $(echo $H2_FONT)>List of Matlab tests</td></tr></table>
    128155<table $(echo $BODY_STYLE) style="border-collapse:collapse;">
    129156<tr>
     
    175202<br>
    176203END
    177 else
    178         mktemp content.html
    179 fi
    180 
    181 #Matlab error report
    182 if [ -e matlaberror.log ]
     204fi
     205#}}}
     206fi
     207if [ $IS_PYTHON -eq 1 ]; then
     208#python{{{
     209#display table ONLY if installation worked and there has been at leat one FAILURE or ERROR
     210if [ $IS_INSTALL -eq 1 ] && [ $NUM_PYTHON_TOT -gt 1 ] && [ $NUM_PYTHON_SUC -ne $NUM_PYTHON_TOT ]
    183211then
    184         cat << END > matlaberror.html
     212        cat << END >> report.html
     213        <table $(echo $H2_STYLE)><tr><td $(echo $H2_FONT)>List of Python tests</td></tr></table>
     214        <table $(echo $BODY_STYLE) style="border-collapse:collapse;">
     215        <tr>
     216        <th $(echo $BODY_FONT)>Result</th>
     217        <th $(echo $BODY_FONT)>Tolerance</th>
     218        <th $(echo $BODY_FONT)>Test id</th> 
     219        <th $(echo $BODY_FONT)>Test name</th>
     220        <th $(echo $BODY_FONT)>Field checked</th>
     221        </tr>
     222        $(cat matlab_short.log | while read line
     223do
     224        echo "<tr>"
     225
     226        #get status
     227        STATUS=`echo $line | awk '{print $1}'`
     228
     229        #FAILURE
     230        if [ "$STATUS" = "FAILURE" ]
     231        then
     232
     233                FONTC=$(echo "$BODY_FONTC bgcolor=#ffff00");
     234                FONTL=$(echo "$BODY_FONTL bgcolor=#ffff00");
     235                echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
     236                { 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);}
     237                ';
     238
     239        else
     240
     241                #SUCCESS
     242                if [ "$STATUS" = "SUCCESS" ]
     243                then
     244                        FONTC=$(echo "$BODY_FONTC bgcolor=#ddffdd")
     245                        FONTL=$(echo "$BODY_FONTL bgcolor=#ddffdd")
     246                        #do not write anything
     247                        #ERROR
     248                else
     249                        FONTC=$(echo "$BODY_FONTC bgcolor=#ffdddd id=ERROR")
     250                        FONTL=$(echo "$BODY_FONTL bgcolor=#ffdddd")
     251                        echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
     252                        { 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);}
     253                        ';
     254                fi
     255
     256        fi
     257        echo "</tr>"
     258done
     259)
     260</table>
     261<br>
     262END
     263fi
     264#}}}
     265fi
     266
     267#4. Error report
     268if [ $IS_MATLAB -eq 1 ]; then
     269#Matlab {{{
     270cat << END >> report.html
    185271<table $H2_STYLE><tr><td $H2_FONT>Matlab errors</td></tr></table>
    186272<table $MATLAB_STYLE><tr><td $MATLAB_FONT>
     
    194280</td></tr></table>
    195281END
    196 else
    197         mktemp matlaberror.html
    198 fi
    199 
    200 #Matlab error report
     282#}}}
     283fi
    201284if test -s petscerror.log
    202285then
    203         cat << END > petscerror.html
     286        #PETSc{{{
     287cat << END >> report.html
    204288<table $H2_STYLE><tr><td $H2_FONT>PETSc errors</td></tr></table>
    205289<table $MATLAB_STYLE><tr><td $MATLAB_FONT>
     
    213297</td></tr></table>
    214298END
    215 else
    216         mktemp petscerror.html
    217 fi
    218 
    219 #last footer
    220 cat << END > footer.html
     299#}}}
     300fi
     301
     302#last: footer
     303#{{{
     304cat << END >> report.html
    221305<br>
    222306<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>
    223307</div>
    224308END
    225 
    226 #concatenate files
    227 cat summary.html content.html matlaberror.html petscerror.html footer.html > report.html
    228 rm  summary.html content.html footer.html matlaberror.html petscerror.html matlab.log
     309#}}}
Note: See TracChangeset for help on using the changeset viewer.