コード例 #1
0
def delete_files_from_device():

    # delete apk file
    logger.debug('step: delete old apk file')
    del_path = module_config.getValue('SHELL_MODULE', 'push_apk_path')
    del_path = os.path.join(del_path, '*.apk')
    device.remove(del_path)

    # delete so file
    logger.debug('step: delete old so file')
    del_path = module_config.getValue('SHELL_MODULE', 'push_so_path')
    del_path = os.path.join(del_path, 'libvlife_*.so')
    device.remove(del_path)
コード例 #2
0
def init_module_version(uid, orig_path, path_index, loop_number):

    shell_paths = module_config.getValue('SHELL_MODULE',
                                         'upgrade_shell_path').split(';')
    result_list = []
    count = 0
    for new_shell in shell_paths:

        logger.debug('***key step****: upgrade to ' + new_shell)
        test_result = True
        new_shell_index = shell_paths.index(new_shell) + 1

        # get root
        device.adb('root')
        device.adb('remount')

        # delete files
        delete_files_from_device()

        # clear app
        pkg_name = module_config.getValue('SHELL_MODULE', 'pkg_name')
        logger.debug('step: clear pkg content ' + pkg_name)
        device.clear_app_data(pkg_name)
        logger.debug('step: clear system ui')
        device.clear_app_data('com.android.systemui')
        device.uninstall(pkg_name)

        # push new api file
        apk_path = module_config.getValue('SHELL_MODULE', 'push_apk_path')
        so_path = module_config.getValue('SHELL_MODULE', 'push_so_path')
        logger.debug('step: push apk file to device')
        files = get_full_name(orig_path, '.apk')
        device.push(files[0], apk_path)
        desktop_path = os.path.join(orig_path, 'so')
        files = get_full_name(desktop_path, '.so')
        logger.debug('step: push so files to device')
        for fl in files:
            device.push(fl, so_path)

        #########################################################################
        # # reboot and unlock screen
        da = action.DeviceAction(uid)
        logger.debug('step: reboot device and unlock screen')
        da.reboot_device('default')
        da.unlock_screen('default')

        # set root permission before reboot
        device.adb('root')
        device.adb('remount')

        # push .xml file to /data/data/com.vlife.vivo.wallpaper/shared_prefs#
        device.push('/home/lang/testfile/function.xml',
                    '/data/data/com.vlife.vivo.wallpaper/shared_prefs')

        # self-activation
        pkg_name = module_config.getValue('SHELL_MODULE', 'pkg_name')
        acti_flag = module_config.getValue('SHELL_MODULE', 'self_activation')
        product_type = device_config.getValue(uid, 'product_type')
        if acti_flag.upper() == 'FALSE':
            logger.debug('step: access to vlife theme, start-up main process')
            if product_type.upper() == 'THEME':
                theme.set_device_theme(uid, 'vlife')

        # configure server option

        mid = module_config.getValue('SHELL_MODULE', 'module_id')
        try:

            logger.debug('step: config server and enable module ')
            tc.update_stage_module_status(int(mid), True)
            flag1 = tc.update_stage_module_network(int(mid), 1, 0)
            flag2 = tc.check_amount_limit(int(mid))
            if flag1 or flag2:
                config_srv.enableModule('STAGECONFIG')

            logger.debug('step: set date to after two months')
            da.update_time('DAYS-61')
            da.unlock_screen('default')
            #connect network and waiting for module download
            logger.debug('step: connect network and download module')
            for i in range(2):
                da.connect_network_trigger('CLOSE_ALL:ONLY_WIFI')

            #check module has download

            config_dict = {"module": mid}
            result = tc.get_all_module_info(config_dict)
            search_path = result['module']['path']
            soft_version = result['module']['version']
            full_path = os.path.join(r'/data/data/', pkg_name,
                                     os.path.dirname(search_path)).replace(
                                         '\\', '/')
            base_name = os.path.basename(search_path)
            res = device.find_file_from_appfolder(pkg_name, full_path)

            if res.find(base_name) != -1:
                logger.debug(
                    '***key step***: module is download successfully, ' +
                    search_path + ' has found')
                # reboot and unlock screen for applying module
                name = collect_log(uid, path_index, loop_number)
                # get pid of app
                pkg_process = pkg_name + ':main'
                pkg_pid = device.get_pid(pkg_process)
                #check log for login package and verify if module update
                loginfo = filter_log_result(name, 'jabber:iq:auth', pkg_pid)
                init_result = verify_pkg_content(loginfo, soft_version)

                if init_result:
                    logger.debug('***key step***: module is made effect for ' +
                                 str(mid))
                    # test basic func
                    sid = module_config.getValue('COMMON',
                                                 'basic_fun_suite_id')
                    cmd = ' '.join(['run', uid, str(sid)])
                    if count == 0:
                        logger.debug(
                            '***key step***: start to run basic test cases')
                        subprocess.call(cmd, shell=True, stdout=None)

                    # test new shell for upgrade
                    result = install_new_shell(new_shell, pkg_name,
                                               soft_version, uid, path_index,
                                               loop_number, new_shell_index)
                    if result:
                        logger.debug(
                            '***key step***:Install new shell is success for SHELL'
                            + str(new_shell_index))
                    else:
                        logger.error(
                            '***key step***:Install new shell is failed. login package is not right for SHELL'
                            + str(new_shell_index))
                        test_result = False

                else:
                    logger.error(
                        '***key step***:Login package content is not right, made effect is failed'
                    )
                    test_result = False
            else:
                logger.error(
                    '***key step***: module is not downloaded successfully')
                test_result = False
        except Exception, ex:
            print ex
            test_result = False

        count += 1

        result_list.append(test_result)
