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_07 Validation of Status in Case of an Unsupported CID 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 common 13from autotest_lib.client.cros.cellular.mbim_compliance import mbim_channel 14from autotest_lib.client.cros.cellular.mbim_compliance import mbim_constants 15from autotest_lib.client.cros.cellular.mbim_compliance import mbim_control 16from autotest_lib.client.cros.cellular.mbim_compliance import mbim_errors 17from autotest_lib.client.cros.cellular.mbim_compliance.sequences \ 18 import mbim_open_generic_sequence 19from autotest_lib.client.cros.cellular.mbim_compliance.tests import test 20 21 22class CM07Test(test.Test): 23 """ Implement the CM_07 test. """ 24 25 def run_internal(self): 26 """ Run CM_07 test. """ 27 # Precondition 28 mbim_open_generic_sequence.MBIMOpenGenericSequence( 29 self.test_context).run() 30 31 # Step 1 32 # 255 is an unsupported CID. 33 command_message = mbim_control.MBIMCommandMessage( 34 message_length=48, 35 total_fragments=1, 36 current_fragment=0, 37 device_service_id=mbim_constants.UUID_BASIC_CONNECT.bytes, 38 cid=255, 39 command_type=mbim_constants.COMMAND_TYPE_QUERY, 40 information_buffer_length=0) 41 packets = command_message.generate_packets() 42 channel = mbim_channel.MBIMChannel( 43 {'idVendor': self.test_context.id_vendor, 44 'idProduct': self.test_context.id_product}, 45 self.test_context.mbim_communication_interface.bInterfaceNumber, 46 self.test_context.interrupt_endpoint.bEndpointAddress, 47 self.test_context.mbim_functional.wMaxControlMessage) 48 response_packets = channel.bidirectional_transaction(*packets) 49 channel.close() 50 51 # Step 2 52 response_message = mbim_control.parse_response_packets(response_packets) 53 54 # Step 3 55 if (response_message.message_type != mbim_constants.MBIM_COMMAND_DONE or 56 (response_message.status_codes != 57 mbim_constants.MBIM_STATUS_NO_DEVICE_SUPPORT)): 58 mbim_errors.log_and_raise(mbim_errors.MBIMComplianceAssertionError, 59 'mbim1.0:9.4.5#2') 60