Ejemplo n.º 1
0
    def loadTestSuitFromName(self, suit_module_name, suit_name):
        '''
        load test suit from name

        @type suit_module_name: string
        @param suit_module_name: suit module name
        @type suit_name: string
        @param suit_name: suit name
        @return: return the suit instance
        '''
        suit_config_map = fs_wrapper.get_test_suit_config(suit_name)
        if suit_config_map.get(fs_wrapper.SUIT_ENABLE_ATTR) != '1':
            return None
        suit_info = None

        # create test suit instance
        test_suit = TestSuitBase.createInstance(suit_module_name + fs_wrapper.DOT_TAG + suit_name, suit_name, suit_info)
        if suit_config_map.get(fs_wrapper.SUIT_RUNNER_ATTR) != None:
            test_suit.runner = suit_config_map.get(fs_wrapper.SUIT_RUNNER_ATTR)
        if suit_config_map.get(fs_wrapper.SUIT_APP_NAME) != None:
            app_name =  suit_config_map.get(fs_wrapper.SUIT_APP_NAME)


        # load test cases for test suit.
        # It will aggregate all the relative suit info for this test suit, too.
        cases = fs_wrapper.get_all_cases_py_module_name(test_suit.name)
        #relative_suits = []
        status = 0
        if is_suit_in_reboot_status(suit_name) and is_in_reboot_status():
            status = 1
        log_test_framework(TAG, "suit_name:"+suit_name)
        for case in cases:
            log_test_framework(TAG, "check case:"+case[1])
            if status == 1 and not is_case_in_reboot_status(case[1]):
                log_test_framework(TAG,  "status == 1 and not is_case_in_reboot_status")
                continue
            elif status == 1 and is_case_in_reboot_status(case[1]):
                log_test_framework(TAG,  "status == 1 and is_case_in_reboot_status")
                status = 2
                if get_reboot_reason() == REBOOT_CRASH:
                    log_test_framework(TAG,  "get_reboot_reason() == REBOOT_CRASH")
                    qsst_log_restore_reboot()
                    continue
                qsst_log_restore_reboot()
            log_test_framework(TAG,  "add case:"+case[1])
            case_config_map = fs_wrapper.get_test_case_config(case[1], test_suit.name)
            if case_config_map.get(fs_wrapper.CASE_ENABLE_ATTR) == '1':
                case_app_name = case_config_map.get(fs_wrapper.CASE_APP_NAME)
                if case_app_name == None or case_app_name == "":
                    case_app_name = app_name
                else:
                    log_test_framework(TAG,'case_app_name null')
                reference = case_config_map.get(fs_wrapper.CASE_REFERENCE);
                if reference != None and reference!= "":
                    (suit_name, case_name) = reference.rsplit('.', 1)
                    class_name = reference + fs_wrapper.DOT_TAG + case_name
                    self.addTestCase(test_suit,case_config_map,class_name, suit_name,case_name, case_app_name)
                else:
                    self.addTestCase(test_suit,case_config_map,case[0] + fs_wrapper.DOT_TAG + case[1], suit_name,case[1], case_app_name)
        return test_suit
