• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2014 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import common
6from autotest_lib.client.cros.cellular.mbim_compliance import mbim_constants
7from autotest_lib.client.cros.cellular.mbim_compliance import mbim_errors
8from autotest_lib.client.cros.cellular.mbim_compliance import mbim_test_base
9from autotest_lib.client.cros.cellular.mbim_compliance.sequences \
10        import connect_sequence
11from autotest_lib.client.cros.cellular.mbim_compliance.sequences \
12        import get_descriptors_sequence
13from autotest_lib.client.cros.cellular.mbim_compliance.sequences \
14        import mbim_open_generic_sequence
15
16
17class cellular_MbimComplianceERR05(mbim_test_base.MbimTestBase):
18    """
19    Validation of issuing a new error message.
20
21    This test verifies that another error message with status code
22    MBIM_ERROR_FRAGMENT_OUT_OF_SEQUENCE is issued when another message with
23    out-of-order fragmentation with the same TransactionId is received.
24
25    Reference:
26        [1] Universal Serial Bus Communication Class MBIM Compliance Testing: 46
27        http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf
28
29    """
30    version = 1
31
32    def run_internal(self):
33        """ Run ERR_05 test. """
34        # Precondition
35        descriptors = get_descriptors_sequence.GetDescriptorsSequence(
36                self.device_context).run()
37        self.device_context.update_descriptor_cache(descriptors)
38        open_sequence = mbim_open_generic_sequence.MBIMOpenGenericSequence(
39                self.device_context)
40        open_sequence.run(max_control_transfer_size=64)
41
42        # Step 1
43        request_message, first_response_message, notifications = (
44                connect_sequence.ConnectSequence(self.device_context).run(
45                        introduce_error_in_packets_order=[1, 1],
46                        raise_exception_on_failure=False))
47
48        if len(notifications) > 1:
49            mbim_errors.log_and_raise(
50                    mbim_errors.MBIMComplianceTestError,
51                    'Not expecting more than 1 pending response.')
52        second_response_message = notifications[0]
53
54        # Step 2
55        if (((first_response_message.transaction_id !=
56              request_message.transaction_id) or
57             (first_response_message.message_type !=
58              mbim_constants.MBIM_FUNCTION_ERROR_MSG) or
59             (first_response_message.error_status_code !=
60              mbim_constants.MBIM_ERROR_FRAGMENT_OUT_OF_SEQUENCE)) or
61            ((second_response_message.transaction_id !=
62              request_message.transaction_id) or
63             (second_response_message.message_type !=
64              mbim_constants.MBIM_FUNCTION_ERROR_MSG) or
65             (second_response_message.error_status_code !=
66              mbim_constants.MBIM_ERROR_FRAGMENT_OUT_OF_SEQUENCE))):
67            mbim_errors.log_and_raise(mbim_errors.MBIMComplianceAssertionError,
68                                      'mbim1.0:9.3.4.2#4')
69