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_errors 7from autotest_lib.client.cros.cellular.mbim_compliance \ 8 import mbim_test_base 9from autotest_lib.client.cros.cellular.mbim_compliance.sequences \ 10 import get_descriptors_sequence 11from autotest_lib.client.cros.cellular.mbim_compliance.sequences \ 12 import mbim_open_generic_sequence 13 14 15class cellular_MbimComplianceCM02(mbim_test_base.MbimTestBase): 16 """ 17 CM_02 Validation of Message Length of the response to MBIM_OPEN_MSG. 18 19 This test validates MessageLength field in MBIM_MESSAGE_HEADER. 20 21 Reference: 22 [1] Universal Serial Bus Communication Class MBIM Compliance Testing: 38 23 http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf 24 25 """ 26 version = 1 27 28 def run_internal(self): 29 """ Run the CM_02 test. """ 30 # Precondition. 31 descriptors = get_descriptors_sequence.GetDescriptorsSequence( 32 self.device_context).run() 33 self.device_context.update_descriptor_cache(descriptors) 34 35 # Step 1 36 _, response_message = ( 37 mbim_open_generic_sequence.MBIMOpenGenericSequence( 38 self.device_context).run()) 39 40 # Validate message length of response to MBIM_OPEN_MESSAGE. 41 if response_message.message_length < 0x0C: 42 mbim_errors.log_and_raise(mbim_errors.MBIMComplianceAssertionError, 43 'mbim1.0:9.1#2') 44