コード例 #3
0
def init_module_version(uid, test_path):

    init_result = False
    # # delete old apk file
    # logger.debug('step: delete old apk file')
    # del_path = module_config.getValue(test_path, 'device_delete_apk_path')
    # logger.debug('step: delete old apk file from ' + del_path)
    # del_path = os.path.join(del_path, '*.apk')
    # device.remove(del_path)
    #
    # # clear app
    # pkg_name = module_config.getValue(test_path, 'pkg_name')
    # logger.debug('step: clear pkg content ' + pkg_name)
    # device.clear_app_data(pkg_name)
    # logger.debug('step: clear system ui')
    # device.clear_app_data('com.android.systemui')
    #
    # # push new api file
    # source = module_config.getValue(test_path, 'push_orig_path')
    # target = module_config.getValue(test_path, 'push_dest_path')
    # logger.debug('step: push apk file to device')
    # device.push(source, target)

    #########################################################################
    # # reboot and unlock screen
    da = action.DeviceAction(uid)
    logger.debug('step: reboot device and unlock screen')
    da.reboot_device('default')
    da.unlock_screen('default')

    # self-activation
    pkg_name = module_config.getValue(test_path, 'pkg_name')
    acti_flag = module_config.getValue(test_path, 'self_activation')
    product_type = device_config.getValue(uid, 'product_type')
    if acti_flag.upper() == 'FALSE':
        logger.debug('step: access to vlife theme, start-up main process')
        if product_type.upper() == 'THEME':
            theme.set_device_theme(uid, 'vlife')

    # configure server option

    mid_list = module_config.getValue(test_path,
                                      'module_upgrade_path').split(';')
    count = 0
    try:
        for mid in mid_list:
            logger.debug('step: config server and enable module ')
            tc.update_stage_module_status(int(mid), True)
            flag1 = tc.update_stage_module_network(int(mid), 1, 0)
            flag2 = tc.check_amount_limit(int(mid))
            if flag1 or flag2:
                config_srv.enableModule('STAGECONFIG')
            #connect network and waiting for module download
            logger.debug('step: connect network and download module')
            for i in range(2):
                da.connect_network_trigger('CLOSE_ALL:ONLY_WIFI')

            #check module has download

            config_dict = {"module": mid}
            result = tc.get_all_module_info(config_dict)
            search_path = result['module']['path']
            soft_version = result['module']['version']
            full_path = os.path.join(r'/data/data/', pkg_name,
                                     os.path.dirname(search_path)).replace(
                                         '\\', '/')
            base_name = os.path.basename(search_path)
            res = device.find_file_from_appfolder(pkg_name, full_path)

            if res.find(base_name) != -1:
                logger.debug('step: module is download successfully, ' +
                             search_path + ' has found')
                # reboot and unlock screen for applying module
                logger.debug('step: reboot device')
                da.reboot_device('default')
                da.unlock_screen('default')

                # start collect log
                name = desktop.get_log_name(uid, 'SmokeModule')
                #LogPath = os.path.dirname(os.path.abspath(name))

                log_reader = dumplog.DumpLogcatFileReader(name, uid)
                log_reader.clear_logcat()
                log_reader.start()
                #connect network and waiting for module download
                logger.debug('step: connect network and download module')
                for i in range(2):
                    da.connect_network_trigger('CLOSE_ALL:ONLY_WIFI')
                sleep(10)
                log_reader.stop()

                # get pid of app
                pkg_pid = device.get_pid(pkg_name)
                #check log for login package and verify if module update
                loginfo = filter_log_result(name, 'jabber:iq:auth', pkg_pid)
                init_result = verify_pkg_content(loginfo, soft_version)

                if init_result:
                    logger.debug('step: module is made effect for ' + str(mid))
                    if count == len(mid_list) - 2:
                        sid = module_config.getValue('COMMON',
                                                     'basic_fun_suite_id')
                        cmd = ' '.join(['run', uid, str(sid)])
                        subprocess.Popen(cmd, shell=True, stdout=None)

                        # test new module for upgrade
                        device_config.setValue(uid, 'background_module_id1',
                                               mid_list[count + 1])
                        sid = module_config.getValue('COMMON',
                                                     'upgrade_fun_suite_id')
                        cmd = ' '.join(['run', uid, str(sid)])
                        subprocess.call(cmd, shell=True, stdout=None)
                        break
                    count += 1
                else:
                    logger.error('step: module is not made effect for ' +
                                 str(mid))
                    break
            else:
                logger.error('step: module is not downloaded successfully')
                break

    except Exception, ex:
        print ex
