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_08 Validation of InformationBuffer in Case of a Failure in MBIM_COMMAND_MSG 7 8Reference: 9 [1] Universal Serial Bus Communication Class MBIM Compliance Testing: 40 10 http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf 11""" 12import array 13import struct 14 15import common 16from autotest_lib.client.cros.cellular.mbim_compliance import mbim_channel 17from autotest_lib.client.cros.cellular.mbim_compliance import mbim_constants 18from autotest_lib.client.cros.cellular.mbim_compliance import mbim_control 19from autotest_lib.client.cros.cellular.mbim_compliance import mbim_errors 20from autotest_lib.client.cros.cellular.mbim_compliance.sequences \ 21 import mbim_open_generic_sequence 22from autotest_lib.client.cros.cellular.mbim_compliance.tests import test 23 24 25class CM08Test(test.Test): 26 """ Implement the CM_08 test. """ 27 28 def run_internal(self): 29 """ Run CM_08 test. """ 30 # Precondition 31 mbim_open_generic_sequence.MBIMOpenGenericSequence( 32 self.test_context).run() 33 34 # Step 1 35 command_message = mbim_control.MBIMCommandMessage( 36 message_length=52, 37 total_fragments=1, 38 current_fragment=0, 39 device_service_id=mbim_constants.UUID_BASIC_CONNECT.bytes, 40 cid=mbim_constants.MBIM_CID_RADIO_STATE, 41 command_type=mbim_constants.COMMAND_TYPE_SET, 42 information_buffer_length=4, 43 information_buffer=array.array('B', struct.pack('I', 2))) 44 packets = command_message.generate_packets() 45 channel = mbim_channel.MBIMChannel( 46 {'idVendor': self.test_context.id_vendor, 47 'idProduct': self.test_context.id_product}, 48 self.test_context.mbim_communication_interface.bInterfaceNumber, 49 self.test_context.interrupt_endpoint.bEndpointAddress, 50 self.test_context.mbim_functional.wMaxControlMessage) 51 response_packets = channel.bidirectional_transaction(*packets) 52 channel.close() 53 54 # Step 2 55 response_message = mbim_control.parse_response_packets(response_packets) 56 57 # Step 3 58 if ((response_message.message_type != 59 mbim_constants.MBIM_COMMAND_DONE) or 60 (response_message.status_codes == 61 mbim_constants.MBIM_STATUS_SUCCESS) or 62 response_message.information_buffer_length != 0): 63 mbim_errors.log_and_raise(mbim_errors.MBIMComplianceAssertionError, 64 'mbim1.0:9.4.5#3') 65