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 import mbim_test_base 9from autotest_lib.client.cros.cellular.mbim_compliance.sequences \ 10 import connect_sequence 11from autotest_lib.client.cros.cellular.mbim_compliance.sequences \ 12 import get_descriptors_sequence 13from autotest_lib.client.cros.cellular.mbim_compliance.sequences \ 14 import mbim_open_generic_sequence 15 16 17class cellular_MbimComplianceERR01(mbim_test_base.MbimTestBase): 18 """ 19 Validation of function's response to messages with variable-length encoding 20 errors. 21 22 This test verifies that incoming messages are rejected when variable-length 23 encoding rules are not followed. 24 25 Reference: 26 [1] Universal Serial Bus Communication Class MBIM Compliance Testing: 45 27 http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf 28 29 """ 30 version = 1 31 32 def run_internal(self): 33 """ Run ERR_01 test. """ 34 # Precondition 35 descriptors = get_descriptors_sequence.GetDescriptorsSequence( 36 self.device_context).run() 37 self.device_context.update_descriptor_cache(descriptors) 38 open_sequence = mbim_open_generic_sequence.MBIMOpenGenericSequence( 39 self.device_context) 40 open_sequence.run() 41 42 # Step 1 43 request_message, response_message, _ = ( 44 connect_sequence.ConnectSequence(self.device_context).run( 45 introduce_error_in_access_offset=True, 46 raise_exception_on_failure=False)) 47 48 # Step 2 49 if ((response_message.transaction_id != 50 request_message.transaction_id) or 51 (response_message.device_service_id != 52 request_message.device_service_id) or 53 (response_message.cid != request_message.cid)): 54 mbim_errors.log_and_raise( 55 mbim_errors.MBIMComplianceTestError, 56 'Mismatch in request/response message params: ' 57 '(transaction_id, service_id, cid). ' 58 'Request Message: (%s, %s, %s), ' 59 'Response Message: (%s, %s, %s)' % ( 60 request_message.transaction_id, 61 request_message.device_service_id, 62 request_message.cid, 63 response_message.transaction_id, 64 response_message.device_service_id, 65 response_message.cid)) 66 67 # Step 3 68 if ((response_message.message_type != 69 mbim_constants.MBIM_COMMAND_DONE) or 70 (response_message.status_codes != 71 mbim_constants.MBIM_STATUS_INVALID_PARAMETERS)): 72 mbim_errors.log_and_raise(mbim_errors.MBIMComplianceAssertionError, 73 'mbim1.0:10.3#2') 74