Ejemplo n.º 2
0
    def test_case_init(self):
        '''
        init the test case . such as: set the L{current_case_continue_flag<current_case_continue_flag>} to True;
        save the current case name; init the logging; launcher this application
        '''
        case_config_map = fs_wrapper.get_test_case_config(
            self.name, self.suit_name)
        global case_des
        case_des = case_config_map.get(fs_wrapper.CASE_DESCRIPTION)
        if case_des == None:
            case_des = ''

        #if auto insert case waypoint.
        if SC.PRIVATE_TRACKING_AUTO_INSERT_CASE_WAYPOINT:
            if int(SC.PUBLIC_RUNNING_REPEAT_NUMBER) == 1:
                case_utility.insert_waypoint(
                    case_utility.START_RUN + self.name, case_des)
            else:
                case_utility.insert_waypoint(
                    case_utility.START_RUN + '(' + str(self.cycle_index) +
                    '/' + str(SC.PUBLIC_RUNNING_REPEAT_NUMBER) + ') ' +
                    self.name, case_des)

        if getprop_suspend():
            log_test_case('TestCaseBase', 'enable touch panel')
            enableTouchPanel()
            log_test_case('TestCaseBase', 'end enable touch panel')

        if getprop_suspend():
            signal.signal(signal.SIGUSR1, OnshakeSignal_handler)
            log_test_case(
                'suspend',
                'suspended, wait for shake-signal from java resume --- 3')
            signal.pause()
            log_test_case(
                'Finally!!!',
                'good luck, already gotten signal and resumed.... --- 4')
        log_test_framework(self.name, 'case init...')
        set_can_continue()
        if (self.runReason == CASE_BE_REFERED):
            (ori_suit_name,
             ori_case_name) = self.original_ClassName.rsplit('.', 1)
            set_cur_case_name(ori_case_name)
        elif (self.runReason == CASE_RUN_SELF):
            set_cur_case_name(self.name)
        qsst_log_case_init()
        clear_logcat()
        #deal with watcher ANR and FC
        global enable_watcher_anr_fc
        enable_watcher_anr_fc = case_config_map.get(
            fs_wrapper.CASE_ENABLE_WATCHER_ANR_AND_FC)
        if (enable_watcher_anr_fc == '0'):
            case_utility.disable_watcher_anr_fc()
Ejemplo n.º 3
0
def call(suit_name,case_name,config_file_name='all_suit_config'):
    log_test_framework(LOG_TAG,  "begin call ... ")
    suit_names = fs_wrapper.get_suit_name_list("./")
    test_config_map = fs_wrapper.get_test_config(config_file_name)
    for suit in suit_names:
        if suit ==suit_name:
            #continue
            suit_py_module_name = fs_wrapper.get_suit_py_module_name(suit_name)
            if len(suit_py_module_name) == 0:
                continue
            # load the suit config
            suit_config_map = fs_wrapper.get_test_suit_config(suit_name)
            #check the suit whether is enable
            #if suit_config_map.get(fs_wrapper.SUIT_ENABLE_ATTR) != '1':
            #    log_test_framework(LOG_TAG, "the suit is disable")
            #    return
            #create the suit//suit_module_name + fs_wrapper.DOT_TAG + suit_name
            suit_info = test_config_map.get(suit_name)
            test_suit = createInstance(suit_py_module_name + fs_wrapper.DOT_TAG + suit_name, suit_name,suit_info)
            if suit_config_map.get(fs_wrapper.SUIT_RUNNER_ATTR) != None:
                test_suit.runner = suit_config_map.get(fs_wrapper.SUIT_RUNNER_ATTR)
            if suit_config_map.get(fs_wrapper.SUIT_APP_NAME) != None:
                app_name =  suit_config_map.get(fs_wrapper.SUIT_APP_NAME)
            # load test cases for test suit.
            # It will aggregate all the relative suit info for this test suit, too.
            case_names = fs_wrapper.get_all_cases_py_module_name(test_suit.name)
            for case in case_names:
                case_config_map = fs_wrapper.get_test_case_config(case[1], test_suit.name)
                #if case_config_map.get(fs_wrapper.CASE_ENABLE_ATTR) == '1':
                test_case = createInstance(case[0] + fs_wrapper.DOT_TAG + case[1], case[1], suit_name, app_name)
                test_case.case_config_map = case_config_map
                test_suit.addCase(test_case)
            case_results = []
            for case in test_suit.test_cases:
                if case_name == "" or case.name == case_name:
                    set_ignore_status(True)
                    #save the current case name
                    pre_case_name = get_cur_case_name()
                    case.test_case_run(case_results)
                    #checkout the current case name
                    set_cur_case_name(pre_case_name)
                    set_ignore_status(False)
            log_test_framework(LOG_TAG,  "can not find the case name:"+case_name)
            return False
    log_test_framework(LOG_TAG,  "can not find the suit name:"+suit_name)
    return False
