From: Samuel Peter Date: Tue, 10 Jul 2018 09:16:59 +0000 (+0530) Subject: [HAL-Test][Non-ACR][Modified coverage script for console log] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F22%2F183722%2F8;p=test%2Fhal%2Fapi.git [HAL-Test][Non-ACR][Modified coverage script for console log] Change-Id: I546546af30b9d104c4dceafe96a01e0b6401c9f2 Signed-off-by: Samuel Peter --- diff --git a/Res/Config.txt b/Res/Config.txt index 61bb46f..104d788 100644 --- a/Res/Config.txt +++ b/Res/Config.txt @@ -1,7 +1,7 @@ -USER=manu.tiwari -PASSWORD=samsung +USER= +PASSWORD= URL=http://165.213.149.200/download/public_mirror/tizen/unified/latest/repos/standard/packages/armv7l/ GTESTRPM=gtest-1.8.0-4.6.armv7l.rpm -GITUSER=abj3kor +GITUSER= GITURL=review.tizen.org GITBRANCH=tizen diff --git a/Scripts/coverage.sh b/Scripts/coverage.sh index 4685eb8..3371caf 100755 --- a/Scripts/coverage.sh +++ b/Scripts/coverage.sh @@ -15,11 +15,12 @@ ############################################################################# #!/bin/bash -PWD=`pwd` +PWD=`pwd` +COV_MOD_NAME="" ERROR=1 SUCCESS=0 - +ALIGN_LENGTH=40 PATH_FILE="$PWD/Res/Paths.txt" CONFIG_FILE="$PWD/Res/Config.txt" @@ -35,11 +36,13 @@ source $CONFIG_FILE # @return NA ############################################################################### function Help_Coverage { + echo " " echo "Make sure you have added/updated correct credentials in $CONFIG_FILE, if already done check below" echo "/**********************************************************************************************/" echo " To check coverage of all the packages, usage: `basename $0` coverage " echo "OR" echo " To check coverage of specific package give full name or at least meaningful name, usage: `basename $0` coverage " + echo " " } ############################################################################## @@ -85,6 +88,32 @@ function Cleanup_Coverage { rm -rf $LOGS_DIR rm -rf $SOURCE_DIR + + cd $COV_DIR + rm -rf *.csv +} + +############################################################################## +# @function Check_GNumeric_Pkg +# @author SRID(j.abhishek) +# @reviewer SRID(shobhit.v) +# @description To check gnumeric package availability on host PC +# @parameter NA +# @return If Success returns 0; +# If Fail returns 1 +############################################################################### +Check_GNumeric_Pkg() +{ + if which gnumeric | grep -q "gnumeric"; then + echo "gnumeric package already available on host-pc" + else + echo "Connect to Internet and Install package on host-pc using command" | tee -a $LOGS_DIR$COV_ERROR_FILE + echo "[1. sudo apt-get install gnumeric ]" | tee -a $LOGS_DIR$COV_ERROR_FILE + echo "[2. sudo updatedb ]" | tee -a $LOGS_DIR$COV_ERROR_FILE + echo "[ sync ]" | tee -a $LOGS_DIR$COV_ERROR_FILE + return $ERROR + fi + return $SUCCESS } ############################################################################## @@ -107,6 +136,7 @@ Check_Mod_Name() return $ERROR else echo "Continue with coverage check for all packages!!!" + COV_MOD_NAME="all" fi else res_count=`ls $SOURCE_DIR | grep $1 | wc -l` @@ -116,6 +146,7 @@ Check_Mod_Name() return $ERROR else echo "Correct package name passed, Continue with coverage!!!" + COV_MOD_NAME=`ls $SOURCE_DIR | grep $1` fi fi return $SUCCESS @@ -123,7 +154,7 @@ Check_Mod_Name() ############################################################################### # @function Find_APIs -# @author SRID(j.abhishek) +# @author SRID(samuel.peter) # @reviewer SRID(shobhit.v) # @description Helper function to find the API covered by which all TCs # @parameter APIName : API name got from the list to be checked @@ -140,33 +171,60 @@ Find_APIs() { return fi + echo "=======================================" + echo "$APIName" + echo "=======================================" + echo "File: TC Name" + grep -inr $APIName $SOURCE_DIR/modules > TC_List.txt apiCount=0 + oldOutPath="" + oldTCName="" while IFS= read -r outFileName - do - outPath="${outFileName%%:*}" - tcName="${outPath##*/}" - outPath="${outPath%/*}" - outPath="${outPath##*/}" + do + newOutPath="${outFileName%%:*}" + newTCName="${newOutPath##*/}" + newOutPath="${newOutPath%/*}" + newOutPath="${newOutPath##*/}" - echo "$APIName, $outPath, $tcName, YES" >> $COV_DIR/$module.csv + echo "$APIName, $newOutPath, $newTCName, YES" >> $COV_DIR/$module.csv apiCount=$((apiCount+1)) + if [[ $newOutPath != $oldOutPath ]] + then + num=${#newOutPath} + Path=$newOutPath + +# ALIGN_LENGTH is set to 40 in order to ensure that all the TC Names align vertically. The variable "num" takes into account the number of characters in the preceding string. The balance is filled with spaces. + while (( num> $COV_DIR/$module.csv - else - echo "[$APIName] found $apiCount times" fi } ############################################################################### # @function Splice_Files -# @author SRID(j.abhishek) +# @author SRID(samuel.peter) # @reviewer SRID(shobhit.v) # @description Helper function to break the single TC file according # to TC name, will be called from Gen_TC_Files function @@ -186,7 +244,7 @@ Splice_Files() { if [[ $line = "TEST_P"* || $line = "TEST_F"* || $line = "TEST"* ]] then sub="$(cut -d',' -f 2 <<< $line)" - sub=${sub:1:-1} + sub="$(cut -d')' -f 1 <<< $sub)" IFS= read -r line brackets=0 @@ -209,7 +267,7 @@ Splice_Files() { ############################################################################### # @function Gen_TC_Files -# @author SRID(j.abhishek) +# @author SRID(samuel.peter) # @reviewer SRID(shobhit.v) # @description Helper function to generate temporary txt file for each # TC which is covering APIs @@ -234,11 +292,35 @@ Gen_TC_Files() { mkdir "$SOURCE_DIR/modules/$module/$secFileName" Splice_Files $module $secFileName $fileName done <"$SOURCE_DIR"/tmpfile.txt + + echo "API Name, File Name, TC Name, Coverage Status" > $COV_DIR/$module.csv + echo "===================================================================================================================================================================================================" + echo "|| $module ||" + echo "===================================================================================================================================================================================================" +} + +############################################################################### +# @function Summarize_Report +# @author SRID(samuel.peter) +# @reviewer SRID(shobhit.v) +# @description Function to combine the resultant .csv files into one .xls file +# @parameter all : To check whether all reports should be merged to xls format, +# module_name: To check if a single report needs to be converted to xls format +# @return NA +############################################################################### +Summarize_Report() { + cd $COV_DIR + if [[ $1 == "all" ]] + then + ssconvert --merge-to=summary.xls *.csv + else + ssconvert *.csv summary.xls + fi } ############################################################################### # @function Coverage -# @author SRID(j.abhishek) +# @author SRID(samuel.peter) # @reviewer SRID(shobhit.v) # @description Main function to be called from parent script to check # coverage of all or specific module @@ -246,9 +328,15 @@ Gen_TC_Files() { # module_name: To check coverage of specific module # @return If Success returns 0; # If Fail returns 1 -#################################################################################################### +############################################################################### Coverage() { + Check_GNumeric_Pkg + if [ $? -eq $ERROR ] + then + return $ERROR + fi + Init_Coverage $1 bash $SCRIPT_DIR/download_code.sh $1 @@ -258,7 +346,7 @@ Coverage() then mod_API_Name=0 excluded=0 - if [[ $1 = "all" ]] + if [[ $COV_MOD_NAME = "all" ]] then while IFS= read -r mod_API_Name do @@ -272,7 +360,6 @@ Coverage() continue else Gen_TC_Files $module - echo "API Name, File Name, TC Name, Coverage Status" > $COV_DIR/$module.csv excluded=0 fi else @@ -282,28 +369,22 @@ Coverage() fi fi done <"$HAL_API_LIST" + else while IFS= read -r mod_API_Name do - if [[ $mod_API_Name != "Module:$1"* ]] + if [[ $mod_API_Name != "Module:$COV_MOD_NAME"* ]] then continue else module="$(cut -d':' -f 2 <<<$mod_API_Name)" module=${module:0:-1} - if cat $EXCLUDE_LIST | grep -q -x $module - then - break - else - Gen_TC_Files $module - echo "$1, -, -, -" > $COV_DIR/$module.csv - echo "API Name, File Name, TC Name, Coverage Status" > $COV_DIR/$module.csv - while IFS= read -r mod_API_Name && [[ $mod_API_Name != "=="* && $mod_API_Name != "Module:"* ]] - do - Find_APIs $mod_API_Name $module - done - break - fi + Gen_TC_Files $module + while IFS= read -r mod_API_Name && [[ $mod_API_Name != "=="* && $mod_API_Name != "Module:"* ]] + do + Find_APIs $mod_API_Name $module + done + break fi done <"$HAL_API_LIST" fi @@ -317,9 +398,9 @@ Coverage() Coverage $1 if [ $? -eq $ERROR ] then - echo "Error in checking Coverage !!!!!!" | tee -a $LOGS_DIR$EXEC_ERROR_FILE + echo "Error in checking Coverage !!!!!!" | tee -a $LOGS_DIR$COV_ERROR_FILE else echo "Coverage check completed..!!" fi - +Summarize_Report $1 Cleanup_Coverage diff --git a/Scripts/download_code.sh b/Scripts/download_code.sh index d12f1a9..6c71890 100755 --- a/Scripts/download_code.sh +++ b/Scripts/download_code.sh @@ -144,7 +144,7 @@ Trigger_Download() git clone -b $GITBRANCH $GITPATH 2>$LOGS_DIR$DOWN_ERROR_FILE if cat $LOGS_DIR$DOWN_ERROR_FILE | grep -q "fatal: Could not read from remote repository."; then - echo "$2 Issue with Credential/Project Name/Network [Update the HAL_project.txt file and also check internet connection]" | tee -a $LOGS_DIR$DOWN_ERROR_FILE + echo "Issue with Credential/Project Name/Network for $2 [Update the HAL_project.txt file and also check internet connection]" | tee -a $LOGS_DIR$DOWN_ERROR_FILE if [ "all" == "$1" ]; then ((DownloadErrCnt++)) else