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_MbimComplianceDTS0511(mbim_dts_test_base.MbimDtsTestBase):
14    """
15    Validation of wSequence increment.
16
17    This test verifies that the expected increment happens for wSequence.
18
19    Reference:
20        [1] Universal Serial Bus Communication Class MBIM Compliance Testing: 28
21        http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf
22
23    """
24    version = 1
25
26    def run_internal(self, ntb_format):
27        """
28        Run DTS_05/DTS_11 test.
29
30        @param ntb_format: Whether to send/receive an NTB16 or NTB32 frame.
31                Possible values: NTB_FORMAT_16, NTB_FORMAT_32 (mbim_constants)
32
33        """
34        # Precondition
35        _, _, _ = self.run_precondition(ntb_format)
36
37        # Step 1
38        loopback = loopback_sequence.LoopbackSequence(self.device_context)
39        nth_1, _, _, _ = loopback.run(ntb_format=ntb_format)
40
41        # Step 2
42        nth_2, _, _, _ = loopback.run(ntb_format=ntb_format)
43
44        # Step 3
45        if ntb_format == mbim_constants.NTB_FORMAT_16:
46            if nth_2.sequence_number != nth_1.sequence_number + 1:
47                mbim_errors.log_and_raise(
48                        mbim_errors.MBIMComplianceAssertionError,
49                        'ncm1.0:3.2.1#4')
50        else:
51            if nth_2.sequence_number != nth_1.sequence_number + 1:
52                mbim_errors.log_and_raise(
53                        mbim_errors.MBIMComplianceAssertionError,
54                        'ncm1.0:3.2.2#4')
55