• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1if [ $# -ne 1 ];then
2    echo Please input $0 [report dir]
3    exit 1
4fi
5
6REPORT=$1
7if [ ! -e ${REPORT} ];then
8    echo "The directory of ${REPORT} dose't not exit,please check the test log"
9    exit 1
10fi
11
12UT_Failed_Num=0
13parse_unittest() {
14    res=$1
15    echo ${res}
16    echo Start to parse unittest results of $res
17    if [ -e $res ];then
18    tests=`cat $res | grep "<testsuites" | awk -F " " '{print $2;}' | awk -F "\"" '{print $2;}'`
19    fails=`cat $res | grep "<testsuites" | awk -F " " '{print $3;}' | awk -F "\"" '{print $2;}'`
20    times=`cat $res | grep "<testsuites" | awk -F " " '{print $6;}' | awk -F "\"" '{print $2;}'`
21    waste=`cat $res | grep "<testsuites" | awk -F " " '{print $7;}' | awk -F "\"" '{print $2;}'`
22    msg="Total testcases: $tests, failed: $fails,time:$waste seconds, at$times,xml:$res"
23    echo ${msg}
24    UT_Failed_Num=$((${UT_Failed_Num}+${fails}))
25cat >> mail.log << EOF
26<style>
27.fail {
28    background-color: yellow;
29}
30</style>
31<br>
32   <table  style="width:600px" cellspacing="0" border="1" width="100%">
33    <thead>
34    <tr>
35        <td>Total unit test cases</td>
36        <td>Failed</td>
37        <td>Time</td>
38        <td>Date</td>
39    </tr>
40    </thead>
41       <tbody>
42        <tr style="text-align:center; font-weight: bold;">
43            <td>${tests}</td>
44            <td><font class="fail">${fails}</font></td>
45            <td>${waste}</td>
46            <td>${times}</td>
47        </tr>
48    </tbody>
49    </table>
50<br>
51EOF
52   fi
53}
54
55xmlcount=`ls $REPORT | wc -l`
56xmlfiles=`ls $REPORT`
57if [ ${xmlcount} -eq 0 ];
58then echo There is nothing xml files generated at $REPORT
59    exit 1
60fi
61for file in $xmlfiles;do
62   parse_unittest $REPORT/$file
63done
64if [ ${UT_Failed_Num} = "0" ];then
65echo Total $xmlcount files at $REPORT,all sucessful
66exit 0
67else
68echo Total $xmlcount files at $REPORT,${UT_Failed_Num} error cases
69exit 2
70fi
71