Ejemplo n.º 4
0
def qsst_log_case_init():
    '''
    ini the logging file for the case.and save the case beginning information to the report logging file which suffix is "qsst"
    '''
    global qsst_log_path
    global total_case
    global ignore_status
    if ignore_status:
        qsst_log_msg("ignore init "+cur_case_name)
    elif is_case_in_reboot_status(cur_case_name):
        qsst_log_msg("reboot init "+cur_case_name)
    else:
        #total_case = total_case+1
        update_case_count(TOTAL_CASE, 1)
        __write_log(PREFIX_CASE+DIVIDE+cur_suit_name+DIVIDE+cur_case_name, qsst_log_path)
        #write case starting to status file
        __write_status(PREFIX_CASE+DIVIDE+cur_suit_name+DIVIDE+cur_case_name)
        from fs_wrapper import get_test_case_config,SUIT_DESCRIPTION
        case_config_map = get_test_case_config(cur_case_name, cur_suit_name)
        if case_config_map.has_key(SUIT_DESCRIPTION):
            __write_log(PREFIX_DESCRIPTION+DIVIDE+case_config_map.get(SUIT_DESCRIPTION), qsst_log_path)
Ejemplo n.º 5
0
def qsst_log_case_init():
    '''
    ini the logging file for the case.and save the case beginning information to the report logging file which suffix is "qsst"
    '''
    global qsst_log_path
    global total_case
    global ignore_status
    if ignore_status:
        qsst_log_msg("ignore init "+cur_case_name)
    elif is_case_in_reboot_status(cur_case_name):
        qsst_log_msg("reboot init "+cur_case_name)
    else:
        #total_case = total_case+1
        update_case_count(TOTAL_CASE, 1)
        __write_log(PREFIX_CASE+DIVIDE+cur_suit_name+DIVIDE+cur_case_name, qsst_log_path)
        #write case starting to status file
        __write_status(PREFIX_CASE+DIVIDE+cur_suit_name+DIVIDE+cur_case_name)
        from fs_wrapper import get_test_case_config,SUIT_DESCRIPTION
        case_config_map = get_test_case_config(cur_case_name, cur_suit_name)
        if case_config_map.has_key(SUIT_DESCRIPTION):
            __write_log(PREFIX_DESCRIPTION+DIVIDE+case_config_map.get(SUIT_DESCRIPTION), qsst_log_path)
Ejemplo n.º 6
0
    def getCaseList(self, base_path):
        '''
        load the test cases from the path

        @type base_path: string
        @param base_path: the path of the case
        @return: return all the cases which can found under this path
        '''
        all_case_name_list = []
        suit_name_list = fs_wrapper.get_suit_name_list(base_path)
        for suit_name in suit_name_list:
            suit_config_map = fs_wrapper.get_test_suit_config(suit_name)
            if suit_config_map.get(fs_wrapper.SUIT_ENABLE_ATTR) == '1':
                cases = fs_wrapper.get_all_cases_py_module_name(suit_name)
                case_name_list = []
                for case in cases:
                    case_name_list.append(case[1])
                    for case_name in case_name_list:
                        case_config_map = fs_wrapper.get_test_case_config(case_name, suit_name)
                        if case_config_map.get(fs_wrapper.CASE_ENABLE_ATTR) == '1':
                            all_case_name_list.append((suit_name, case_name))
        return all_case_name_list