コード例 #4
0
                           type=int,
                           help="Loop number")
    args = newParser.parse_args()
    uid = args.uid
    loop_number = args.lnum
    if uid is None:
        sys.exit(0)

    device = adbtools.AdbTools(uid)
    # verify if device is connected
    devices = device.get_devices()
    if uid not in devices:
        print "Device is not connected, please check"
        sys.exit(0)

    test_paths = module_config.getValue('SHELL_MODULE',
                                        'orig_shell_path').split(';')

    for tp in test_paths:
        index = test_paths.index(tp)
        logger.debug('***key step***:Start to test ========PATH_' + str(index))
        loop_result = []
        for i in range(loop_number):
            logger.debug('***key step***:========LOOP_' + str(i))
            result_list = init_module_version(uid, tp, index, i)
            for re in result_list:
                ind = result_list.index(re)
                if re:
                    logger.debug('***key step****:upgrade success form A_' +
                                 str(index) + 'to B_' + str(ind))
                else:
                    logger.error('***key step****:upgrade failed form A_ ' +
コード例 #5
0
                break

    except Exception, ex:
        print ex


if __name__ == '__main__':

    global device

    newParser = argparse.ArgumentParser()
    newParser.add_argument("uid", help="Your device uid")
    args = newParser.parse_args()
    uid = args.uid
    if uid is None:
        sys.exit(0)

    device = adbtools.AdbTools(uid)
    # verify if device is connected
    devices = device.get_devices()
    if uid not in devices:
        print "Device is not connected, please check"
        sys.exit(0)
    test_paths = module_config.getValue('COMMON', 'tags').split(';')
    for tp in test_paths:
        init_module_version(uid, tp)
        # set all module to disable
        mid_list = module_config.getValue(tp, 'module_upgrade_path').split(';')
        for mid in mid_list:
            tc.update_stage_module_status(mid, False)
            config_srv.enableModule('STAGECONFIG')