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 \
9        import mbim_test_base
10from autotest_lib.client.cros.cellular.mbim_compliance.sequences \
11        import get_descriptors_sequence
12from autotest_lib.client.cros.cellular.mbim_compliance.sequences \
13        import mbim_cid_device_caps_sequence
14from autotest_lib.client.cros.cellular.mbim_compliance.sequences \
15        import mbim_open_generic_sequence
16
17class cellular_MbimComplianceCM06(mbim_test_base.MbimTestBase):
18    """
19    CM_06 Validation of |status_codes| in modem's response to MBIM_COMMAND_MSG.
20
21    This test verifies that the function returns MBIM_STATUS_SUCCESS in Status
22    field of MBIM_COMMAND_DONE response in case of a successfully executed
23    command.
24
25    Reference:
26        [1] Universal Serial Bus Communication Class MBIM Compliance Testing: 39
27        http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf
28    """
29    version = 1
30
31    def run_internal(self):
32        """ Run CM_06 test. """
33        # Precondition
34        descriptors = get_descriptors_sequence.GetDescriptorsSequence(
35                self.device_context).run()
36        self.device_context.update_descriptor_cache(descriptors)
37        mbim_open_generic_sequence.MBIMOpenGenericSequence(
38                self.device_context).run()
39
40        # Step 1
41        _, response_message = (
42                mbim_cid_device_caps_sequence.MBIMCIDDeviceCapsSequence(
43                        self.device_context).run())
44        if response_message.status_codes != mbim_constants.MBIM_STATUS_SUCCESS:
45            mbim_errors.log_and_raise(mbim_errors.MBIMComplianceAssertionError,
46                                      'mbim1.0:9.4.5#1')
47