def run_precondition(self, ntb_format):
        """
        Runs all the precondition sequences for data transfer tests.

        @param ntb_format: Whether to send/receive an NTB16 or NTB32 frame.
                Possible values: NTB_FORMAT_16, NTB_FORMAT_32 (mbim_constants)
        @returns tuple of (desc_sequence, open_sequence, connect_sequence) where,
                desc_sequence - Handle to run the get descriptor sequence.
                open_sequence - Handle to run the open sequence.
                connect_sequence - Handle to run the connect sequence.

        """
        desc_sequence = get_descriptors_sequence.GetDescriptorsSequence(
            self.device_context)
        descriptors = desc_sequence.run()
        self.device_context.update_descriptor_cache(descriptors)
        open_sequence = mbim_open_generic_sequence.MBIMOpenGenericSequence(
            self.device_context)
        open_sequence.run(ntb_format=ntb_format)
        connect_seq = connect_sequence.ConnectSequence(self.device_context)
        connect_seq.run()

        # Devices may not support SetNtbFormat(), so fail the NTB32 tests on
        # such devices.
        if ((ntb_format == mbim_constants.NTB_FORMAT_32)
                and (self.device_context.current_ntb_format != ntb_format)):
            mbim_errors.log_and_raise(
                mbim_errors.MBIMComplianceFrameworkError,
                'Device does not support NTB 32 format.')

        return (desc_sequence, open_sequence, connect_seq)
Пример #2
0
    def run_internal(self):
        """ Run CM_09 test. """
        # Precondition
        mbim_open_generic_sequence.MBIMOpenGenericSequence(
            self.test_context).run()

        # Step 1
        _, _, notifications = (connect_sequence.ConnectSequence(
            self.test_context).run())

        # Step 2
        for notification in notifications:
            if notification.transaction_id != 0:
                mbim_errors.log_and_raise(
                    mbim_errors.MBIMComplianceAssertionError, 'mbim1.0:9.1#1')
Пример #3
0
    def run_internal(self):
        """ Run CM_13 test. """
        # Precondition
        mbim_open_generic_sequence.MBIMOpenGenericSequence(
                self.test_context).run()
        connect_sequence.ConnectSequence(self.test_context).run()
        mbim_close_sequence.MBIMCloseSequence(self.test_context).run()
        mbim_open_generic_sequence.MBIMOpenGenericSequence(
                self.test_context).run()

        # Step 1
        connect_info_structure = mbim_data.MBIMConnectInfoStructure(
                session_id=0,
                activation_state=0,
                voice_call_state=0,
                ip_type=0,
                context_type=mbim_constants.MBIM_CONTEXT_TYPE_NONE.bytes,
                nw_error=0)
        command_message = mbim_control.MBIMCommandMessage(
                message_length=84,
                total_fragments=1,
                current_fragment=0,
                device_service_id=mbim_constants.UUID_BASIC_CONNECT.bytes,
                cid=mbim_constants.MBIM_CID_CONNECT,
                command_type=mbim_constants.COMMAND_TYPE_QUERY,
                information_buffer_length=36,
                information_buffer=connect_info_structure.pack())
        packets = command_message.generate_packets()
        channel = mbim_channel.MBIMChannel(
                {'idVendor': self.test_context.id_vendor,
                 'idProduct': self.test_context.id_product},
                self.test_context.mbim_communication_interface.bInterfaceNumber,
                self.test_context.interrupt_endpoint.bEndpointAddress,
                self.test_context.mbim_functional.wMaxControlMessage)
        response_packets = channel.bidirectional_transaction(*packets)
        channel.close()

        # Step 2
        response_message = mbim_control.parse_response_packets(response_packets)

        # Step 3
        if (response_message.status_codes !=
            mbim_constants.MBIM_STATUS_CONTEXT_NOT_ACTIVATED):
            mbim_errors.log_and_raise(mbim_errors.MBIMComplianceAssertionError,
                                      'mbim1.0:9.3.2#3')
Пример #4
0
    def run_internal(self):
        """ Run CM_09 test. """
        # Precondition
        descriptors = get_descriptors_sequence.GetDescriptorsSequence(
            self.device_context).run()
        self.device_context.update_descriptor_cache(descriptors)
        mbim_open_generic_sequence.MBIMOpenGenericSequence(
            self.device_context).run()

        # Step 1
        _, _, notifications = (connect_sequence.ConnectSequence(
            self.device_context).run())

        # Step 2
        for notification in notifications:
            if notification.transaction_id != 0:
                mbim_errors.log_and_raise(
                    mbim_errors.MBIMComplianceAssertionError, 'mbim1.0:9.1#1')
