[TCT][scripts_tpk][NonACR][DPTTIZEN-2674: Modified tpk build script and added new...
authorShilpa Jindal <shilpa.j@samsung.com>
Tue, 6 Dec 2016 11:20:25 +0000 (16:50 +0530)
committerSatyajit Anand <satyajit.a@samsung.com>
Tue, 6 Dec 2016 11:33:29 +0000 (03:33 -0800)
Change-Id: Ib6c017c8a9c248d2de7918c3e4fc12d8c57b8c9f
Signed-off-by: Shilpa Jindal <shilpa.j@samsung.com>
scripts_tpk/external_wrapper_coverage.sh [new file with mode: 0644]
scripts_tpk/tpk-install.py
scripts_tpk/tpkbuild.sh
scripts_tpk/tpksdk-install.py

diff --git a/scripts_tpk/external_wrapper_coverage.sh b/scripts_tpk/external_wrapper_coverage.sh
new file mode 100644 (file)
index 0000000..20b81b5
--- /dev/null
@@ -0,0 +1,166 @@
+
+
+#!/bin/bash
+#
+# Copyright (c) 2014 Samsung Electronics Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http:#www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+TIMEOUT_VALUE=60 #default timeout value
+FILE="/tmp/TC_Timeout.txt"
+SCRIPT_DIR="/home/owner/share"
+
+# extract TCT configuration directory from TCT_CONFIG_FILE (/tmp/TCT_CONFIG)
+TCT_CONFIG_FILE=/tmp/TCT_CONFIG
+if [ ! -f $TCT_CONFIG_FILE ];then
+       echo "$TCT_CONFIG_FILE is not Found : Can Not Read TCT Configuration File to get Execution Mode"
+       exit 1;
+fi
+DEVICE_EXECUTION_MODE_30=`cat $TCT_CONFIG_FILE | grep DEVICE_EXECUTION_MODE_30 | cut -f 2- -d '='`
+if [ $DEVICE_EXECUTION_MODE_30 == "" ]; then
+       echo "'DEVICE_EXECUTION_MODE_30' key-value pair is not Found in $TCT_CONFIG_FILE. Unable to get Execution Mode"
+       exit 1;
+fi
+
+if [[ "$1" == "" || "$2" == "" || "$3" == "" ]];
+then
+    echo "module name, TC name and build type type needed"
+    exit 1
+fi
+
+TIME_FACTOR=10
+RESULT_PATH=/tmp/tcresult
+ERRLOG_PATH=/tmp/tclog
+UTC_LOG=/tmp/utclog
+UTC_LOG_CORE=/tmp/utclog_core
+
+DIR_COV1=/tmp/usr
+DIR_COV2=/tmp/home
+DIR_COV3=/home/abuild
+DIR_COV4=/usr/src
+
+#Read timeout value from /tmp/TCT_Timeout.txt file
+if [ -f $FILE ];
+then
+       for next in `cat $FILE`
+       do
+           TIMEOUT_VALUE=$next
+       done
+fi
+
+if [ -d $DIR_COV1 ];
+then
+       chsmack -a "*" $(find $DIR_COV1 -type d)
+fi
+
+if [ -d $DIR_COV2 ];
+then
+       chsmack -a "*" $(find $DIR_COV2 -type d)
+fi
+
+if [ -d $DIR_COV3 ];
+then
+       chsmack -a "*" $(find $DIR_COV3 -type d)
+fi
+
+if [ -d $DIR_COV4 ];
+then
+       chsmack -a "*" $(find $DIR_COV4 -type d)
+fi
+
+function KillPackage {
+       pkgcmd --kill -n $1
+       sleep 2
+}
+
+
+function Execute {
+       rm -f $RESULT_PATH
+       rm -f $ERRLOG_PATH
+       rm -f $UTC_LOG
+       rm -f $UTC_LOG_CORE
+
+       ## pre-launch script
+       if [ -f $SCRIPT_DIR/pre_launch.sh ];
+       then
+               bash $SCRIPT_DIR/pre_launch.sh $1 $2
+       fi
+
+       RET=`su -c "app_launcher -s $1 testcase_name $2" $DEVICE_EXECUTION_MODE_30`
+       if [[ $RET != *"successfully launched"* ]];then
+               echo "Launch Failed"
+               su -c "app_launcher -s $1 > /dev/null" $DEVICE_EXECUTION_MODE_30
+               exit 1
+       fi
+       ## post-launch script
+       if [ -f $SCRIPT_DIR/post_launch.sh ];
+       then
+               bash $SCRIPT_DIR/post_launch.sh $1 $2
+       fi
+
+
+       COUNTER=0
+
+       while [ ! -e $RESULT_PATH ];
+       do
+               if [ $COUNTER -eq $TIMEOUT_VALUE ];
+               then
+                       # terminate launched application
+                       su -c "app_launcher -s $1 > /dev/null" $DEVICE_EXECUTION_MODE_30
+                       echo "Timeout! [ Execution exceeded $TIMEOUT_VALUE seconds ]"
+                       if [ -e $ERRLOG_PATH ];
+                       then
+                               echo `cat $ERRLOG_PATH`
+                               rm -f $ERRLOG_PATH
+                       fi
+                       if [ -e $UTC_LOG_CORE ];
+                       then
+                               echo `cat $UTC_LOG_CORE`
+                               rm -f $UTC_LOG_CORE
+                       fi
+                       alive=`su -c "app_launcher -r $1" $DEVICE_EXECUTION_MODE_30 | grep "not"`
+                       if [ "$alive" == "" ]; then
+                               su -c "app_launcher -t $1 > /dev/null" $DEVICE_EXECUTION_MODE_30
+                       fi
+
+                       su -c "app_launcher -s $1 > /dev/null" $DEVICE_EXECUTION_MODE_30
+                       exit 1
+               fi
+               sleep 1
+               COUNTER=$(($COUNTER + 1))
+       done
+
+       if [ -e $ERRLOG_PATH ];
+       then
+               echo `cat $ERRLOG_PATH`
+               rm -f $ERRLOG_PATH
+       fi
+       if [ -e $UTC_LOG_CORE ];
+       then
+               echo `cat $UTC_LOG_CORE`
+               rm -f $UTC_LOG_CORE
+       fi
+       alive=`su -c "app_launcher -r $1" $DEVICE_EXECUTION_MODE_30 | grep "not"`
+       if [ "$alive" == "" ]; then
+               su -c "app_launcher -t $1 > /dev/null" $DEVICE_EXECUTION_MODE_30
+       fi
+       exit `cat $RESULT_PATH`
+}
+
+
+Execute $1 $2
+
+
+
+
index e2774046888f3e39ca413b05824f14f879f3b917..8f5a57ca45f489cb84e9d5288e12e0a39eddc308 100755 (executable)
@@ -55,7 +55,8 @@ def removeDir(path):
 
        return True
 
-def install(TYPE, MODNAME, PROFILE, TC_COUNT, ARCH):
+def install(TYPE, MODNAME, PROFILE, TC_COUNT, ARCH, COVERAGE):
+       
        rpmCheck=False
        global INSTALL_PKG_COUNT
        if ( TYPE == None ):
@@ -114,7 +115,9 @@ def install(TYPE, MODNAME, PROFILE, TC_COUNT, ARCH):
                        #       scripts_tpk/inst.sh > /tmp/'+TCT_DIR+'/inst.sh')
                        src_f=open('scripts_tpk'+dirSeparator+'inst.sh')
                        dest_f=open(dirSeparator+'tmp'+dirSeparator+TCT_DIR+dirSeparator+'inst.sh', 'w')
+                       
                        for line in src_f:
+                       
                                pkg_dir_m=re.search('^\sPKG_DIR=(?P<pkg_dir>%{PKG_DIR})', line)
                                pkg_name_m=re.search('^\sPKG_NAME=(?P<pkg_name>%{PKG_NAME})', line)
                                pkg_fname_m=re.search('^\sPKG_FULLNAME=(?P<pkg_fname>%{PKG_FULLNAME})', line)
@@ -125,6 +128,7 @@ def install(TYPE, MODNAME, PROFILE, TC_COUNT, ARCH):
                                        line=line.replace('%{PKG_NAME}', '"'+PKG_NAME+'"')
                                elif ( pkg_fname_m != None ):
                                        line=line.replace('%{PKG_FULLNAME}', '"'+PKG_FNAME+'"')
+                       
 
                                dest_f.write(line)
                        src_f.close()
@@ -144,15 +148,19 @@ def install(TYPE, MODNAME, PROFILE, TC_COUNT, ARCH):
                                sys.exit('Aborting...')
                        
                        # external_wrapper.sh
+               
                        process_dali_application = "dali-application"
                        process = "dali"
                        if ( re.search(process_dali_application, MODNAME) != None ):
                                shutil.copy('scripts_tpk'+dirSeparator+'external_wrapper_dali_app_launch.sh', dirSeparator+'tmp'+dirSeparator+TCT_DIR+dirSeparator+'external_wrapper.sh')
                        elif ( re.search(process, MODNAME) != None ):
                                shutil.copy('scripts_tpk'+dirSeparator+'external_wrapper_dali_binary_launch.sh', dirSeparator+'tmp'+dirSeparator+TCT_DIR+dirSeparator+'external_wrapper.sh')
+                       elif ( COVERAGE == '1' ):
+                               print('-- Using Coverage Wrapper...')
+                               shutil.copy('scripts_tpk'+dirSeparator+'external_wrapper_coverage.sh', dirSeparator+'tmp'+dirSeparator+TCT_DIR+dirSeparator+'external_wrapper.sh')
                        else:
                                shutil.copy('scripts_tpk'+dirSeparator+'external_wrapper.sh', dirSeparator+'tmp'+dirSeparator+TCT_DIR)
-
+                       
                        # LICENSE, add_all_smack_rule.sh, all_smack.rule
                        shutil.copy('scripts_tpk'+dirSeparator+'LICENSE', dirSeparator+'tmp'+dirSeparator+TCT_DIR)
 
@@ -215,6 +223,7 @@ module=None
 build_ctype=None
 profile=None
 tc_count=None
+is_coverage=0
 INSTALL_PKG_COUNT=0
 
 ### script starts here ###
@@ -238,6 +247,8 @@ if ( len(sys.argv) >= 5 ):
        build_ctype=sys.argv[4]
 if ( len(sys.argv) >= 6 ):
        module=sys.argv[5]
+if ( len(sys.argv) >= 7 ):
+       is_coverage=sys.argv[6]
 
 if ( os.path.exists('install.log') ):
        os.remove('install.log')
@@ -247,7 +258,7 @@ instLog.write('**********************************************\n')
 instLog.write('Following packages get installed successfully:\n')
 instLog.close()
 
-install(build_ctype, module, profile,tc_count, arch)
+install(build_ctype, module, profile,tc_count, arch, is_coverage)
 
 if ( module == None ):
        instLog=open('install.log', 'a')
index a66effed6ef7c12d068484d076a2c177ff3f22ff..8dee34d95dc09e04aca32340c1e4c9eed92f8c3a 100755 (executable)
@@ -150,6 +150,32 @@ function install {
                cd $PWD
        fi
 }
+function install_coverage {
+
+       TC_TYPE=$1
+       MOD_NAME=$2
+    TC_COUNT=1
+       IS_COVERAGE=1
+
+       if [ "$ARCH_TYPE" == "arm" ] || [ "$ARCH_TYPE" == "aarch64" ] ; then
+               ln -sf ./scripts_tpk/tpk-install.py $PWD/tpk-install
+               python tpk-install $ARCH_TYPE $PROFILE_TYPE $TC_COUNT $TC_TYPE $MOD_NAME $IS_COVERAGE
+       elif [ "$ARCH_TYPE" == "x86" ] || [ "$ARCH_TYPE" == "x86_64" ] ; then
+               ln -sf ./scripts_tpk/tpksdk-install.py $PWD/tpksdk-install
+               python tpksdk-install $ARCH_TYPE $PROFILE_TYPE $TC_COUNT $TC_TYPE $MOD_NAME $IS_COVERAGE
+       fi
+
+       if [ $INSTALL_CHILD == 1 ]; then 
+               echo "------ Generating child packages..."
+               bash $PWD/scripts_tpk/child-package-generator.sh $TC_TYPE $MOD_NAME $PROFILE_TYPE $TC_CHILD_COUNT
+               if [ $? -ne 0 ]; then
+                       cd $PWD
+                       echo "------ child-package-generator script Failed to generate child packages"
+                       exit 1; 
+               fi
+               cd $PWD
+       fi
+}
 
 function install_custom {
 
@@ -237,6 +263,25 @@ elif [ "install" == "$1" ]; then
                helpusage
        fi
 
+elif [ "install_coverage" == "$1" ]; then
+       
+       if [ "$#" -eq  "3" ]; then
+               install_coverage
+       
+       elif  [ "$#" -eq  "4" ]; then
+               check_tc_type $2 $3 $4
+               install_coverage $TESTCASE_TYPE
+       
+       elif  [ "$#" -eq  "5" ]; then
+               check_tc_type $2 $3 $4 $5
+               MODULE_NAME=$3
+               install_coverage $TESTCASE_TYPE $MODULE_NAME
+       
+       else
+               echo "Entered wrong number of arguments"
+               helpusage
+       fi
+       
 elif [ "install_child" == "$1" ]; then
        
        INSTALL_CHILD=1
index 0ef63ba92815a0bf8b3bc159a3dad8359ffa7838..24f2427bfc2baa9a394620ae09ee8ab786ace5be 100755 (executable)
@@ -55,7 +55,7 @@ def removeDir(path):
 
        return True
 
-def install(TYPE, MODNAME, PROFILE, TC_COUNT, ARCH):
+def install(TYPE, MODNAME, PROFILE, TC_COUNT, ARCH, COVERAGE):
        rpmCheck=False
        global INSTALL_PKG_COUNT
        if ( TYPE == None ):
@@ -145,6 +145,9 @@ def install(TYPE, MODNAME, PROFILE, TC_COUNT, ARCH):
                                shutil.copy('scripts_tpk'+dirSeparator+'external_wrapper_dali_app_launch.sh', dirSeparator+'tmp'+dirSeparator+TCT_DIR+dirSeparator+'external_wrapper.sh')
                        elif ( re.search(process, MODNAME) != None ):
                                shutil.copy('scripts_tpk'+dirSeparator+'external_wrapper_dali_binary_launch.sh', dirSeparator+'tmp'+dirSeparator+TCT_DIR+dirSeparator+'external_wrapper.sh')
+                       elif ( COVERAGE == '1' ):
+                               print('-- Using Coverage Wrapper...')
+                               shutil.copy('scripts_tpk'+dirSeparator+'external_wrapper_coverage.sh', dirSeparator+'tmp'+dirSeparator+TCT_DIR+dirSeparator+'external_wrapper.sh')
                        else:
                                shutil.copy('scripts_tpk'+dirSeparator+'external_wrapper.sh', dirSeparator+'tmp'+dirSeparator+TCT_DIR)
 
@@ -210,8 +213,10 @@ module=None
 build_ctype=None
 profile=None
 tc_count=None
+is_coverage=0
 INSTALL_PKG_COUNT=0
 
+
 ### script starts here ###
 
 OS=platform.system()
@@ -233,6 +238,8 @@ if ( len(sys.argv) >= 5 ):
        build_ctype=sys.argv[4]
 if ( len(sys.argv) >= 6 ):
        module=sys.argv[5]
+if ( len(sys.argv) >= 7 ):
+       is_coverage=sys.argv[6]
 
 if ( arch == 'x86' ):
        arch='i386'
@@ -247,7 +254,7 @@ instLog.write('**********************************************\n')
 instLog.write('Following packages get installed successfully:\n')
 instLog.close()
 
-install(build_ctype, module, profile,tc_count, arch)
+install(build_ctype, module, profile,tc_count, arch, is_coverage)
 
 if ( module == None ):
        instLog=open('install.log', 'a')