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_dts_test_base
8from autotest_lib.client.cros.cellular.mbim_compliance import mbim_errors
9from autotest_lib.client.cros.cellular.mbim_compliance.sequences \
10        import loopback_sequence
11
12
13class cellular_MbimComplianceDTS01(mbim_dts_test_base.MbimDtsTestBase):
14    """
15    Validation for alternate setting 1 of the communication interface.
16
17    This test validates data transfer operation for alternate setting 1 of the
18    Communication Interface.
19
20    Reference:
21        [1] Universal Serial Bus Communication Class MBIM Compliance Testing: 28
22        http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf
23
24    """
25    version = 1
26
27    def run_internal(self):
28        """ Run DTS_01 test. """
29        # Precondition
30        _, _, _ = self.run_precondition(mbim_constants.NTB_FORMAT_16)
31
32        # Step 1
33        loopback = loopback_sequence.LoopbackSequence(self.device_context)
34        _, _, _, payload = loopback.run(ntb_format=mbim_constants.NTB_FORMAT_16)
35
36        # Step 2
37        # Let's check the first byte of the first received payload to verify
38        # that it is an IPv4 packet
39        if payload[0][0] != 0x45:
40            mbim_errors.log_and_raise(mbim_errors.MBIMComplianceAssertionError,
41                                      'mbim1.0:3.2.1#5')
42