ref: b53f8909de7651216cecd70d00f32863b098815e
dir: /autotest/unitTest/run_ParseUTxml.sh/
if [ $# -ne 1 ];then echo Please input $0 [report dir] exit 1 fi REPORT=$1 if [ ! -e ${REPORT} ];then echo "The directory of ${REPORT} dose't not exit,please check the test log" exit 1 fi UT_Failed_Num=0 parse_unittest() { res=$1 echo Start to parse unittest results of $res if [ -e $res ];then tests=`cat $res | grep "<testsuites" | awk -F " " '{print $2;}' | awk -F "\"" '{print $2;}'` fails=`cat $res | grep "<testsuites" | awk -F " " '{print $3;}' | awk -F "\"" '{print $2;}'` times=`cat $res | grep "<testsuites" | awk -F " " '{print $6;}' | awk -F "\"" '{print $2;}'` waste=`cat $res | grep "<testsuites" | awk -F " " '{print $7;}' | awk -F "\"" '{print $2;}'` msg="Total testcases: $tests, failed: $fails,time:$waste seconds, at$times,xml:$res" echo $msg UT_Failed_Num=$[${UT_Failed_Num}+${fails}] fi } xmlcount=`ls $REPORT | wc -l` xmlfiles=`ls $REPORT` if [ ${xmlcount} -eq 0 ]; then echo There is nothing xml files generated at $REPORT exit 1 fi for file in $xmlfiles;do parse_unittest $REPORT/$file done if [ ${UT_Failed_Num} = "0" ];then echo Total $xmlcount files at $REPORT,all sucessful exit 0 else echo Total $xmlcount files at $REPORT,${UT_Failed_Num} error cases exit 2 fi