#############################################################################
#!/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"
# @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 <all>"
echo "OR"
echo " To check coverage of specific package give full name or at least meaningful name, usage: `basename $0` coverage <package_name>"
+ echo " "
}
##############################################################################
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 <gnumeric> 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
}
##############################################################################
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`
return $ERROR
else
echo "Correct package name passed, Continue with coverage!!!"
+ COV_MOD_NAME=`ls $SOURCE_DIR | grep $1`
fi
fi
return $SUCCESS
###############################################################################
# @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
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<ALIGN_LENGTH ))
+ do
+ Path+=" "
+ num=$((num+1))
+ done
+ echo "$Path$newTCName"
+ else
+ if [[ $newTCName != $oldTCName ]]
+ then
+# 5 '\t' characters that amount to 40 spaces.
+ echo " $newTCName"
+ fi
+ fi
+ oldOutPath=$newOutPath
+ oldTCName=$newTCName
done < TC_List.txt
if ((apiCount<1))
then
- echo "[$APIName] not found"
+# NONE is followed by 5 '\t' characters in order to be consistent with the alignment process. The first '\t' character appends only 4 spaces.
+ echo "NONE NONE"
echo "$APIName, -, -, NO" >> $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
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
###############################################################################
# @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
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
# 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
then
mod_API_Name=0
excluded=0
- if [[ $1 = "all" ]]
+ if [[ $COV_MOD_NAME = "all" ]]
then
while IFS= read -r mod_API_Name
do
continue
else
Gen_TC_Files $module
- echo "API Name, File Name, TC Name, Coverage Status" > $COV_DIR/$module.csv
excluded=0
fi
else
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
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