Example #1
0
def backup_to_local():
    work_dir = cur_loc + "/" + QSST_BACKUP + "/" + PREFIX + curTime
    makedirs(work_dir)
    makedirs(work_dir + "/settings")
    copy(cur_loc + "/settings/config.xml", work_dir + "/settings")
    suit_list = fs_wrapper.get_suit_name_list(cur_loc + "/")
    for suit in suit_list:
        makedirs(work_dir + "/" + suit)
        copy(cur_loc + "/" + suit + "/" + suit + ".xml", work_dir + "/" + suit)
        case_list = fs_wrapper.get_all_cases_py_module_name(suit, False)
        for case in case_list:
            copy(cur_loc + "/" + suit + "/" + case[1] + ".xml",
                 work_dir + "/" + suit)

    bg_suit_list = fs_wrapper.get_suit_name_list(cur_loc + "/" +
                                                 BACKGROUND_CASE_POOL + "/")
    for bg_suit in bg_suit_list:
        makedirs(work_dir + "/" + BACKGROUND_CASE_POOL + "/" + bg_suit)
        copy(
            cur_loc + "/" + BACKGROUND_CASE_POOL + "/" + bg_suit + "/" +
            bg_suit + ".xml",
            work_dir + "/" + BACKGROUND_CASE_POOL + "/" + bg_suit)
        bg_case_list = fs_wrapper.get_all_cases_py_module_name(bg_suit, True)
        for bg_case in bg_case_list:
            copy(
                cur_loc + "/" + BACKGROUND_CASE_POOL + "/" + bg_suit + "/" +
                bg_case[1] + ".xml",
                work_dir + "/" + BACKGROUND_CASE_POOL + "/" + bg_suit)
Example #2
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)
                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
                #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,
                    case_app_name)
                test_case.case_config_map = case_config_map
                test_case.original_ClassName = ''
                test_case.runReason = CASE_BE_CALLED
                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()
                    success = case.test_case_run(case_results)
                    #checkout the current case name
                    set_cur_case_name(pre_case_name)
                    set_ignore_status(False)
                    if success == None:
                        return True
                    return success
            log_test_framework(LOG_TAG,
                               "can not find the case name:" + case_name)
            return False
Example #3
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
Example #4
0
    def getUnInteractiveCaseList(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)
                for case in cases:
                    case_config_map = fs_wrapper.get_test_case_config(
                        case[1], suit_name)
                    if case_config_map.get(fs_wrapper.CASE_ENABLE_ATTR) == '1':
                        if case_config_map.get(
                                fs_wrapper.CASE_INTERACTIVE_ATTR
                        ) != '1' or case_config_map.get(
                                fs_wrapper.CASE_INTERACTIVE_ATTR) == '':
                            all_case_name_list.append(
                                (suit_name + fs_wrapper.DOT_TAG + case[1],
                                 case[1]))
        return all_case_name_list
Example #5
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
Example #6
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
Example #7
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