• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2015 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_channel
7from autotest_lib.client.cros.cellular.mbim_compliance \
8        import mbim_command_message
9from autotest_lib.client.cros.cellular.mbim_compliance import mbim_constants
10from autotest_lib.client.cros.cellular.mbim_compliance import mbim_errors
11from autotest_lib.client.cros.cellular.mbim_compliance \
12        import mbim_message_request
13from autotest_lib.client.cros.cellular.mbim_compliance \
14        import mbim_message_response
15from autotest_lib.client.cros.cellular.mbim_compliance \
16        import mbim_test_base
17from autotest_lib.client.cros.cellular.mbim_compliance.sequences \
18        import connect_sequence
19from autotest_lib.client.cros.cellular.mbim_compliance.sequences \
20        import get_descriptors_sequence
21from autotest_lib.client.cros.cellular.mbim_compliance.sequences \
22        import mbim_close_sequence
23from autotest_lib.client.cros.cellular.mbim_compliance.sequences \
24        import mbim_open_generic_sequence
25
26
27class cellular_MbimComplianceCM13(mbim_test_base.MbimTestBase):
28    """
29    CM_13 Validation of active context termination on function's closing.
30
31    This test verifies that no any active context exists after closing of the
32    function.
33
34    Reference:
35        [1] Universal Serial Bus Communication Class MBIM Compliance Testing: 42
36        http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf
37
38    """
39    version = 1
40
41    def run_internal(self):
42        """ Run CM_13 test. """
43        # Precondition
44        descriptors = get_descriptors_sequence.GetDescriptorsSequence(
45                self.device_context).run()
46        self.device_context.update_descriptor_cache(descriptors)
47        mbim_open_generic_sequence.MBIMOpenGenericSequence(
48                self.device_context).run()
49        connect_sequence.ConnectSequence(self.device_context).run()
50        mbim_close_sequence.MBIMCloseSequence(self.device_context).run()
51        mbim_open_generic_sequence.MBIMOpenGenericSequence(
52                self.device_context).run()
53
54        # Step 1
55        device_context = self.device_context
56        descriptor_cache = device_context.descriptor_cache
57        command_message = mbim_command_message.MBIMConnectQuery(session_id=0)
58        packets = mbim_message_request.generate_request_packets(
59                command_message,
60                device_context.max_control_transfer_size)
61        channel = mbim_channel.MBIMChannel(
62                device_context._device,
63                descriptor_cache.mbim_communication_interface.bInterfaceNumber,
64                descriptor_cache.interrupt_endpoint.bEndpointAddress,
65                device_context.max_control_transfer_size)
66        response_packets = channel.bidirectional_transaction(*packets)
67        channel.close()
68
69        # Step 2
70        response_message = mbim_message_response.parse_response_packets(
71                response_packets)
72
73        # Step 3
74        if (response_message.status_codes !=
75            mbim_constants.MBIM_STATUS_CONTEXT_NOT_ACTIVATED):
76            mbim_errors.log_and_raise(mbim_errors.MBIMComplianceAssertionError,
77                                      'mbim1.0:9.3.2#3')
78