From 501aace39e9c56ad3f8176dbf9ab10f9dabba447 Mon Sep 17 00:00:00 2001 From: Samuel Peter Date: Thu, 23 Aug 2018 16:05:00 +0530 Subject: [PATCH] [HAL-Test][Modified download-rpm logic to remove dependency on HAL-rpm.txt] Change-Id: I787a8e4dd8600cad585cd8dfb1021da8e9e7ee44 --- Res/HAL_rpm.txt | 15 ------ Res/Paths.txt | 1 - Scripts/download_code.sh | 8 +-- Scripts/download_rpm.sh | 136 ++++++++--------------------------------------- Scripts/execute.sh | 53 ++++++++++++++++-- hal_test.sh | 5 -- 6 files changed, 76 insertions(+), 142 deletions(-) delete mode 100644 Res/HAL_rpm.txt mode change 100755 => 100644 Scripts/download_rpm.sh diff --git a/Res/HAL_rpm.txt b/Res/HAL_rpm.txt deleted file mode 100644 index ad150e2..0000000 --- a/Res/HAL_rpm.txt +++ /dev/null @@ -1,15 +0,0 @@ -audio-haltests-0.0.13-11.1.armv7l.rpm -bluetooth-frwk-oal-haltests-0.3.0-45.1.armv7l.rpm -camera-haltests-0.0.13-11.1.armv7l.rpm -codec-haltests-0.0.13-11.1.armv7l.rpm -device-haltests-0.1.1-8.1.armv7l.rpm -libtapi-haltests-0.8.31-10.1.armv7l.rpm -libtbm-haltests-3.0.1-42.2.armv7l.rpm -libtdm-haltests-2.2.0-57.1.armv7l.rpm -mtp-initiator-haltests-1.4.30-19.1.armv7l.rpm -net-config-haltests-1.1.136-67.1.armv7l.rpm -nfc-manager-haltests-0.1.174-24.1.armv7l.rpm -pass-haltests-1.0.0-26.1.armv7l.rpm -radio-haltests-0.0.13-11.1.armv7l.rpm -wifi-mesh-manager-haltests-0.0.3-16.1.armv7l.rpm -zigbee-manager-haltests-0.1.2-16.1.armv7l.rpm diff --git a/Res/Paths.txt b/Res/Paths.txt index 2b548d3..17af14a 100644 --- a/Res/Paths.txt +++ b/Res/Paths.txt @@ -29,7 +29,6 @@ CONFIG_FILE="$RES_DIR/Config.txt" HAL_API_LIST="$RES_DIR/HAL_api_list.txt" HAL_CONF_FILE="$RES_DIR/gbs-haltest.conf" PRJ_LIST_FILE="$RES_DIR/HAL_project.txt" -RPM_LIST_FILE="$RES_DIR/HAL_rpm.txt" COMPLETED_TC_LIST="$PWD/comp_tc_list.txt" TMP_PRJ_LIST="$PWD/temp_prj_list.txt" COV_TEMP_DIR="$SOURCE_DIR/temp_folder" diff --git a/Scripts/download_code.sh b/Scripts/download_code.sh index f86d35b..db3f18c 100755 --- a/Scripts/download_code.sh +++ b/Scripts/download_code.sh @@ -225,7 +225,7 @@ Trigger_Download() #################################################################################################### Download_Code() { - nRet=$SUCCESS + nReturn=$SUCCESS MODULE=$1 COMMAND=$2 @@ -289,7 +289,7 @@ Download_Code() success_count=$((module_count-DownloadErrCnt)) echo "$success_count/$module_count modules code were downloaded successfully." if [ $DownloadErrCnt -eq $module_count ]; then - nRet=$ERROR + nReturn=$ERROR fi fi else @@ -297,12 +297,12 @@ Download_Code() Trigger_Download $MODULE $module $COMMAND if [ $? -eq $ERROR ] then - nRet=$ERROR + nReturn=$ERROR else mod=${module##*/} echo "Module [$mod] code downloaded successfully." fi fi - return $nRet + return $nReturn } diff --git a/Scripts/download_rpm.sh b/Scripts/download_rpm.sh old mode 100755 new mode 100644 index 5dcf122..469343f --- a/Scripts/download_rpm.sh +++ b/Scripts/download_rpm.sh @@ -21,8 +21,8 @@ ERROR=1 SUCCESS=0 NOMODULE=0 DownloadErrCnt=0 -success_count=0 module_count=0 +RPM_Name="-haltests-*.armv7l.rpm" PATH_FILE="$PWD/Res/Paths.txt" CONFIG_FILE="$PWD/Res/Config.txt" @@ -34,53 +34,6 @@ GIT_DOWN_CHECK_FILE="Git_Download_check.txt" WGET_LOG_FILE=tmpfile.txt ############################################################################## -# @function Help_Download -# @author SRID(j.abhishek) -# @reviewer SRID(shobhit.v) -# @description To display the usage of download function, -# if wrong name is passed. -# @parameter NA -# @return NA -############################################################################### -function Help_Download { - echo "Incorrect package name [$1] provided which does not exist in Res/HAL_rpm.txt file." | tee -a $DOWNLOAD_LOG/$DOWN_ERROR_FILE - echo "/**********************************************************************************************/" - echo " usage: ./hal_test.sh download " - echo " Example: ./hal_test.sh download libtdm" - echo " OR" - echo " ./hal_test.sh download all" - echo "/**********************************************************************************************/" - echo "To get the package name, refer to Res/HAL_rpm.txt file for package entry." | tee -a $DOWNLOAD_LOG/$DOWN_ERROR_FILE - DownloadErrCnt=1 - module_count=1 -} - -############################################################################## -# @function Check_Pkg_Name -# @author SRID(j.abhishek) -# @reviewer SRID(shobhit.v) -# @description To check if correct package name passed in download -# @parameter NA -# @return NA -############################################################################### -Check_Pkg_Name() -{ - if [ "all" == "$1" ]; then - echo "Continue with downloading for all packages." - else - res_count=`cat $RPM_LIST_FILE | grep $1 | wc -l` - if [ "$res_count" != "1" ] - then - Help_Download $1 - return $ERROR - else - echo "Correct package name passed, Continue with downloading." - fi - fi - return $SUCCESS -} - -############################################################################## # @function Init_Download # @author SRID(manu.tiwari) # @reviewer SRID(shobhit.v) @@ -114,18 +67,14 @@ function Init_Download # @reviewer SRID(shobhit.v) # @description Helper function of Download function # @parameter Option : all/modulename, RPM_name: rpm name to be downloaded -# @return If Success returns 0; -# If Fail returns 1 +# @return NA ################################################################################### Trigger_Download() { AUTHFAIL=0 WRONGURLFAIL=0 WRONGSERVERFAIL=0 - nRet=$SUCCESS - wget --spider --user=$SPIN_GIT_USER --password=$SPIN_GIT_PASSWORD $SPIN_GIT_URL 2>$DOWNLOAD_LOG/$GIT_DOWN_CHECK_FILE - WRONGURLFAIL=`cat $DOWNLOAD_LOG/$GIT_DOWN_CHECK_FILE | grep "404 Not Found" | wc -l` if [ $WRONGURLFAIL != $NOMODULE ]; then cat $DOWNLOAD_LOG/$GIT_DOWN_CHECK_FILE >> $DOWNLOAD_LOG/$DOWN_ERROR_FILE @@ -162,31 +111,20 @@ Trigger_Download() fi exit 1 fi - WRONGFILEFAIL=0 - wget --spider --user=$SPIN_GIT_USER --password=$SPIN_GIT_PASSWORD $SPIN_GIT_URL$2 2>$DOWNLOAD_LOG/$GIT_DOWN_CHECK_FILE - - WRONGFILEFAIL=`cat $DOWNLOAD_LOG/$GIT_DOWN_CHECK_FILE | grep "404 Not Found" | wc -l` - if [ $WRONGFILEFAIL != $NOMODULE ]; then - cat $DOWNLOAD_LOG/$GIT_DOWN_CHECK_FILE >> $DOWNLOAD_LOG/$DOWN_ERROR_FILE - echo "" - echo "[ERROR] $2 is not matching with the version present at server [Update the Res/HAL_rpm.txt file and run again]." | tee -a $DOWNLOAD_LOG/$DOWN_ERROR_FILE - if [ "all" == "$1" ]; then - ((DownloadErrCnt++)) - else - nRet=$ERROR - fi - else - wget -nd --user=$SPIN_GIT_USER --password=$SPIN_GIT_PASSWORD $SPIN_GIT_URL$2 2>$DOWNLOAD_LOG/$WGET_LOG_FILE - rm -rf $DOWNLOAD_LOG/$WGET_LOG_FILE - echo "[SUCCESS] $2 Downloaded successfully." - fi - if [ -f $DOWNLOAD_LOG/$GIT_DOWN_CHECK_FILE ]; then rm -rf $DOWNLOAD_LOG/$GIT_DOWN_CHECK_FILE fi - return $nRet + if [ "all" == $1 ]; then + RPM_Name="*$RPM_Name" + else + RPM_Name="$1$RPM_Name" + fi + wget --user=$SPIN_GIT_USER --password=$SPIN_GIT_PASSWORD -A $RPM_Name -r -l 1 -nd $SPIN_GIT_URL 2>>/dev/null + module_count=`ls $RPM_DIR | wc -l` + + find "$RPM_DIR" -type f -iname "*.html*" -delete } #################################################################################################### @@ -196,63 +134,35 @@ Trigger_Download() # @description Main function to be called from parent script to download all or specific module # @parameter all : To download all modules specified in Res/HAL_rpm.txt # module_name: To download specific module -# @return If Success returns 0; -# If Fail returns 1 +# @return NA #################################################################################################### Download() { - nRet=$SUCCESS - Init_Download $1 - Check_Pkg_Name $1 - if [ $? -eq $ERROR ] - then - return $ERROR - fi - module_count=0 - cd $RPM_DIR if [ "all" == "$1" ]; then - while IFS= read -r line - do - if [ -z "$line" ]; then - echo "[ERROR] Remove empty line from Res/HAL_rpm.txt and enter correct module names." | tee -a $DOWNLOAD_LOG/$DOWN_ERROR_FILE - else - ((module_count++)) - Trigger_Download $1 $line - fi - done < "$RPM_LIST_FILE" - - if [ $DownloadErrCnt -gt $NOMODULE ]; then - success_count=$((module_count-DownloadErrCnt)) - echo "$success_count/$module_count rpms were downloaded successfully." - nRet=$ERROR + Trigger_Download $1 + if [ $module_count -eq $NOMODULE ]; then + echo "No RPMs were downloaded." | tee -a $DOWNLOAD_LOG/$DOWN_ERROR_FILE + else + echo "Download completed for $module_count RPMs." fi else - module=`cat $RPM_LIST_FILE | grep $1` - Trigger_Download $1 $module - if [ $? -eq $ERROR ] - then - DownloadErrCnt=1 - module_count=1 - nRet=$ERROR + Trigger_Download $1 + if [ $module_count -eq $NOMODULE ]; then + echo "RPM not found for $1." | tee -a $DOWNLOAD_LOG/$DOWN_ERROR_FILE + else + Module_Full_Name=`ls $RPM_DIR | grep $1` + echo "Download completed for $Module_Full_Name" fi fi - - return $nRet } start=$(date +%s) Download $1 -if [ $? -eq $ERROR ] -then - echo "Download failed for $DownloadErrCnt/$module_count modules." | tee -a $DOWNLOAD_LOG/$DOWN_ERROR_FILE -else - echo "Download completed." -fi end=$(date +%s) execution_time=$( expr $end - $start ) diff --git a/Scripts/execute.sh b/Scripts/execute.sh index 4eb9838..e9a34d6 100755 --- a/Scripts/execute.sh +++ b/Scripts/execute.sh @@ -21,6 +21,7 @@ ERROR=1 SUCCESS=0 InstallErrCnt=0 ExecuteErrCnt=0 +device="" NOERROR=0 SUMMARY_GENERATION=$ERROR SINGLE_MOD_EXEC=$SUCCESS @@ -281,10 +282,11 @@ Init_Execute() ############################################################################### Is_Device_Connected() { - count=`sdb devices | wc -l` - if [ $count -eq 2 ] + devices=`sdb devices` + count=`grep -i 'device ' <<< $devices | wc -l` + if [ $count -eq 1 ] then - echo "Device attached." + device="${devices#*device }" else echo "No device attached." | tee -a $EXECUTE_LOG/$EXEC_ERROR_FILE return $ERROR @@ -545,6 +547,22 @@ Execute() if [ "all" == "$MODULE" ]; then for rpm in $(ls); do + count=`grep -i "tm1" <<< $rpm | wc -l` + if [ $count -eq 1 ]; then + #if [ $device == "TM1" ]; then + # Trigger_Execute $MODULE $rpm + #fi + continue + fi + + count=`grep -i "tw2" <<< $rpm | wc -l` + if [ $count -eq 1 ]; then + if [ $device == "TW2" ]; then + Trigger_Execute $MODULE $rpm + fi + continue + fi + Trigger_Execute $MODULE $rpm done if [ $InstallErrCnt -eq $RpmCnt ] || [ $ExecuteErrCnt -eq $RpmCnt ]; then @@ -557,7 +575,34 @@ Execute() else rpm=`ls $RPM_DIR | grep $MODULE` if [ -f "$rpm" ]; then - Trigger_Execute $MODULE $rpm + countTM1=`grep -i "tm1" <<< $rpm | wc -l` + countTW2=`grep -i "tw2" <<< $rpm | wc -l` + if [ $countTM1 -eq 1 ]; then + if [ $device == "TM1" ]; then + # Trigger_Execute $MODULE $rpm + # if [ $? -eq $ERROR ] + # then + # echo "Incorrect device attached" | tee -a $EXECUTE_LOG/$EXEC_ERROR_FILE + return $ERROR + # fi + else + echo "Incorrect device attached" | tee -a $EXECUTE_LOG/$EXEC_ERROR_FILE + return $ERROR + fi + elif [ $countTW2 -eq 1 ]; then + if [ $device == "TW2" ]; then + Trigger_Execute $MODULE $rpm + if [ $? -eq $ERROR ] + then + return $ERROR + fi + else + echo "Incorrect device attached" | tee -a $EXECUTE_LOG/$EXEC_ERROR_FILE + return $ERROR + fi + else + Trigger_Execute $MODULE $rpm + fi if [ $? -eq $ERROR ] then return $ERROR diff --git a/hal_test.sh b/hal_test.sh index ad0f9bd..2fa7863 100755 --- a/hal_test.sh +++ b/hal_test.sh @@ -118,11 +118,6 @@ function Check_Env echo "[ERROR] Basic environment file [Res/HAL_project.txt] is not present, clone the code again and run" exit 1 fi - - if [[ ! -f $RPM_LIST_FILE ]];then - echo "[ERROR] Basic environment file [Res/HAL_rpm.txt] is not present, clone the code again and run" - exit 1 - fi } SRC_DIR="$(cd "$(dirname $0)" && pwd)" -- 2.7.4