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_02 Validation of Message Length of the response to MBIM_OPEN_MSG.
7
8Reference:
9    [1] Universal Serial Bus Communication Class MBIM Compliance Testing: 38
10        http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf
11"""
12
13import common
14from autotest_lib.client.cros.cellular.mbim_compliance import mbim_errors
15from autotest_lib.client.cros.cellular.mbim_compliance.sequences \
16        import mbim_open_generic_sequence
17from autotest_lib.client.cros.cellular.mbim_compliance.tests import test
18
19
20class CM02Test(test.Test):
21    """
22    Implement the CM_02 test.
23    """
24
25    def run_internal(self):
26        """ Run CM_02 test. """
27        # Step 1
28        open_message, response_message = (
29                mbim_open_generic_sequence.MBIMOpenGenericSequence(
30                        self.test_context).run())
31
32        # Validate message length of response to MBIM_OPEN_MESSAGE.
33        if response_message.message_length < 0x0C:
34            mbim_errors.log_and_raise(mbim_errors.MBIMComplianceAssertionError,
35                                      'mbim1.0:9.1#2')
36