Пример #5
0
    def run_internal(self):
        """ Run CM_14 test. """
        # Precondition
        descriptors = get_descriptors_sequence.GetDescriptorsSequence(
            self.device_context).run()
        self.device_context.update_descriptor_cache(descriptors)
        mbim_open_generic_sequence.MBIMOpenGenericSequence(
            self.device_context).run()
        mbim_close_sequence.MBIMCloseSequence(self.device_context).run()

        # Step 1
        _, response_message, _ = (connect_sequence.ConnectSequence(
            self.device_context).run(raise_exception_on_failure=False))

        # Step 2
        if ((response_message.message_type !=
             mbim_constants.MBIM_FUNCTION_ERROR_MSG)
                or (response_message.message_length != 16)):
            mbim_errors.log_and_raise(mbim_errors.MBIMComplianceAssertionError,
                                      'mbim1.0:9.3.4#2')
Пример #6
0
    def run_internal(self):
        """ Run ERR_04 test. """
        # Precondition
        descriptors = get_descriptors_sequence.GetDescriptorsSequence(
            self.device_context).run()
        self.device_context.update_descriptor_cache(descriptors)
        open_sequence = mbim_open_generic_sequence.MBIMOpenGenericSequence(
            self.device_context)
        open_sequence.run(max_control_transfer_size=64)

        # Step 1
        request_message, response_message, _ = (
            connect_sequence.ConnectSequence(self.device_context).run(
                introduce_error_in_packets_order=[1, 0, 2],
                raise_exception_on_failure=False))

        # Step 2
        if ((response_message.transaction_id != request_message.transaction_id)
                or (response_message.message_type
                    == mbim_constants.MBIM_COMMAND_DONE)):
            mbim_errors.log_and_raise(mbim_errors.MBIMComplianceAssertionError,
                                      'mbim1.0:9.3.4.2#3')
Пример #7
0
    def run_internal(self):
        """ Run ERR_02 test. """
        # Precondition
        descriptors = get_descriptors_sequence.GetDescriptorsSequence(
            self.device_context).run()
        self.device_context.update_descriptor_cache(descriptors)
        open_sequence = mbim_open_generic_sequence.MBIMOpenGenericSequence(
            self.device_context)
        open_sequence.run(max_control_transfer_size=64)

        # Step 1
        request_message, response_message, _ = (
            connect_sequence.ConnectSequence(self.device_context).run(
                introduce_error_in_packets_order=[1, 0, 2],
                raise_exception_on_failure=False))

        # Step 2
        if ((response_message.message_type !=
             mbim_constants.MBIM_FUNCTION_ERROR_MSG)
                or (response_message.error_status_code !=
                    mbim_constants.MBIM_ERROR_FRAGMENT_OUT_OF_SEQUENCE)):
            mbim_errors.log_and_raise(mbim_errors.MBIMComplianceAssertionError,
                                      'mbim1.0:9.3.4#3')
Пример #8
0
    def run_internal(self):
        """ Run ERR_05 test. """
        # Precondition
        descriptors = get_descriptors_sequence.GetDescriptorsSequence(
                self.device_context).run()
        self.device_context.update_descriptor_cache(descriptors)
        open_sequence = mbim_open_generic_sequence.MBIMOpenGenericSequence(
                self.device_context)
        open_sequence.run(max_control_transfer_size=64)

        # Step 1
        request_message, first_response_message, notifications = (
                connect_sequence.ConnectSequence(self.device_context).run(
                        introduce_error_in_packets_order=[1, 1],
                        raise_exception_on_failure=False))

        if len(notifications) > 1:
            mbim_errors.log_and_raise(
                    mbim_errors.MBIMComplianceTestError,
                    'Not expecting more than 1 pending response.')
        second_response_message = notifications[0]

        # Step 2
        if (((first_response_message.transaction_id !=
              request_message.transaction_id) or
             (first_response_message.message_type !=
              mbim_constants.MBIM_FUNCTION_ERROR_MSG) or
             (first_response_message.error_status_code !=
              mbim_constants.MBIM_ERROR_FRAGMENT_OUT_OF_SEQUENCE)) or
            ((second_response_message.transaction_id !=
              request_message.transaction_id) or
             (second_response_message.message_type !=
              mbim_constants.MBIM_FUNCTION_ERROR_MSG) or
             (second_response_message.error_status_code !=
              mbim_constants.MBIM_ERROR_FRAGMENT_OUT_OF_SEQUENCE))):
            mbim_errors.log_and_raise(mbim_errors.MBIMComplianceAssertionError,
                                      'mbim1.0:9.3.4.2#4')