• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 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
5"""
6CM_13 Validation of Active Context Termination on Function's Closing
7
8Reference:
9    [1] Universal Serial Bus Communication Class MBIM Compliance Testing: 42
10        http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf
11"""
12import common
13
14from autotest_lib.client.cros.cellular.mbim_compliance import mbim_channel
15from autotest_lib.client.cros.cellular.mbim_compliance import mbim_constants
16from autotest_lib.client.cros.cellular.mbim_compliance import mbim_control
17from autotest_lib.client.cros.cellular.mbim_compliance import mbim_data
18from autotest_lib.client.cros.cellular.mbim_compliance import mbim_errors
19from autotest_lib.client.cros.cellular.mbim_compliance.sequences \
20        import connect_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
25from autotest_lib.client.cros.cellular.mbim_compliance.tests import test
26
27
28class CM13Test(test.Test):
29    """ Implement the CM_13 test. """
30
31    def run_internal(self):
32        """ Run CM_13 test. """
33        # Precondition
34        mbim_open_generic_sequence.MBIMOpenGenericSequence(
35                self.test_context).run()
36        connect_sequence.ConnectSequence(self.test_context).run()
37        mbim_close_sequence.MBIMCloseSequence(self.test_context).run()
38        mbim_open_generic_sequence.MBIMOpenGenericSequence(
39                self.test_context).run()
40
41        # Step 1
42        connect_info_structure = mbim_data.MBIMConnectInfoStructure(
43                session_id=0,
44                activation_state=0,
45                voice_call_state=0,
46                ip_type=0,
47                context_type=mbim_constants.MBIM_CONTEXT_TYPE_NONE.bytes,
48                nw_error=0)
49        command_message = mbim_control.MBIMCommandMessage(
50                message_length=84,
51                total_fragments=1,
52                current_fragment=0,
53                device_service_id=mbim_constants.UUID_BASIC_CONNECT.bytes,
54                cid=mbim_constants.MBIM_CID_CONNECT,
55                command_type=mbim_constants.COMMAND_TYPE_QUERY,
56                information_buffer_length=36,
57                information_buffer=connect_info_structure.pack())
58        packets = command_message.generate_packets()
59        channel = mbim_channel.MBIMChannel(
60                {'idVendor': self.test_context.id_vendor,
61                 'idProduct': self.test_context.id_product},
62                self.test_context.mbim_communication_interface.bInterfaceNumber,
63                self.test_context.interrupt_endpoint.bEndpointAddress,
64                self.test_context.mbim_functional.wMaxControlMessage)
65        response_packets = channel.bidirectional_transaction(*packets)
66        channel.close()
67
68        # Step 2
69        response_message = mbim_control.parse_response_packets(response_packets)
70
71        # Step 3
72        if (response_message.status_codes !=
73            mbim_constants.MBIM_STATUS_CONTEXT_NOT_ACTIVATED):
74            mbim_errors.log_and_raise(mbim_errors.MBIMComplianceAssertionError,
75                                      'mbim1.0:9.3.2#3')
76