def end_inner_iterator_if_required(active_iterator_handle):
    itr_result_obj = iterator_utils.get_leaf_iterator()
    root_result = iterator_utils.get_stm_test_result_throw()

    if itr_result_obj is None or \
            itr_result_obj.GetObjectHandle() == root_result.GetObjectHandle() or \
            itr_result_obj.Get(Iterator.get_stc_property_Iterator()) == active_iterator_handle:
        logger.debug('Either new iterator or leaf iterator.')
        return
    # find if new iterator or existing iterator with missing child end iterator
    while itr_result_obj is not None and \
            itr_result_obj.GetObjectHandle() != root_result.GetObjectHandle() and \
            itr_result_obj.Get(Iterator.get_stc_property_Iterator()) != active_iterator_handle:

        itr_result_obj = itr_result_obj.GetParent()
        logger.debug_result_object_info(itr_result_obj)
    if itr_result_obj.GetObjectHandle() == root_result.GetObjectHandle() or \
            itr_result_obj.Get(Iterator.get_stc_property_Iterator()) != active_iterator_handle:
        logger.debug('No existing iterator found with same handle')
        return
    # call end iterator for missing
    leaf_iterator = iterator_utils.get_leaf_iterator()
    while leaf_iterator.Get(Iterator.get_stc_property_Iterator()) != active_iterator_handle:
        logger.error('Missing end iterator for child iterator')
        end_iterator()
        leaf_iterator = iterator_utils.get_leaf_iterator()
Example #2
0
 def set_iterator_result(self):
     logger.debug('Set iterator result object.')
     if self._stc_result_object is None:
         self._stc_result_object = iterator_utils.get_iterator(self._iterator_handle)
         if self._stc_result_object is None:
             self.create_new_iterator()
     logger.debug('Set iterator results object completed.')
def get_last_iteration_info_status(iterator_handle):
    logger.info('Get last iteration info for iterator:' + str(iterator_handle))
    result = iterator_utils.get_iterator_result_no_leaf_check(iterator_handle)
    if result is None:
        return None
    iterator = Iterator(iterator_handle, result)
    return iterator.get_last_iteration_data()
Example #4
0
 def create_new_iterator(self):
     logger.info('Create new iterator.')
     self._stc_result_object = iterator_utils.create_iterator_result()
     self.set_stc_object(self.stc_property_Iterator, str(self._iterator_handle))
     self._info = IteratorInfo(self._iterator_param)
     self._status = Status(EnumExecStatus.created)
     self.commit_info_status()
     logger.debug('Create new iterator completed.')
     logger.log_result_info_status(self._stc_result_object)
def test_create_stm_get_stm(stc, resource_cleanup):
    mm = meth_man_utils.get_meth_manager()
    assert mm is not None
    assert result_obj.get_stm_test_result() is None
    stm_result = mm.GetObject('StmTestResult')
    assert stm_result is None
    stm_result = result_obj.create_stm_test_result_under_mm()
    assert stm_result is not None
    stm_mm = mm.GetObject('StmTestResult')
    assert stm_result.GetObjectHandle() == stm_mm.GetObjectHandle()
    stm3 = result_obj.get_stm_test_result()
    assert stm3 is not None
    assert stm_result.GetObjectHandle() == stm3.GetObjectHandle()
    # check leaf iterator is none
    assert iterator_utils.get_leaf_iterator() is None
    # check StmTestResult is active result
    stm4 = iterator_utils.get_active_result_object()
    assert stm4 is not None
    assert stm_result.GetObjectHandle() == stm4.GetObjectHandle()
def complete_iteration():
    logger.info('Complete iteration.')
    itr_result_obj = iterator_utils.get_leaf_iterator()
    if itr_result_obj is None:
        logger.error('There is no iterator running to complete iteration.')
        return
    logger.debug_result_object_info(itr_result_obj)
    iterator = Iterator(0, itr_result_obj)
    iterator.complete_active_iteration()
    logger.debug('Complete iteration completed.')
