• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2015 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 MbimDtsTestBase(mbim_test_base.MbimTestBase):
18    """ Base class for all the data transfer tests. """
19
20    def run_precondition(self, ntb_format):
21        """
22        Runs all the precondition sequences for data transfer tests.
23
24        @param ntb_format: Whether to send/receive an NTB16 or NTB32 frame.
25                Possible values: NTB_FORMAT_16, NTB_FORMAT_32 (mbim_constants)
26        @returns tuple of (desc_sequence, open_sequence, connect_sequence) where,
27                desc_sequence - Handle to run the get descriptor sequence.
28                open_sequence - Handle to run the open sequence.
29                connect_sequence - Handle to run the connect sequence.
30
31        """
32        desc_sequence = get_descriptors_sequence.GetDescriptorsSequence(
33                self.device_context)
34        descriptors = desc_sequence.run()
35        self.device_context.update_descriptor_cache(descriptors)
36        open_sequence = mbim_open_generic_sequence.MBIMOpenGenericSequence(
37                self.device_context)
38        open_sequence.run(ntb_format=ntb_format)
39        connect_seq = connect_sequence.ConnectSequence(self.device_context)
40        connect_seq.run()
41
42        # Devices may not support SetNtbFormat(), so fail the NTB32 tests on
43        # such devices.
44        if ((ntb_format == mbim_constants.NTB_FORMAT_32) and
45            (self.device_context.current_ntb_format != ntb_format)):
46            mbim_errors.log_and_raise(
47                    mbim_errors.MBIMComplianceFrameworkError,
48                    'Device does not support NTB 32 format.')
49
50        return (desc_sequence, open_sequence, connect_seq)
51