Ejemplo n.º 7
0
def __auto_log_env_context_info(status):
    '''
    auto log env context info with the status.

    @type status: int
    @param status: this status of the current cases. the values will be:
        L{STATUS_SUCCESS<STATUS_SUCCESS>},
        L{STATUS_FAILED<STATUS_FAILED>},
        L{STATUS_UNSUPPORTED<STATUS_UNSUPPORTED>},
        L{STATUS_UNKNOWN<STATUS_UNKNOWN>}.
    '''
    import settings.common as SC
    #config level: env_context_type is disable
    try:
        if SC.PUBLIC_AUTO_LOGGING_ENV_CONTEXT == AUTO_LOGGING_ENV_CONTEXT_TYPE_DISABLE:
            from fs_wrapper import get_test_case_config,CASE_AUTO_LOGGING_ENV_CONTEXT_ATTR,CASE_ITEMS_FOR_AUTO_LOGGING_ATTR
            case_config_map = get_test_case_config(cur_case_name, cur_suit_name)
            case_env_context_type = case_config_map.get(CASE_AUTO_LOGGING_ENV_CONTEXT_ATTR)
            case_env_context_items = case_config_map.get(CASE_ITEMS_FOR_AUTO_LOGGING_ATTR)
            if case_env_context_type == None:
                return
            elif case_env_context_type == AUTO_LOGGING_ENV_CONTEXT_TYPE_CASE_END:
                __write_log_env_context_info(case_env_context_items)
            elif case_env_context_type == AUTO_LOGGING_ENV_CONTEXT_TYPE_CASE_FAIL:
                if STATUS_FAILED == status:
                    __write_log_env_context_info(case_env_context_items)
            else:
                return
        #config level: env_context_type is case_end
        elif SC.PUBLIC_AUTO_LOGGING_ENV_CONTEXT == AUTO_LOGGING_ENV_CONTEXT_TYPE_CASE_END:
            __write_log_env_context_info(SC.PUBLIC_ENV_CONTEXT_ITEMS_FOR_AUTO_LOGGING)
        #config level: env_context_type is case_fail
        elif SC.PUBLIC_AUTO_LOGGING_ENV_CONTEXT == AUTO_LOGGING_ENV_CONTEXT_TYPE_CASE_FAIL:
            if STATUS_FAILED == status:
                __write_log_env_context_info(SC.PUBLIC_ENV_CONTEXT_ITEMS_FOR_AUTO_LOGGING)
    except AttributeError , why:
        log_test_framework(LOG_TAG, "write env context info failed:" + str(why))
        return
Ejemplo n.º 8
0
def __auto_log_env_context_info(status):
    '''
    auto log env context info with the status.

    @type status: int
    @param status: this status of the current cases. the values will be:
        L{STATUS_SUCCESS<STATUS_SUCCESS>},
        L{STATUS_FAILED<STATUS_FAILED>},
        L{STATUS_UNSUPPORTED<STATUS_UNSUPPORTED>},
        L{STATUS_UNKNOWN<STATUS_UNKNOWN>}.
    '''
    import settings.common as SC
    #config level: env_context_type is disable
    try:
        if SC.PUBLIC_AUTO_LOGGING_ENV_CONTEXT == AUTO_LOGGING_ENV_CONTEXT_TYPE_DISABLE:
            from fs_wrapper import get_test_case_config,CASE_AUTO_LOGGING_ENV_CONTEXT_ATTR,CASE_ITEMS_FOR_AUTO_LOGGING_ATTR
            case_config_map = get_test_case_config(cur_case_name, cur_suit_name)
            case_env_context_type = case_config_map.get(CASE_AUTO_LOGGING_ENV_CONTEXT_ATTR)
            case_env_context_items = case_config_map.get(CASE_ITEMS_FOR_AUTO_LOGGING_ATTR)
            if case_env_context_type == None:
                return
            elif case_env_context_type == AUTO_LOGGING_ENV_CONTEXT_TYPE_CASE_END:
                __write_log_env_context_info(case_env_context_items)
            elif case_env_context_type == AUTO_LOGGING_ENV_CONTEXT_TYPE_CASE_FAIL:
                if STATUS_FAILED == status:
                    __write_log_env_context_info(case_env_context_items)
            else:
                return
        #config level: env_context_type is case_end
        elif SC.PUBLIC_AUTO_LOGGING_ENV_CONTEXT == AUTO_LOGGING_ENV_CONTEXT_TYPE_CASE_END:
            __write_log_env_context_info(SC.PUBLIC_ENV_CONTEXT_ITEMS_FOR_AUTO_LOGGING)
        #config level: env_context_type is case_fail
        elif SC.PUBLIC_AUTO_LOGGING_ENV_CONTEXT == AUTO_LOGGING_ENV_CONTEXT_TYPE_CASE_FAIL:
            if STATUS_FAILED == status:
                __write_log_env_context_info(SC.PUBLIC_ENV_CONTEXT_ITEMS_FOR_AUTO_LOGGING)
    except AttributeError , why:
        log_test_framework(LOG_TAG, "write env context info failed:" + str(why))
        return