[tools][non-acr][Updated config device] 21/206021/1
authorSanghoon Lee <shooney.lee@samsung.com>
Mon, 13 May 2019 08:48:09 +0000 (17:48 +0900)
committerSanghoon Lee <shooney.lee@samsung.com>
Mon, 13 May 2019 08:48:09 +0000 (17:48 +0900)
Change-Id: Ie17d71844b8c3e728010852d813d20be9dfcaefb

release/csharp-tct_5.5_dotnet/csharp-tct_5.5_dotnet/tools/tct-config-device.py

index d573c94..9c51077 100755 (executable)
-#!/usr/bin/python\r
-\r
-"""Usage:\r
-         tct-config-device.py [--install [--deviceid <serial_no>]]\r
-         tct-config-device.py --purge [--deviceid <serial_no>]\r
-         tct-config-device.py --check [--deviceid <serial_no>][--procid <process_name>]\r
-         tct-config-device.py --bhtest <profile>\r
-\r
-Options:\r
-  -h, --help         show this help message and exit\r
-  --install          Install tct resources to TIZEN device,it can be omitted\r
-  --purge            Clean up tct resources from TIZEN device\r
-  --check            Check test resource on device\r
-  --bhtest           Install tct behavior test\r
-  --deviceid         Set the device serial number\r
-  --procid           Set the check process name\r
-\r
-"""\r
-import os\r
-import sys\r
-import time\r
-import ConfigParser\r
-import threading\r
-import subprocess\r
-\r
-\r
-from optparse import OptionParser\r
-from devicemanager import DeviceManager\r
-from sdbmanager import SdbManager\r
-\r
-JOIN = os.path.join\r
-EXISTS = os.path.exists\r
-DIRNAME = os.path.dirname\r
-BASENAME = os.path.basename\r
-ABSPATH = os.path.abspath\r
-SPLIT = os.path.split\r
-\r
-CURENT_DIR = SPLIT(DIRNAME(ABSPATH(__file__)))[0]\r
-\r
-TOOLS_DIR = JOIN(CURENT_DIR, "tools")\r
-RESRC_DIR = JOIN(CURENT_DIR, "resource")\r
-PKGS_DIR = JOIN(CURENT_DIR, "package")\r
-\r
-DEVID = ""\r
-\r
-TIZENV = "tizen_5.5"\r
-\r
-DLOG_CLEAR = "dlogutil -c"\r
-DLOG_UTIL = "sdb -s %s shell dlogutil -v time"\r
-\r
-TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"\r
-tct_parser = ConfigParser.ConfigParser()\r
-tct_parser.read(TCT_CONFIG_FILE)\r
-\r
-DEVICE_SUITE_TARGET_24 = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_24')\r
-DEVICE_SUITE_TARGET_30 = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')\r
-DEVICE_EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30')\r
-\r
-if TIZENV.find('tizen_5.5') > -1:\r
-    DEVICE_SUITE_TARGET = DEVICE_SUITE_TARGET_30\r
-else:\r
-    DEVICE_SUITE_TARGET = DEVICE_SUITE_TARGET_24\r
-\r
-def LS(root, file_name, extension=None):\r
-    import glob\r
-\r
-    file_path = ""\r
-    if extension:\r
-        file_path = JOIN(root, file_name) + "*." + extension\r
-    else:\r
-        file_path = JOIN(root, file_name) + "*"\r
-    files = glob.iglob(r'' + file_path + '')\r
-    for f in files:\r
-        return BASENAME(f)\r
-\r
-def get_device_arch():\r
-    global DEV_ARCH\r
-    #ARCHCMD = SDB_SERNO + " shell \"cat /etc/products.d/tizen.prod |grep \<arch\""\r
-    arch_cmd = "cat /etc/config/model-config.xml | grep tizen.org/feature/platform.core.cpu.arch"\r
-    #result example : <key name="tizen.org/feature/platform.core.cpu.arch" type="string">armv7</key>\r
-    result = SdbManager.sdbShell(DEVID, arch_cmd)\r
-    if result and len(result) > 0:\r
-        arch_str = result.split('\n')[0]\r
-        if arch_str and arch_str.find('armv7') > -1:\r
-            DEV_ARCH = "arm"\r
-            print "info: [* Arch Type : arm *]"\r
-        elif arch_str and arch_str.find("aarch64") > -1:\r
-            DEV_ARCH = "aarch64"\r
-            print "info: [* Arch Type : aarch64 *]"\r
-        elif arch_str and arch_str.find('x86_64') > -1:\r
-            DEV_ARCH = "ia64"\r
-            print "info: [* Arch Type : ia64 *]"\r
-        elif arch_str and (arch_str.find("i686") > -1 or arch_str.find("x86") > -1 or arch_str.find("i386") > -1):\r
-            DEV_ARCH = "ia"\r
-            print "info: [* Arch Type : ia *]"\r
-        else:\r
-            print "info: [* Arch Type : None *]"\r
-            return False\r
-        return True\r
-    else:\r
-        print "#ERROR#: Failed to get device cpu_arch type"\r
-        return False\r
-\r
-\r
-def kill_process(process_name):\r
-    proc_cmd = "ps aux | grep " + process_name + " | grep -v grep | awk '{print $2}'"\r
-    result = SdbManager.sdbShell(DEVID, proc_cmd)\r
-    if result and len(result) > 0:\r
-        kill_cmd = "kill -9 " + str(result).strip() + " > /dev/null 2>&1"\r
-        SdbManager.sdbShell(DEVID, kill_cmd)\r
-        print "info: %s process has been killed" % process_name\r
-    else:\r
-        print "info: No process of %s activated" % process_name\r
-\r
-def remove_tinyweb():\r
-    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/server.pem > /dev/null 2>&1")\r
-    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/tinyweb > /dev/null 2>&1")\r
-    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/cgi-getcookie > /dev/null 2>&1")\r
-    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/cgi-getfield > /dev/null 2>&1")\r
-    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/libmongoose.so > /dev/null 2>&1")\r
-    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/echo.so > /dev/null 2>&1")\r
-    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/libssl.so > /dev/null 2>&1")\r
-    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/libcrypto.so > /dev/null 2>&1")\r
-\r
-def remove_stub():\r
-    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/testkit-stub")\r
-\r
-\r
-def uninstall_testconfig():\r
-    if TIZENV.find('tizen_5.5') > -1:\r
-        inst_path = RESRC_DIR + os.sep + 'tct-testconfig' + os.sep + 'inst.py'\r
-        SdbManager.hostCommand("python %s -s %s -u" % (inst_path, DEVID))\r
-    else:\r
-        RPMPKG = LS(RESRC_DIR, "tct-testconfig")\r
-        if not RPMPKG:\r
-            sys.exit("#ERROR#: cannot found tct-testconfig.zip file in resource dir")\r
-        uninst_cmd = JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-testconfig/inst.sh') + ' -u'\r
-        SdbManager.sdbShell(DEVID, uninst_cmd)\r
-        rm_cmd = 'rm -f ' + JOIN(DEVICE_SUITE_TARGET, 'tct/', RPMPKG)\r
-        SdbManager.sdbShell(DEVID, rm_cmd)\r
-\r
-\r
-def uninstall_behavior():\r
-    print "info: Uninstall behavior tool."\r
-    if TIZENV.find('tizen_5.5') > -1:\r
-        pass\r
-    else:\r
-        uninst_cmd = JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-behavior-tests/inst.sh') + ' -u'\r
-        SdbManager.sdbShell(DEVID, uninst_cmd)\r
-\r
-\r
-def check_resource_dir():\r
-    print "info: check resource directory."\r
-    if os.path.exists(RESRC_DIR):\r
-        SdbManager.sdbShell(DEVID, 'mkdir -p ' + JOIN(DEVICE_SUITE_TARGET, 'tct/'))\r
-        SdbManager.sdbShell(DEVID, 'mkdir -p ' + JOIN(DEVICE_SUITE_TARGET, 'Documents/'))\r
-        return True\r
-    else:\r
-        print "#WARNING#: The directory resource does not exists. Please copy test resources to %s " % RESRC_DIR\r
-        return False\r
-\r
-def check_tinyweb():\r
-    print "info: Check tinyweb."\r
-    result = SdbManager.sdbShell(DEVID, "ls /opt/home/developer/ | grep tinyweb")\r
-    if result and result.find('tinyweb'):\r
-        remove_tinyweb()\r
-        install_tinyweb()\r
-        launch_tinyweb()\r
-    else:\r
-        install_tinyweb()\r
-        launch_tinyweb()\r
-\r
-\r
-def port_manager():\r
-    print "info: Check the tinyweb port"\r
-    result = SdbManager.sdbShell('fuser -n tcp 80 8080 8081 8082 8083 8443')\r
-    if result and len(result) > 0:\r
-        check_port = SdbManager.sdbShell('su "netstat -nap |grep tinyweb"')\r
-        if len(check_port) > 0:\r
-            print "info: tinyweb on"\r
-    else:\r
-        print "info: Port is available"\r
-\r
-\r
-def launch_tinyweb():\r
-    dpath_cmd = "printenv PATH"\r
-    dpath = SdbManager.sdbShell(DEVID, dpath_cmd)\r
-\r
-    launch_cmd = 'sdb -s ' + DEVID + ' shell ' + '"env LD_LIBRARY_PATH=/opt/home/developer PATH=' + dpath.strip() + \\r
-                 ':/opt/home/developer/ tinyweb -ssl_certificate /opt/home/developer/server.pem -document_root ' + \\r
-                 JOIN(DEVICE_SUITE_TARGET, 'tct') + ' -listening_ports 80,8080,8081,8082,8083,8443s; sleep 3s" 0> /dev/null'\r
-\r
-    SdbManager.sdbCommand(launch_cmd, 10)\r
-\r
-    check_tinyweb_cmd = '\"ps aux | grep tinyweb | grep -v grep\"'\r
-    result = SdbManager.sdbShell(DEVID, check_tinyweb_cmd)\r
-    if result and result.find('tinyweb') > -1:\r
-        print "info: Active process tinyweb successfully."\r
-        return True\r
-    else:\r
-        print "#ERROR#: Active process tinyweb failed."\r
-        return False\r
-\r
-def install_tinyweb():\r
-    print "info: Install tinyweb"\r
-    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'tinyweb'), '/opt/home/developer/')\r
-    SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/tinyweb")\r
-\r
-    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'cgi-getcookie'), '/opt/home/developer/')\r
-    SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/cgi-getcookie")\r
-\r
-    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'cgi-getfield'), '/opt/home/developer/')\r
-    SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/cgi-getfield")\r
-\r
-    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'libmongoose.so'), '/opt/home/developer/')\r
-    SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/libmongoose.so")\r
-\r
-    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'echo.so'), '/opt/home/developer/')\r
-    SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/echo.so")\r
-\r
-    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'server.pem'), '/opt/home/developer/')\r
-    SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/server.pem")\r
-    if DEV_ARCH == "arm":\r
-        SdbManager.sdbShell(DEVID, "ln -s /usr/lib/libssl.so.1.0.0 /opt/home/developer/libssl.so")\r
-        SdbManager.sdbShell(DEVID, "ln -s /usr/lib/libcrypto.so.1.0.0 /opt/home/developer/libcrypto.so")\r
-    elif DEV_ARCH == "ia":\r
-        SdbManager.sdbShell(DEVID, "ln -s /usr/lib/libssl.so.1.0.0 /opt/home/developer/libssl.so")\r
-        SdbManager.sdbShell(DEVID, "ln -s /usr/lib/libcrypto.so.1.0.0 /opt/home/developer/libcrypto.so")\r
-    elif DEV_ARCH == "aarch64":\r
-        SdbManager.sdbShell(DEVID, "ln -s /usr/lib64/libssl.so.1.0.0 /opt/home/developer/libssl.so")\r
-        SdbManager.sdbShell(DEVID, "ln -s /usr/lib64/libcrypto.so.1.0.0 /opt/home/developer/libcrypto.so")\r
-    elif DEV_ARCH == "ia64":\r
-        SdbManager.sdbShell(DEVID, "ln -s /usr/lib64/libssl.so.1.0.0 /opt/home/developer/libssl.so")\r
-        SdbManager.sdbShell(DEVID, "ln -s /usr/lib64/libcrypto.so.1.0.0 /opt/home/developer/libcrypto.so")\r
-\r
-\r
-def check_stub():\r
-    print "info: Check testkit-stub."\r
-    result = SdbManager.sdbShell(DEVID, "ls /opt/home/developer/ | grep testkit-stub")\r
-    if result and len(result) > 0:\r
-        print "info: testkit-stub has been installed on device."\r
-        kill_process("testkit-stub")\r
-    install_stub()\r
-\r
-\r
-def install_stub():\r
-    print "info: Install testkit-stub."\r
-    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'testkit-stub', DEV_ARCH, 'testkit-stub'), '/opt/home/developer/testkit-stub')\r
-    SdbManager.sdbShell(DEVID, "chmod a+x /opt/home/developer/testkit-stub")\r
-    SdbManager.sdbShell(DEVID, "chsmack -e \"User\" /opt/home/developer/testkit-stub")\r
-\r
-\r
-def check_testconfig():\r
-    result = SdbManager.sdbShell(DEVID, '"cat ' + JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-testconfig/tct-testconfig.ini') + ' | grep tct"')\r
-    if result and len(result) > 0 and result.find('No such file or directory') == -1:\r
-        print "info: testconfig has already been installed on device."\r
-    else:\r
-        install_testconfig()\r
-\r
-\r
-def install_testconfig():\r
-    print "info: Install testconfig."\r
-    if TIZENV.find('tizen_5.5') > -1:\r
-        instPath = RESRC_DIR + os.sep + 'tct-testconfig' + os.sep + 'inst.py'\r
-        SdbManager.hostCommand("python %s -s %s" % (instPath, DEVID))\r
-    else:\r
-        conf_pkg = LS(RESRC_DIR, "tct-testconfig")\r
-        SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, conf_pkg), JOIN(DEVICE_SUITE_TARGET, 'tct/'))\r
-        SdbManager.sdbShell(DEVID, 'unzip -uo ' + JOIN(DEVICE_SUITE_TARGET, 'tct/') + conf_pkg + ' -d ' + JOIN(DEVICE_SUITE_TARGET, 'tct/'))\r
-        SdbManager.sdbShell(DEVID, JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-testconfig/inst.sh'))\r
-\r
-    result = SdbManager.sdbShell(DEVID, 'cat ' + JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-testconfig/tct-testconfig.ini') + ' | grep tct')\r
-\r
-    if result and len(result) > 0:\r
-        print "info: Install testconfig successfully."\r
-    else:\r
-        print "#ERROR#: Failed to install testconfig, please check %s" % RESRC_DIR\r
-        return False\r
-\r
-    return True\r
-\r
-def install_behavior(profile_name):\r
-    print "info: Install behavior tool."\r
-\r
-    if not profile_name in ['wearable', 'mobile', 'tv', 'ivi']:\r
-        print "#WARNING#: Invalid device profile value %s" % profile_name\r
-        return False\r
-\r
-    if TIZENV.find('tizen_5.5') > -1:\r
-        RPMPKG = "tct-behavior-tests-5.5.zip"\r
-        opt_rpm_path = PKGS_DIR + "s" + os.sep + profile_name + os.sep + RPMPKG\r
-        local_rpm_path = PKGS_DIR + os.sep + profile_name + os.sep + RPMPKG\r
-\r
-        install_rpm = None\r
-        install_dest = None\r
-        install_cmd = None\r
-        if os.path.exists(opt_rpm_path):\r
-            install_rpm = opt_rpm_path\r
-            install_dest = PKGS_DIR + "s" + os.sep + profile_name + os.sep\r
-            install_cmd = PKGS_DIR + "s" + os.sep + profile_name + os.sep + \\r
-                    'opt' + os.sep + "tct-behavior-tests" + os.sep + "inst.py"\r
-        elif os.path.exists(local_rpm_path):\r
-            install_rpm = local_rpm_path\r
-            install_dest = PKGS_DIR + os.sep + profile_name + os.sep\r
-            install_cmd = PKGS_DIR + os.sep + profile_name + os.sep + \\r
-                    'opt' + os.sep + "tct-behavior-tests" + os.sep + "inst.py"\r
-\r
-        SdbManager.hostCommand("rm -rf %s" % install_dest + "opt/tct-behavior-tests")\r
-        SdbManager.hostCommand("unzip -uo %s -d %s" % (install_rpm, install_dest))\r
-        SdbManager.hostCommand("python %s -s %s" % (install_cmd, DEVID))\r
-\r
-        print "info: Check tizen-web-ui-fw. Please wait..."\r
-        check_uifw = SdbManager.sdbShell(DEVID, "ls /usr/share/ | grep tizen-web-ui-fw")\r
-        if check_uifw and len(check_uifw) > 0:\r
-            print "info: tizen-web-ui-fw has been installed on device."\r
-        else:\r
-            SdbManager.sdbShell(DEVID, '"mkdir -p /usr/share/tizen-web-ui-fw/"')\r
-            SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, "tizen-web-ui-fw"), '/usr/share/tizen-web-ui-fw/')\r
-    else:\r
-        pass\r
-\r
-    return True\r
-\r
-\r
-def install_getCap():\r
-    print "info: Install widget getCap."\r
-    widgetCap = LS(RESRC_DIR, 'getCap', 'wgt')\r
-    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, widgetCap), JOIN(DEVICE_SUITE_TARGET, 'tct/') + widgetCap)\r
-\r
-    if TIZENV.find('5.5') > -1:\r
-        SdbManager.sdbShell(DEVID, "su - " + DEVICE_EXECUTION_MODE_30 + \\r
-                " -c 'pkgcmd -i -t wgt -q -p " + JOIN(DEVICE_SUITE_TARGET, 'tct/') + widgetCap + '\'')\r
-        SdbManager.sdbShell(DEVID, 'pkgcmd -i -t wgt -q -p ' + JOIN(DEVICE_SUITE_TARGET, 'tct/') + widgetCap)\r
-\r
-\r
-def install_ngetCap():\r
-    print "info: Install widget ngetCap."\r
-    getcap_pkg = LS(RESRC_DIR, 'getCap', 'tpk')\r
-    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, getcap_pkg), JOIN(DEVICE_SUITE_TARGET, 'tct/') + getcap_pkg)\r
-\r
-    if TIZENV.find('tizen_5.5') > -1:\r
-        SdbManager.sdbShell(DEVID, "su - " + DEVICE_EXECUTION_MODE_30 + \\r
-                " -c 'pkgcmd -ipt tpk -p " + JOIN(DEVICE_SUITE_TARGET, 'tct/') + getcap_pkg + '\'')\r
-    else:\r
-        SdbManager.sdbShell(DEVID, "pkgcmd -iqt tpk -p" + JOIN(DEVICE_SUITE_TARGET, 'tct/') + getcap_pkg)\r
-\r
-def uninstall_getCap():\r
-    print "info: Uninstall widget getCap."\r
-    wgt_id = getCap_appid()\r
-    if wgt_id:\r
-        uninst_cmd = ""\r
-        if TIZENV.find('tizen_5.5') > -1:\r
-            uninst_cmd = "su - " + DEVICE_EXECUTION_MODE_30 + \\r
-                    " -c 'pkgcmd -qun " + wgt_id.split('.')[0] + '\''\r
-        elif TIZENV.find('tizen_2.4') > -1:\r
-            uninst_cmd = "pkgcmd -u -q -t wgt -q -p " + wgt_id + '\''\r
-        SdbManager.sdbShell(DEVID, uninst_cmd)\r
-\r
-    else:\r
-        print "info: getCap is not installed. No need to uninstall"\r
-\r
-    SdbManager.sdbShell(DEVID, "rm -rf " + JOIN(DEVICE_SUITE_TARGET, "Documents/tct"))\r
-    SdbManager.sdbShell(DEVID, "rm -rf " + JOIN(DEVICE_SUITE_TARGET, "tct/getCap.wgt"))\r
-    SdbManager.sdbShell(DEVID, "rm -rf " + JOIN(DEVICE_SUITE_TARGET, "tct/getCap.tpk"))\r
-\r
-\r
-def uninstall_ngetCap():\r
-    print "info: Uninstall widget ngetCap."\r
-\r
-def getCap_appid():\r
-    widgetid_cmd = ""\r
-    if TIZENV.find('tizen_5.5') > -1:\r
-        widgetid_cmd = "su - " + DEVICE_EXECUTION_MODE_30 + \\r
-                " -c \"app_launcher -l | grep getCapabilities\""\r
-    else:\r
-        widgetid_cmd = "wrt-launcher -l | grep getCapabilities"\r
-\r
-    widgetids = SdbManager.sdbShell(DEVID, widgetid_cmd)\r
-    if widgetids and widgetids.find('getCapabilities') > -1:\r
-        items = widgetids.split()\r
-        return items[len(items) - 1].strip("'")\r
-    else:\r
-        return None\r
-\r
-def check_getCap():\r
-    print "info: Check getCap widget. Please wait..."\r
-    if getCap_appid():\r
-        print "info: widget getCap has already been installed on device."\r
-    else:\r
-        install_getCap()\r
-    launch_getCap()\r
-\r
-\r
-def check_ngetCap():\r
-    print "info: Check ngetCap widget. Please wait..."\r
-    if getCap_appid():\r
-        print "info: widget ngetCap has already been installed on device."\r
-    else:\r
-        install_ngetCap()\r
-    launch_ngetCap()\r
-\r
-\r
-def launch_getCap():\r
-    wgt_id = getCap_appid()\r
-    if wgt_id:\r
-        launchResult = None\r
-        if TIZENV.find('tizen_5.5') > -1:\r
-            launchResult = SdbManager.sdbShell(DEVID, 'su - ' + \\r
-                    DEVICE_EXECUTION_MODE_30 + ' -c \"app_launcher -s ' + wgt_id + '\"')\r
-        else:\r
-            launchResult = SdbManager.sdbShell(DEVID, '\"wrt-launcher -s ' + wgt_id + '\"')\r
-\r
-        if launchResult.find('launched') > -1:\r
-            fcheck_retry = 20\r
-\r
-            while fcheck_retry > 0:\r
-                build = SdbManager.sdbShell(DEVID, "cat " + JOIN(DEVICE_SUITE_TARGET, "Documents/tct/buildinfo.xml") + " | grep buildinfos")\r
-                capa = SdbManager.sdbShell(DEVID, "cat " + JOIN(DEVICE_SUITE_TARGET, "Documents/tct/capability.xml") + " | grep capabilities")\r
-                if not build or not capa:\r
-                    time.sleep(2)\r
-                    fcheck_retry -= 1\r
-                else:\r
-                    break\r
-            if fcheck_retry == 0:\r
-                print "#ERROR#: getCap get buildinfo, capability of device failed!"\r
-                return False\r
-            else:\r
-                print "info: Launch getCap successfully"\r
-                return True\r
-        else:\r
-            print "#ERROR#: Launch getCap got failed"\r
-            return False\r
-    else:\r
-        print "#ERROR#: Widget getCap cannot be found. Please check whether the widget is installed successfully"\r
-        return False\r
-\r
-def launch_ngetCap():\r
-    launch_result = None\r
-    if TIZENV.find('tizen_5.5') > -1:\r
-        launch_result = SdbManager.sdbShell(DEVID, 'su - ' + \\r
-                DEVICE_EXECUTION_MODE_30 + ' -c \"launch_app org.example.getcap\"')\r
-    else:\r
-        launch_result = SdbManager.sdbShell(DEVID, '\"launch_app org.example.getcap\"')\r
-\r
-    if "launched" in launch_result:\r
-        return True\r
-    else:\r
-        return False\r
-\r
-def getStorage_appid():\r
-    widgetid_cmd = "su - " + DEVICE_EXECUTION_MODE_30 + \\r
-            " -c \"app_launcher -l | grep InternalStorageSetting\""\r
-    widgetids = SdbManager.sdbShell(DEVID, widgetid_cmd)\r
-    if widgetids and widgetids.find('InternalStorageSetting') > -1:\r
-        items = widgetids.split()\r
-        return items[len(items)-1].strip("'")\r
-    else:\r
-        return None\r
-\r
-def check_storage():\r
-    print "info: Check InternalStorageSetting widget. Please wait..."\r
-    if getStorage_appid():\r
-        print "info: widget InternalStorageSetting has already been installed on device."\r
-    else:\r
-        install_storage()\r
-    launch_storage()\r
-\r
-def install_storage():\r
-    print "info: Install widget InternalStorageSetting"\r
-    widget = LS(RESRC_DIR, 'InternalStorageSetting', 'wgt')\r
-    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, widget), JOIN(DEVICE_SUITE_TARGET, 'tct/') + widget)\r
-\r
-    SdbManager.sdbShell(DEVID, "su - " + DEVICE_EXECUTION_MODE_30 + \\r
-            " -c 'pkgcmd -i -t wgt -q -p " + JOIN(DEVICE_SUITE_TARGET, 'tct/') + widget + '\'')\r
-\r
-def launch_storage():\r
-    wgt_id = getStorage_appid()\r
-    if wgt_id:\r
-        launch_result = SdbManager.sdbShell(DEVID, 'su - ' + \\r
-                DEVICE_EXECUTION_MODE_30 + ' -c \"app_launcher -s ' + wgt_id + '\"')\r
-\r
-        if launch_result.find('launched') > -1:\r
-            print "info: Launch InternalStorageSetting successfully"\r
-            return True\r
-        else:\r
-            print "#ERROR#: InternalStorageSetting launch failed"\r
-            return False\r
-    else:\r
-        print "#ERROR#: Widget InternalStorageSetting cannot be found"\r
-        return False\r
-\r
-def uninstall_storage():\r
-    print "info: Uninstall widget InternalStorageSetting"\r
-    wgt_id = getStorage_appid()\r
-    if wgt_id:\r
-        uninst_cmd = "su - " + DEVICE_EXECUTION_MODE_30 + \\r
-                " -c 'pkgcmd -qun " + wgt_id.split('.')[0] + '\''\r
-        SdbManager.sdbShell(DEVID, uninst_cmd)\r
-    else:\r
-        print "info: InternalStorageSetting is not installed"\r
-\r
-def push_tctconf_file():\r
-    local = TCT_CONFIG_FILE\r
-    remote = DEVICE_SUITE_TARGET_30\r
-    if not SdbManager.sdbPush(DEVID, local, remote):\r
-        print "#ERROR#: TCT_CONFIG file push failed"\r
-        return False\r
-    return True\r
-\r
-def find_ngetCap():\r
-    getcap_tpk = LS(RESRC_DIR, 'getCap', 'tpk')\r
-    if getcap_tpk:\r
-        return True\r
-    else:\r
-        return False\r
-\r
-def debug_trace(cmd, logfile):\r
-    global debug_flag, metux\r
-\r
-    wbuffile = file(logfile, "a+")\r
-    exit_code = None\r
-    proc = subprocess.Popen(args=cmd,\r
-            shell=True,\r
-            stdout=wbuffile,\r
-            stderr=None)\r
-    while True:\r
-        exit_code = proc.poll()\r
-        if exit_code is not None:\r
-            break\r
-        time.sleep(0.6)\r
-        metux.acquire()\r
-        proc_flag = debug_flag\r
-        metux.release()\r
-        if not proc_flag:\r
-            break\r
-    wbuffile.close()\r
-    SdbManager.killall(proc.pid)\r
-\r
-\r
-def start_debug(dlog_file):\r
-    global debug_flag, metux, dlog_thread\r
-    debug_flag = True\r
-    metux = threading.Lock()\r
-    clear_cmd = DLOG_CLEAR\r
-    SdbManager.sdbShell(DEVID, clear_cmd)\r
-\r
-    dlog_cmd = DLOG_UTIL % DEVID\r
-    dlog_thread = threading.Thread(target=debug_trace, args=(dlog_cmd, dlog_file))\r
-    dlog_thread.setDaemon(True)\r
-    dlog_thread.start()\r
-\r
-\r
-def stop_debug():\r
-    global debug_flag, metux\r
-    metux.acquire()\r
-    debug_flag = False\r
-    metux.release()\r
-    dlog_thread.join()\r
-\r
-\r
-def runProcess():\r
-    if options.purge:\r
-        print "[ Uninstall test resource on device. Please wait...]"\r
-        uninstall_testconfig()\r
-        uninstall_behavior()\r
-        uninstall_getCap()\r
-        remove_tinyweb()\r
-        kill_process("tinyweb")\r
-        kill_process("testkit-stub")\r
-        remove_stub()\r
-        if TIZENV.find('5.5') > -1:\r
-            uninstall_storage()\r
-        print "Clean the tct packages in device successfully."\r
-\r
-    elif options.check:\r
-        check_resource_dir()\r
-        print "[ Check test resource on device. Please wait...]"\r
-        if options.process == 'tinyweb':\r
-            check_tinyweb()\r
-        elif options.process == 'testkit-stub':\r
-            check_stub()\r
-        elif options.process == 'testconfig':\r
-            check_testconfig()\r
-        elif options.process == 'getCap':\r
-            check_getCap()\r
-        elif options.process == 'ngetCap':\r
-            if find_ngetCap():\r
-                check_ngetCap()\r
-            else:\r
-                check_getCap()\r
-        elif options.process == 'storage':\r
-            check_storage()\r
-        else:\r
-            check_tinyweb()\r
-            check_stub()\r
-            check_testconfig()\r
-            if find_ngetCap():\r
-                check_ngetCap()\r
-            else:\r
-                check_getCap()\r
-            if TIZENV.find('5.5') > -1:\r
-                check_storage()\r
-\r
-        print "Check finished."\r
-\r
-    elif options.bhtest:\r
-        check_resource_dir()\r
-        if TIZENV.find('5.5') > -1:\r
-            uninstall_storage()\r
-            install_storage()\r
-            launch_storage()\r
-\r
-        uninstall_behavior()\r
-        print "[ Install tct behavior tool on device. Please wait...]"\r
-        install_behavior(options.bhtest)\r
-        print "Installation of tct behavior on device completed."\r
-\r
-    else:\r
-        check_resource_dir()\r
-        print "[ Clean old test resource on device. Please wait...]"\r
-        if options.process == 'tinyweb':\r
-            kill_process("tinyweb")\r
-            remove_tinyweb()\r
-        elif options.process == 'testkit-stub':\r
-            kill_process("testkit-stub")\r
-            remove_stub()\r
-        elif options.process == 'testconfig':\r
-            uninstall_testconfig()\r
-        elif options.process == 'getCap':\r
-            uninstall_getCap()\r
-            pass\r
-        elif options.process == 'ngetCap':\r
-            uninstall_ngetCap()\r
-        elif options.process == 'storage':\r
-            uninstall_storage()\r
-        else:\r
-            remove_tinyweb()\r
-            kill_process("testkit-stub")\r
-            remove_stub()\r
-            uninstall_testconfig()\r
-            uninstall_getCap()\r
-            uninstall_ngetCap()\r
-            if TIZENV.find('5.5') > -1:\r
-                uninstall_storage()\r
-\r
-        print "Clean the tct packages in device successfully."\r
-        print "[ Install test resource on device. Please wait...]"\r
-        if options.process == 'tinyweb':\r
-            install_tinyweb()\r
-            launch_tinyweb()\r
-        elif options.process == 'testkit-stub':\r
-            install_stub()\r
-        elif options.process == 'testconfig':\r
-            install_testconfig()\r
-        elif options.process == 'getCap':\r
-            install_getCap()\r
-            launch_getCap()\r
-        elif options.process == 'ngetCap':\r
-            if find_ngetCap():\r
-                install_ngetCap()\r
-                launch_ngetCap()\r
-            else:\r
-                install_getCap()\r
-                launch_getCap()\r
-        elif options.process == 'storage':\r
-            install_storage()\r
-            launch_storage()\r
-        else:\r
-            install_testconfig()\r
-            install_stub()\r
-            install_tinyweb()\r
-            launch_tinyweb()\r
-            if find_ngetCap():\r
-                install_ngetCap()\r
-                launch_ngetCap()\r
-            else:\r
-                install_getCap()\r
-                launch_getCap()\r
-\r
-            if TIZENV.find('5.5') > -1:\r
-                install_storage()\r
-                launch_storage()\r
-\r
-        print "All of installation process on device completed."\r
-\r
-\r
-if __name__ == "__main__":\r
-\r
-    parser = OptionParser()\r
-    parser.add_option(\r
-        "--install", dest="install", action="store_true", default=False,\r
-        help="Install tct resources to TIZEN device,it can be omitted")\r
-    parser.add_option(\r
-        "--purge", dest="purge", action="store_true", default=False,\r
-        help="Clean up tct resources from TIZEN device")\r
-    parser.add_option(\r
-        "--check", dest="check", action="store_true", default=False,\r
-        help="Check test resource on device")\r
-    parser.add_option(\r
-        "--deviceid", dest="deviceid", action="store",\r
-        help="Set the device serial number")\r
-    parser.add_option(\r
-        "--procid", dest="process", action="store",\r
-        help="Set the process id for checking")\r
-    parser.add_option(\r
-        "--bhtest", dest="bhtest", action="store",\r
-        help="Install behavior test tool to device")\r
-\r
-    (options, args) = parser.parse_args()\r
-\r
-    devinst = DeviceManager.getInstance()\r
-    if options.deviceid:\r
-        if devinst.isDeviceAvailable(options.deviceid):\r
-            DEVID = options.deviceid\r
-        else:\r
-            sys.exit("#ERROR#: The '%s' device Id exists error" % options.deviceid)\r
-    else:\r
-        if devinst.getDeviceSize() > 1 or devinst.getDeviceSize() == 0:\r
-            sys.exit("#ERROR#: %s devices connected or device not connected" % str(devinst.getDeviceSize()))\r
-        else:\r
-            DEVID = devinst.getSdbDeviceList()[0].getDeviceId()\r
-\r
-    print "[========== start tct-config-device : %s ==========]" % DEVID\r
-    dev_temp_dir = '/opt/tools/shell/tmp/%s/' % DEVID\r
-    if not os.path.isdir(dev_temp_dir):\r
-        os.mkdir(dev_temp_dir)\r
-    DLOG_SAVE_PATH = '/opt/tools/shell/tmp/%s/conf_dev_%s.dlog'\r
-    if options.process is None:\r
-        DLOG_SAVE_PATH = DLOG_SAVE_PATH % (DEVID, 'all')\r
-    else:\r
-        DLOG_SAVE_PATH = DLOG_SAVE_PATH % (DEVID, options.process)\r
-\r
-    #start_debug(DLOG_SAVE_PATH)\r
-\r
-    if not SdbManager.sdbRootOn(DEVID):\r
-        sys.exit(-1)\r
-\r
-    SdbManager.sdbSetDate(DEVID)\r
-\r
-    if not get_device_arch() or not push_tctconf_file():\r
-        sys.exit(0)\r
-\r
-    runProcess()\r
-    #stop_debug()\r
-    print "[========== end tct-config-device : %s ==========]" % DEVID\r
+#!/usr/bin/python
+
+"""Usage:
+         tct-config-device.py [--install [--deviceid <serial_no>]]
+         tct-config-device.py --purge [--deviceid <serial_no>]
+         tct-config-device.py --check [--deviceid <serial_no>][--procid <process_name>]
+         tct-config-device.py --bhtest <profile>
+
+Options:
+  -h, --help         show this help message and exit
+  --install          Install tct resources to TIZEN device,it can be omitted
+  --purge            Clean up tct resources from TIZEN device
+  --check            Check test resource on device
+  --bhtest           Install tct behavior test
+  --deviceid         Set the device serial number
+  --procid           Set the check process name
+
+"""
+import os
+import sys
+import time
+import ConfigParser
+import threading
+import subprocess
+
+
+from optparse import OptionParser
+from devicemanager import DeviceManager
+from sdbmanager import SdbManager
+
+JOIN = os.path.join
+EXISTS = os.path.exists
+DIRNAME = os.path.dirname
+BASENAME = os.path.basename
+ABSPATH = os.path.abspath
+SPLIT = os.path.split
+
+CURENT_DIR = SPLIT(DIRNAME(ABSPATH(__file__)))[0]
+
+TOOLS_DIR = JOIN(CURENT_DIR, "tools")
+RESRC_DIR = JOIN(CURENT_DIR, "resource")
+PKGS_DIR = JOIN(CURENT_DIR, "package")
+
+DEVID = ""
+
+TIZENV = "tizen_5.5"
+
+DLOG_CLEAR = "dlogutil -c"
+DLOG_UTIL = "sdb -s %s shell dlogutil -v time"
+
+TCT_CONFIG_FILE = "/opt/tools/TCT_CONFIG"
+tct_parser = ConfigParser.ConfigParser()
+tct_parser.read(TCT_CONFIG_FILE)
+
+DEVICE_SUITE_TARGET_24 = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_24')
+DEVICE_SUITE_TARGET_30 = tct_parser.get('DEVICE', 'DEVICE_SUITE_TARGET_30')
+DEVICE_EXECUTION_MODE_30 = tct_parser.get('DEVICE', 'DEVICE_EXECUTION_MODE_30')
+
+if TIZENV.find('tizen_5.5') > -1:
+    DEVICE_SUITE_TARGET = DEVICE_SUITE_TARGET_30
+else:
+    DEVICE_SUITE_TARGET = DEVICE_SUITE_TARGET_24
+
+def LS(root, file_name, extension=None):
+    import glob
+
+    file_path = ""
+    if extension:
+        file_path = JOIN(root, file_name) + "*." + extension
+    else:
+        file_path = JOIN(root, file_name) + "*"
+    files = glob.iglob(r'' + file_path + '')
+    for f in files:
+        return BASENAME(f)
+
+def get_device_arch():
+    global DEV_ARCH
+    #ARCHCMD = SDB_SERNO + " shell \"cat /etc/products.d/tizen.prod |grep \<arch\""
+    arch_cmd = "cat /etc/config/model-config.xml | grep tizen.org/feature/platform.core.cpu.arch"
+    #result example : <key name="tizen.org/feature/platform.core.cpu.arch" type="string">armv7</key>
+    result = SdbManager.sdbShell(DEVID, arch_cmd)
+    if result and len(result) > 0:
+        arch_str = result.split('\n')[0]
+        if arch_str and arch_str.find('armv') > -1:
+            DEV_ARCH = "arm"
+            print "info: [* Arch Type : arm *]"
+        elif arch_str and arch_str.find("aarch64") > -1:
+            DEV_ARCH = "aarch64"
+            print "info: [* Arch Type : aarch64 *]"
+        elif arch_str and arch_str.find('x86_64') > -1:
+            DEV_ARCH = "ia64"
+            print "info: [* Arch Type : ia64 *]"
+        elif arch_str and (arch_str.find("i686") > -1 or arch_str.find("x86") > -1 or arch_str.find("i386") > -1):
+            DEV_ARCH = "ia"
+            print "info: [* Arch Type : ia *]"
+        else:
+            print "info: [* Arch Type : None *]"
+            return False
+        return True
+    else:
+        print "#ERROR#: Failed to get device cpu_arch type"
+        return False
+
+
+def kill_process(process_name):
+    proc_cmd = "ps aux | grep " + process_name + " | grep -v grep | awk '{print $2}'"
+    result = SdbManager.sdbShell(DEVID, proc_cmd)
+    if result and len(result) > 0:
+        kill_cmd = "kill -9 " + str(result).strip() + " > /dev/null 2>&1"
+        SdbManager.sdbShell(DEVID, kill_cmd)
+        print "info: %s process has been killed" % process_name
+    else:
+        print "info: No process of %s activated" % process_name
+
+def remove_tinyweb():
+    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/server.pem > /dev/null 2>&1")
+    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/tinyweb > /dev/null 2>&1")
+    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/cgi-getcookie > /dev/null 2>&1")
+    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/cgi-getfield > /dev/null 2>&1")
+    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/libmongoose.so > /dev/null 2>&1")
+    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/echo.so > /dev/null 2>&1")
+    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/libssl.so > /dev/null 2>&1")
+    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/libcrypto.so > /dev/null 2>&1")
+
+def remove_stub():
+    SdbManager.sdbShell(DEVID, "rm -f /opt/home/developer/testkit-stub")
+
+
+def uninstall_testconfig():
+    if TIZENV.find('tizen_5.5') > -1:
+        inst_path = RESRC_DIR + os.sep + 'tct-testconfig' + os.sep + 'inst.py'
+        SdbManager.hostCommand("python %s -s %s -u" % (inst_path, DEVID))
+    else:
+        RPMPKG = LS(RESRC_DIR, "tct-testconfig")
+        if not RPMPKG:
+            sys.exit("#ERROR#: cannot found tct-testconfig.zip file in resource dir")
+        uninst_cmd = JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-testconfig/inst.sh') + ' -u'
+        SdbManager.sdbShell(DEVID, uninst_cmd)
+        rm_cmd = 'rm -f ' + JOIN(DEVICE_SUITE_TARGET, 'tct/', RPMPKG)
+        SdbManager.sdbShell(DEVID, rm_cmd)
+
+
+def uninstall_behavior():
+    print "info: Uninstall behavior tool."
+    if TIZENV.find('tizen_5.5') > -1:
+        pass
+    else:
+        uninst_cmd = JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-behavior-tests/inst.sh') + ' -u'
+        SdbManager.sdbShell(DEVID, uninst_cmd)
+
+
+def check_resource_dir():
+    print "info: check resource directory."
+    if os.path.exists(RESRC_DIR):
+        SdbManager.sdbShell(DEVID, 'mkdir -p ' + JOIN(DEVICE_SUITE_TARGET, 'tct/'))
+        SdbManager.sdbShell(DEVID, 'mkdir -p ' + JOIN(DEVICE_SUITE_TARGET, 'Documents/'))
+        return True
+    else:
+        print "#WARNING#: The directory resource does not exists. Please copy test resources to %s " % RESRC_DIR
+        return False
+
+def check_tinyweb():
+    print "info: Check tinyweb."
+    result = SdbManager.sdbShell(DEVID, "ls /opt/home/developer/ | grep tinyweb")
+    if result and result.find('tinyweb'):
+        remove_tinyweb()
+        install_tinyweb()
+        launch_tinyweb()
+    else:
+        install_tinyweb()
+        launch_tinyweb()
+
+
+def port_manager():
+    print "info: Check the tinyweb port"
+    result = SdbManager.sdbShell('fuser -n tcp 80 8080 8081 8082 8083 8443')
+    if result and len(result) > 0:
+        check_port = SdbManager.sdbShell('su "netstat -nap |grep tinyweb"')
+        if len(check_port) > 0:
+            print "info: tinyweb on"
+    else:
+        print "info: Port is available"
+
+
+def launch_tinyweb():
+    dpath_cmd = "printenv PATH"
+    dpath = SdbManager.sdbShell(DEVID, dpath_cmd)
+
+    launch_cmd = 'sdb -s ' + DEVID + ' shell ' + '"env LD_LIBRARY_PATH=/opt/home/developer PATH=' + dpath.strip() + \
+                 ':/opt/home/developer/ tinyweb -ssl_certificate /opt/home/developer/server.pem -document_root ' + \
+                 JOIN(DEVICE_SUITE_TARGET, 'tct') + ' -listening_ports 80,8080,8081,8082,8083,8443s; sleep 3s" 0> /dev/null'
+
+    SdbManager.sdbCommand(launch_cmd, 10)
+
+    check_tinyweb_cmd = '\"ps aux | grep tinyweb | grep -v grep\"'
+    result = SdbManager.sdbShell(DEVID, check_tinyweb_cmd)
+    if result and result.find('tinyweb') > -1:
+        print "info: Active process tinyweb successfully."
+        return True
+    else:
+        print "#ERROR#: Active process tinyweb failed."
+        return False
+
+def install_tinyweb():
+    print "info: Install tinyweb"
+    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'tinyweb'), '/opt/home/developer/')
+    SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/tinyweb")
+
+    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'cgi-getcookie'), '/opt/home/developer/')
+    SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/cgi-getcookie")
+
+    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'cgi-getfield'), '/opt/home/developer/')
+    SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/cgi-getfield")
+
+    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'libmongoose.so'), '/opt/home/developer/')
+    SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/libmongoose.so")
+
+    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'echo.so'), '/opt/home/developer/')
+    SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/echo.so")
+
+    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'tinyweb', DEV_ARCH, 'server.pem'), '/opt/home/developer/')
+    SdbManager.sdbShell(DEVID, "chmod 777 /opt/home/developer/server.pem")
+    if DEV_ARCH == "arm":
+        SdbManager.sdbShell(DEVID, "ln -s /usr/lib/libssl.so.1.0.0 /opt/home/developer/libssl.so")
+        SdbManager.sdbShell(DEVID, "ln -s /usr/lib/libcrypto.so.1.0.0 /opt/home/developer/libcrypto.so")
+    elif DEV_ARCH == "ia":
+        SdbManager.sdbShell(DEVID, "ln -s /usr/lib/libssl.so.1.0.0 /opt/home/developer/libssl.so")
+        SdbManager.sdbShell(DEVID, "ln -s /usr/lib/libcrypto.so.1.0.0 /opt/home/developer/libcrypto.so")
+    elif DEV_ARCH == "aarch64":
+        SdbManager.sdbShell(DEVID, "ln -s /usr/lib64/libssl.so.1.0.0 /opt/home/developer/libssl.so")
+        SdbManager.sdbShell(DEVID, "ln -s /usr/lib64/libcrypto.so.1.0.0 /opt/home/developer/libcrypto.so")
+    elif DEV_ARCH == "ia64":
+        SdbManager.sdbShell(DEVID, "ln -s /usr/lib64/libssl.so.1.0.0 /opt/home/developer/libssl.so")
+        SdbManager.sdbShell(DEVID, "ln -s /usr/lib64/libcrypto.so.1.0.0 /opt/home/developer/libcrypto.so")
+
+
+def check_stub():
+    print "info: Check testkit-stub."
+    result = SdbManager.sdbShell(DEVID, "ls /opt/home/developer/ | grep testkit-stub")
+    if result and len(result) > 0:
+        print "info: testkit-stub has been installed on device."
+        kill_process("testkit-stub")
+    install_stub()
+
+
+def install_stub():
+    print "info: Install testkit-stub."
+    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, 'testkit-stub', DEV_ARCH, 'testkit-stub'), '/opt/home/developer/testkit-stub')
+    SdbManager.sdbShell(DEVID, "chmod a+x /opt/home/developer/testkit-stub")
+    SdbManager.sdbShell(DEVID, "chsmack -e \"User\" /opt/home/developer/testkit-stub")
+
+
+def check_testconfig():
+    result = SdbManager.sdbShell(DEVID, '"cat ' + JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-testconfig/tct-testconfig.ini') + ' | grep tct"')
+    if result and len(result) > 0 and result.find('No such file or directory') == -1:
+        print "info: testconfig has already been installed on device."
+    else:
+        install_testconfig()
+
+
+def install_testconfig():
+    print "info: Install testconfig."
+    if TIZENV.find('tizen_5.5') > -1:
+        instPath = RESRC_DIR + os.sep + 'tct-testconfig' + os.sep + 'inst.py'
+        SdbManager.hostCommand("python %s -s %s" % (instPath, DEVID))
+    else:
+        conf_pkg = LS(RESRC_DIR, "tct-testconfig")
+        SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, conf_pkg), JOIN(DEVICE_SUITE_TARGET, 'tct/'))
+        SdbManager.sdbShell(DEVID, 'unzip -uo ' + JOIN(DEVICE_SUITE_TARGET, 'tct/') + conf_pkg + ' -d ' + JOIN(DEVICE_SUITE_TARGET, 'tct/'))
+        SdbManager.sdbShell(DEVID, JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-testconfig/inst.sh'))
+
+    result = SdbManager.sdbShell(DEVID, 'cat ' + JOIN(DEVICE_SUITE_TARGET, 'tct/opt/tct-testconfig/tct-testconfig.ini') + ' | grep tct')
+
+    if result and len(result) > 0:
+        print "info: Install testconfig successfully."
+    else:
+        print "#ERROR#: Failed to install testconfig, please check %s" % RESRC_DIR
+        return False
+
+    return True
+
+def install_behavior(profile_name):
+    print "info: Install behavior tool."
+
+    if not profile_name in ['wearable', 'mobile', 'tv', 'ivi']:
+        print "#WARNING#: Invalid device profile value %s" % profile_name
+        return False
+
+    if TIZENV.find('tizen_5.5') > -1:
+        RPMPKG = "tct-behavior-tests-5.5.zip"
+        opt_rpm_path = PKGS_DIR + "s" + os.sep + profile_name + os.sep + RPMPKG
+        local_rpm_path = PKGS_DIR + os.sep + profile_name + os.sep + RPMPKG
+
+        install_rpm = None
+        install_dest = None
+        install_cmd = None
+        if os.path.exists(opt_rpm_path):
+            install_rpm = opt_rpm_path
+            install_dest = PKGS_DIR + "s" + os.sep + profile_name + os.sep
+            install_cmd = PKGS_DIR + "s" + os.sep + profile_name + os.sep + \
+                    'opt' + os.sep + "tct-behavior-tests" + os.sep + "inst.py"
+        elif os.path.exists(local_rpm_path):
+            install_rpm = local_rpm_path
+            install_dest = PKGS_DIR + os.sep + profile_name + os.sep
+            install_cmd = PKGS_DIR + os.sep + profile_name + os.sep + \
+                    'opt' + os.sep + "tct-behavior-tests" + os.sep + "inst.py"
+
+        SdbManager.hostCommand("rm -rf %s" % install_dest + "opt/tct-behavior-tests")
+        SdbManager.hostCommand("unzip -uo %s -d %s" % (install_rpm, install_dest))
+        SdbManager.hostCommand("python %s -s %s" % (install_cmd, DEVID))
+
+        print "info: Check tizen-web-ui-fw. Please wait..."
+        check_uifw = SdbManager.sdbShell(DEVID, "ls /usr/share/ | grep tizen-web-ui-fw")
+        if check_uifw and len(check_uifw) > 0:
+            print "info: tizen-web-ui-fw has been installed on device."
+        else:
+            SdbManager.sdbShell(DEVID, '"mkdir -p /usr/share/tizen-web-ui-fw/"')
+            SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, "tizen-web-ui-fw"), '/usr/share/tizen-web-ui-fw/')
+    else:
+        pass
+
+    return True
+
+
+def install_getCap():
+    print "info: Install widget getCap."
+    widgetCap = LS(RESRC_DIR, 'getCap', 'wgt')
+    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, widgetCap), JOIN(DEVICE_SUITE_TARGET, 'tct/') + widgetCap)
+
+    if TIZENV.find('5.5') > -1:
+        SdbManager.sdbShell(DEVID, "su - " + DEVICE_EXECUTION_MODE_30 + \
+                " -c 'pkgcmd -i -t wgt -q -p " + JOIN(DEVICE_SUITE_TARGET, 'tct/') + widgetCap + '\'')
+        SdbManager.sdbShell(DEVID, 'pkgcmd -i -t wgt -q -p ' + JOIN(DEVICE_SUITE_TARGET, 'tct/') + widgetCap)
+
+
+def install_ngetCap():
+    print "info: Install widget ngetCap."
+    getcap_pkg = LS(RESRC_DIR, 'getCap', 'tpk')
+    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, getcap_pkg), JOIN(DEVICE_SUITE_TARGET, 'tct/') + getcap_pkg)
+
+    if TIZENV.find('tizen_5.5') > -1:
+        SdbManager.sdbShell(DEVID, "su - " + DEVICE_EXECUTION_MODE_30 + \
+                " -c 'pkgcmd -ipt tpk -p " + JOIN(DEVICE_SUITE_TARGET, 'tct/') + getcap_pkg + '\'')
+    else:
+        SdbManager.sdbShell(DEVID, "pkgcmd -iqt tpk -p" + JOIN(DEVICE_SUITE_TARGET, 'tct/') + getcap_pkg)
+
+def uninstall_getCap():
+    print "info: Uninstall widget getCap."
+    wgt_id = getCap_appid()
+    if wgt_id:
+        uninst_cmd = ""
+        if TIZENV.find('tizen_5.5') > -1:
+            uninst_cmd = "su - " + DEVICE_EXECUTION_MODE_30 + \
+                    " -c 'pkgcmd -qun " + wgt_id.split('.')[0] + '\''
+        elif TIZENV.find('tizen_2.4') > -1:
+            uninst_cmd = "pkgcmd -u -q -t wgt -q -p " + wgt_id + '\''
+        SdbManager.sdbShell(DEVID, uninst_cmd)
+
+    else:
+        print "info: getCap is not installed. No need to uninstall"
+
+    SdbManager.sdbShell(DEVID, "rm -rf " + JOIN(DEVICE_SUITE_TARGET, "Documents/tct"))
+    SdbManager.sdbShell(DEVID, "rm -rf " + JOIN(DEVICE_SUITE_TARGET, "tct/getCap.wgt"))
+    SdbManager.sdbShell(DEVID, "rm -rf " + JOIN(DEVICE_SUITE_TARGET, "tct/getCap.tpk"))
+
+
+def uninstall_ngetCap():
+    print "info: Uninstall widget ngetCap."
+
+def getCap_appid():
+    widgetid_cmd = ""
+    if TIZENV.find('tizen_5.5') > -1:
+        widgetid_cmd = "su - " + DEVICE_EXECUTION_MODE_30 + \
+                " -c \"app_launcher -l | grep getCapabilities\""
+    else:
+        widgetid_cmd = "wrt-launcher -l | grep getCapabilities"
+
+    widgetids = SdbManager.sdbShell(DEVID, widgetid_cmd)
+    if widgetids and widgetids.find('getCapabilities') > -1:
+        items = widgetids.split()
+        return items[len(items) - 1].strip("'")
+    else:
+        return None
+
+def check_getCap():
+    print "info: Check getCap widget. Please wait..."
+    if getCap_appid():
+        print "info: widget getCap has already been installed on device."
+    else:
+        install_getCap()
+    launch_getCap()
+
+
+def check_ngetCap():
+    print "info: Check ngetCap widget. Please wait..."
+    if getCap_appid():
+        print "info: widget ngetCap has already been installed on device."
+    else:
+        install_ngetCap()
+    launch_ngetCap()
+
+
+def launch_getCap():
+    wgt_id = getCap_appid()
+    if wgt_id:
+        launchResult = None
+        if TIZENV.find('tizen_5.5') > -1:
+            launchResult = SdbManager.sdbShell(DEVID, 'su - ' + \
+                    DEVICE_EXECUTION_MODE_30 + ' -c \"app_launcher -s ' + wgt_id + '\"')
+        else:
+            launchResult = SdbManager.sdbShell(DEVID, '\"wrt-launcher -s ' + wgt_id + '\"')
+
+        if launchResult.find('launched') > -1:
+            fcheck_retry = 20
+
+            while fcheck_retry > 0:
+                build = SdbManager.sdbShell(DEVID, "cat " + JOIN(DEVICE_SUITE_TARGET, "Documents/tct/buildinfo.xml") + " | grep buildinfos")
+                capa = SdbManager.sdbShell(DEVID, "cat " + JOIN(DEVICE_SUITE_TARGET, "Documents/tct/capability.xml") + " | grep capabilities")
+                if not build or not capa:
+                    time.sleep(2)
+                    fcheck_retry -= 1
+                else:
+                    break
+            if fcheck_retry == 0:
+                print "#ERROR#: getCap get buildinfo, capability of device failed!"
+                return False
+            else:
+                print "info: Launch getCap successfully"
+                return True
+        else:
+            print "#ERROR#: Launch getCap got failed"
+            return False
+    else:
+        print "#ERROR#: Widget getCap cannot be found. Please check whether the widget is installed successfully"
+        return False
+
+def launch_ngetCap():
+    launch_result = None
+    if TIZENV.find('tizen_5.5') > -1:
+        launch_result = SdbManager.sdbShell(DEVID, 'su - ' + \
+                DEVICE_EXECUTION_MODE_30 + ' -c \"launch_app org.example.getcap\"')
+    else:
+        launch_result = SdbManager.sdbShell(DEVID, '\"launch_app org.example.getcap\"')
+
+    if "launched" in launch_result:
+        return True
+    else:
+        return False
+
+def getStorage_appid():
+    widgetid_cmd = "su - " + DEVICE_EXECUTION_MODE_30 + \
+            " -c \"app_launcher -l | grep InternalStorageSetting\""
+    widgetids = SdbManager.sdbShell(DEVID, widgetid_cmd)
+    if widgetids and widgetids.find('InternalStorageSetting') > -1:
+        items = widgetids.split()
+        return items[len(items)-1].strip("'")
+    else:
+        return None
+
+def check_storage():
+    print "info: Check InternalStorageSetting widget. Please wait..."
+    if getStorage_appid():
+        print "info: widget InternalStorageSetting has already been installed on device."
+    else:
+        install_storage()
+    launch_storage()
+
+def install_storage():
+    print "info: Install widget InternalStorageSetting"
+    widget = LS(RESRC_DIR, 'InternalStorageSetting', 'wgt')
+    SdbManager.sdbPush(DEVID, JOIN(RESRC_DIR, widget), JOIN(DEVICE_SUITE_TARGET, 'tct/') + widget)
+
+    SdbManager.sdbShell(DEVID, "su - " + DEVICE_EXECUTION_MODE_30 + \
+            " -c 'pkgcmd -i -t wgt -q -p " + JOIN(DEVICE_SUITE_TARGET, 'tct/') + widget + '\'')
+
+def launch_storage():
+    wgt_id = getStorage_appid()
+    if wgt_id:
+        launch_result = SdbManager.sdbShell(DEVID, 'su - ' + \
+                DEVICE_EXECUTION_MODE_30 + ' -c \"app_launcher -s ' + wgt_id + '\"')
+
+        if launch_result.find('launched') > -1:
+            print "info: Launch InternalStorageSetting successfully"
+            return True
+        else:
+            print "#ERROR#: InternalStorageSetting launch failed"
+            return False
+    else:
+        print "#ERROR#: Widget InternalStorageSetting cannot be found"
+        return False
+
+def uninstall_storage():
+    print "info: Uninstall widget InternalStorageSetting"
+    wgt_id = getStorage_appid()
+    if wgt_id:
+        uninst_cmd = "su - " + DEVICE_EXECUTION_MODE_30 + \
+                " -c 'pkgcmd -qun " + wgt_id.split('.')[0] + '\''
+        SdbManager.sdbShell(DEVID, uninst_cmd)
+    else:
+        print "info: InternalStorageSetting is not installed"
+
+def push_tctconf_file():
+    local = TCT_CONFIG_FILE
+    remote = DEVICE_SUITE_TARGET_30
+    if not SdbManager.sdbPush(DEVID, local, remote):
+        print "#ERROR#: TCT_CONFIG file push failed"
+        return False
+    return True
+
+def find_ngetCap():
+    getcap_tpk = LS(RESRC_DIR, 'getCap', 'tpk')
+    if getcap_tpk:
+        return True
+    else:
+        return False
+
+def debug_trace(cmd, logfile):
+    global debug_flag, metux
+
+    wbuffile = file(logfile, "a+")
+    exit_code = None
+    proc = subprocess.Popen(args=cmd,
+            shell=True,
+            stdout=wbuffile,
+            stderr=None)
+    while True:
+        exit_code = proc.poll()
+        if exit_code is not None:
+            break
+        time.sleep(0.6)
+        metux.acquire()
+        proc_flag = debug_flag
+        metux.release()
+        if not proc_flag:
+            break
+    wbuffile.close()
+    SdbManager.killall(proc.pid)
+
+
+def start_debug(dlog_file):
+    global debug_flag, metux, dlog_thread
+    debug_flag = True
+    metux = threading.Lock()
+    clear_cmd = DLOG_CLEAR
+    SdbManager.sdbShell(DEVID, clear_cmd)
+
+    dlog_cmd = DLOG_UTIL % DEVID
+    dlog_thread = threading.Thread(target=debug_trace, args=(dlog_cmd, dlog_file))
+    dlog_thread.setDaemon(True)
+    dlog_thread.start()
+
+
+def stop_debug():
+    global debug_flag, metux
+    metux.acquire()
+    debug_flag = False
+    metux.release()
+    dlog_thread.join()
+
+
+def runProcess():
+    if options.purge:
+        print "[ Uninstall test resource on device. Please wait...]"
+        uninstall_testconfig()
+        uninstall_behavior()
+        uninstall_getCap()
+        remove_tinyweb()
+        kill_process("tinyweb")
+        kill_process("testkit-stub")
+        remove_stub()
+        if TIZENV.find('5.5') > -1:
+            uninstall_storage()
+        print "Clean the tct packages in device successfully."
+
+    elif options.check:
+        check_resource_dir()
+        print "[ Check test resource on device. Please wait...]"
+        if options.process == 'tinyweb':
+            check_tinyweb()
+        elif options.process == 'testkit-stub':
+            check_stub()
+        elif options.process == 'testconfig':
+            check_testconfig()
+        elif options.process == 'getCap':
+            check_getCap()
+        elif options.process == 'ngetCap':
+            if find_ngetCap():
+                check_ngetCap()
+            else:
+                check_getCap()
+        elif options.process == 'storage':
+            check_storage()
+        else:
+            check_tinyweb()
+            check_stub()
+            check_testconfig()
+            if find_ngetCap():
+                check_ngetCap()
+            else:
+                check_getCap()
+            if TIZENV.find('5.5') > -1:
+                check_storage()
+
+        print "Check finished."
+
+    elif options.bhtest:
+        check_resource_dir()
+        if TIZENV.find('5.5') > -1:
+            uninstall_storage()
+            install_storage()
+            launch_storage()
+
+        uninstall_behavior()
+        print "[ Install tct behavior tool on device. Please wait...]"
+        install_behavior(options.bhtest)
+        print "Installation of tct behavior on device completed."
+
+    else:
+        check_resource_dir()
+        print "[ Clean old test resource on device. Please wait...]"
+        if options.process == 'tinyweb':
+            kill_process("tinyweb")
+            remove_tinyweb()
+        elif options.process == 'testkit-stub':
+            kill_process("testkit-stub")
+            remove_stub()
+        elif options.process == 'testconfig':
+            uninstall_testconfig()
+        elif options.process == 'getCap':
+            uninstall_getCap()
+            pass
+        elif options.process == 'ngetCap':
+            uninstall_ngetCap()
+        elif options.process == 'storage':
+            uninstall_storage()
+        else:
+            remove_tinyweb()
+            kill_process("testkit-stub")
+            remove_stub()
+            uninstall_testconfig()
+            uninstall_getCap()
+            uninstall_ngetCap()
+            if TIZENV.find('5.5') > -1:
+                uninstall_storage()
+
+        print "Clean the tct packages in device successfully."
+        print "[ Install test resource on device. Please wait...]"
+        if options.process == 'tinyweb':
+            install_tinyweb()
+            launch_tinyweb()
+        elif options.process == 'testkit-stub':
+            install_stub()
+        elif options.process == 'testconfig':
+            install_testconfig()
+        elif options.process == 'getCap':
+            install_getCap()
+            launch_getCap()
+        elif options.process == 'ngetCap':
+            if find_ngetCap():
+                install_ngetCap()
+                launch_ngetCap()
+            else:
+                install_getCap()
+                launch_getCap()
+        elif options.process == 'storage':
+            install_storage()
+            launch_storage()
+        else:
+            install_testconfig()
+            install_stub()
+            install_tinyweb()
+            launch_tinyweb()
+            if find_ngetCap():
+                install_ngetCap()
+                launch_ngetCap()
+            else:
+                install_getCap()
+                launch_getCap()
+
+            if TIZENV.find('5.5') > -1:
+                install_storage()
+                launch_storage()
+
+        print "All of installation process on device completed."
+
+
+if __name__ == "__main__":
+
+    parser = OptionParser()
+    parser.add_option(
+        "--install", dest="install", action="store_true", default=False,
+        help="Install tct resources to TIZEN device,it can be omitted")
+    parser.add_option(
+        "--purge", dest="purge", action="store_true", default=False,
+        help="Clean up tct resources from TIZEN device")
+    parser.add_option(
+        "--check", dest="check", action="store_true", default=False,
+        help="Check test resource on device")
+    parser.add_option(
+        "--deviceid", dest="deviceid", action="store",
+        help="Set the device serial number")
+    parser.add_option(
+        "--procid", dest="process", action="store",
+        help="Set the process id for checking")
+    parser.add_option(
+        "--bhtest", dest="bhtest", action="store",
+        help="Install behavior test tool to device")
+
+    (options, args) = parser.parse_args()
+
+    devinst = DeviceManager.getInstance()
+    if options.deviceid:
+        if devinst.isDeviceAvailable(options.deviceid):
+            DEVID = options.deviceid
+        else:
+            sys.exit("#ERROR#: The '%s' device Id exists error" % options.deviceid)
+    else:
+        if devinst.getDeviceSize() > 1 or devinst.getDeviceSize() == 0:
+            sys.exit("#ERROR#: %s devices connected or device not connected" % str(devinst.getDeviceSize()))
+        else:
+            DEVID = devinst.getSdbDeviceList()[0].getDeviceId()
+
+    print "[========== start tct-config-device : %s ==========]" % DEVID
+    dev_temp_dir = '/opt/tools/shell/tmp/%s/' % DEVID
+    if not os.path.isdir(dev_temp_dir):
+        os.mkdir(dev_temp_dir)
+    DLOG_SAVE_PATH = '/opt/tools/shell/tmp/%s/conf_dev_%s.dlog'
+    if options.process is None:
+        DLOG_SAVE_PATH = DLOG_SAVE_PATH % (DEVID, 'all')
+    else:
+        DLOG_SAVE_PATH = DLOG_SAVE_PATH % (DEVID, options.process)
+
+    #start_debug(DLOG_SAVE_PATH)
+
+    if not SdbManager.sdbRootOn(DEVID):
+        sys.exit(-1)
+
+    SdbManager.sdbSetDate(DEVID)
+
+    if not get_device_arch() or not push_tctconf_file():
+        sys.exit(0)
+
+    runProcess()
+    #stop_debug()
+    print "[========== end tct-config-device : %s ==========]" % DEVID