def end_iterator(force_stop=False):
    logger.info('End iteration.')
    itr_result_obj = iterator_utils.get_leaf_iterator()
    if itr_result_obj is None:
        logger.error('There is no iterator running to end iterator.')
        return
    iterator = Iterator(0, itr_result_obj)
    data = iterator.complete(force_stop)
    parentIterator = iterator_utils.get_leaf_iterator_no_throw()
    if parentIterator is None:
        logger.info('Adding iteration result to Test.')
        data[pc.STATUS][pc.APPLY_VERDICT] = True
        test_result = TestResult()
        test_result.add_provider_data(data)
    else:
        logger.info('Adding iteration result to parent iterator.')
        logger.debug_result_object_info(itr_result_obj)
        parent_itr = Iterator(0, parentIterator)
        parent_itr.add_child_iterator_data(data)
    logger.debug('End iteration completed')
def add_provider_result(dict_data):
    """Add provider result to active result object.
    It is leaf iterator result object in case of iterative test.
    Do not throw error if result object does not exist.
    Try to create one and continue.
    """
    logger.info('Add provider result.')
    # make sure test in created and running. If not do that first.
    start_test_if_required()
    result = iterator_utils.get_active_result_object()
    logger.debug_result_object_info(result)
    dict_data = result_utils.insert_report_group_if_not_defined(dict_data)
    result_obj.add_provider_data(result, dict_data)
Example #9
0
    def generate_report(self):
        result_utils.summarize_status(self)
        parent_itr_info = iterator_utils.get_parent_active_info(self._stc_result_object)
        self._info.set_data_format(self._info, EnumDataFormat.group)
        self._info.set_data_class(self._info, EnumDataClass.iteration_report)
        report = self._info.run_time_data
        if parent_itr_info and len(parent_itr_info) > 0:
            report[self._info.dict_name]['parent_iteration_info'] = parent_itr_info
        report[self._status.dict_name] = self._status.run_time_data
        report[ResultBase.get_data_dict_name()] = \
            result_utils.group_data_using_report_group(self._data)

        report_name = self.get_report_file_name(parent_itr_info)
        # add report name to info
        report[self._info.dict_name]['resultFile'] = report_name
        result_utils.generate_report_file(report_name, report)
        # return status
        status = {}
        status[Status.get_verdict_dict_name()] = self._status.verdict
        status[Status.get_verdict_text_dict_name()] = self._status._verdict_text
        status[IterationInfo.get_result_file_dict_name()] = report_name
        return status
def test_iterato_utils_create_get(stc, resource_cleanup):
    # check there are no result objects to start with
    assert result_obj.get_stm_test_result() is None
    # create iterator result which should create StmTestResult as well
    iterator_result_1 = iterator_utils.create_iterator_result()
    assert iterator_result_1 is not None
    stm_result = result_obj.get_stm_test_result()
    assert stm_result is not None
    parent_1 = iterator_result_1.GetParent()
    assert parent_1 is not None
    assert stm_result.GetObjectHandle() == parent_1.GetObjectHandle()
    # check leaf iterator
    iterator_result_3 = iterator_utils.get_leaf_iterator()
    assert iterator_result_3 is not None
    assert iterator_result_3.GetObjectHandle() == iterator_result_1.GetObjectHandle()
    # create one more iterator
    child_1 = iterator_utils.create_iterator_result()
    assert child_1 is not None
    # check parent is previous iterator
    parent_2 = child_1.GetParent()
    assert parent_2 is not None
    assert parent_2.GetObjectHandle() == iterator_result_3.GetObjectHandle()
    # new child should be leaf now
    child_3 = iterator_utils.get_leaf_iterator()
    assert child_3 is not None
    assert child_3.GetObjectHandle() == child_1.GetObjectHandle()
    # active result is same as well
    active_1 = iterator_utils.get_active_result_object()
    assert active_1 is not None
    assert child_3.GetObjectHandle() == active_1.GetObjectHandle()
    # reset results
    result_obj.reset()
    stm_2 = iterator_utils.get_active_result_object()
    assert stm_2 is not None
    assert stm_result.GetObjectHandle() == stm_2.GetObjectHandle()
    # check there are no iterator results
    assert iterator_utils.get_leaf_iterator() is None
    assert stm_2.GetObject('StmIteratorResult') is None
def end_all_iterators(force_stop):
    itr_result_obj = iterator_utils.get_leaf_iterator()
    while itr_result_obj is not None:
        logger.error('End iterator call is missing.')
        end_iterator(force_stop)
        itr_result_obj = iterator_utils.get_leaf_iterator()