Exemple #1
0
from openhtf.util.utils import TimeMillis


VALIDATOR_MAP = {
    'range': data.InRange, 'matches': data.Matches,
    'regex': data.MatchesRegex, 'enum': data.Enum,
    'none': None}

configuration.Declare('overridden_parameters',
                      '''
Overridden parameter validators and optionality.

You can't change the type, however.

Example:
  overridden_parameters:
    numeric_parameter_with_bad_limits:
      validator: range
      optional: true
      kwargs:
        minimum: 1
        maximum: 2
''', default_value={})


class TestParameterError(Exception):
  """An exception which occurs when working with a test parameter."""


class NotAParameterError(Exception):
  """Raised if an invalid parameter is accessed."""
Exemple #2
0
To use these capabilities:
  from openhtf import capabilities
  from openhtf.capabilities import usb

  @capabilities.RequiresCapability(adb=usb.AdbCapability)
  def MyPhase(test, adb):
    adb.Shell('ls')
"""

import openhtf.capabilities as capabilities
from openhtf.capabilities.usb import adb_device
from openhtf.capabilities.usb import fastboot_device
from openhtf.capabilities.usb import local_usb
from openhtf.util import configuration

configuration.Declare('usb_server', 'USB Server IP/Hostname')
configuration.Declare('usb_server_port',
                      'USB Server Port',
                      default_value=10000)

configuration.Declare('libusb_rsa_key',
                      doc='A private key file for use by libusb auth.')


def _open_usb_handle(**kwargs):
    """Open a UsbHandle subclass, based on configuration.

  If configuration 'usb_server' is set, use it to connect to remote usb,
  otherwise attempt to connect locally.

  Args:
Exemple #3
0
CellExecuter executes the test for the given cell consecutively, concisely, and
consistently.
"""
import logging
import time

import contextlib2 as contextlib

from openhtf import capabilities
from openhtf import dutmanager
from openhtf import testmanager
from openhtf.util import configuration
from openhtf.util import threads

configuration.Declare('cell_info', """
All the information for each cell. This should be a mapping from cell number to
cell data. What is in the cell data is dictated by the capabilities used.
""", default_value={1: {}})


_LOG = logging.getLogger('openhtf.cells')


class TestStopError(Exception):
  """Test is being stopped."""


class CellExecutorStarter(object):
  """Starts all the cell executor threads."""

  def __init__(self, test):
    self.test = test
Exemple #4
0
This module handles these various functions.
"""

import collections
import logging
import threading
import time

from openhtf.capabilities.usb import adb_device
from openhtf.capabilities.usb import fastboot_device
from openhtf.capabilities.usb import local_usb
from openhtf.capabilities.usb import usb_exceptions
from openhtf.util import configuration

configuration.Declare('test_start',
                      'Mechanism to use for starting a test.',
                      default_value='android')
configuration.Declare('stub_dut_serial', 'Serial to use when test_start is '
                      '"stub".',
                      default_value='DUT_SERIAL',
                      required=False)


class InvalidTestStartError(Exception):
    """Raised when an invalid value is provided for test_start."""


class StubHandler(object):
    """Noop handler for testing."""
    def __init__(self, dummy_cell_number, config):
        self.config = config
Exemple #5
0
from openhtf.proto import htf_pb2  # pylint: disable=no-name-in-module

FLAGS = gflags.FLAGS
gflags.DEFINE_integer('phase_default_timeout_ms',
                      3 * 60 * 1000,
                      'Test phase timeout in ms',
                      lower_bound=0)

_LOG = logging.getLogger('htf.phasemanager')

# Only use 'is' checks, as that does pointer comparison for strings. That makes
# this the same as an object(), but useful when printed.
DIDNT_FINISH = 'DIDNT_FINISH'

configuration.Declare('blacklist_phases',
                      'Phase names to skip',
                      default_value=[])


class TestPhaseResult(
        collections.namedtuple(
            'TestPhaseResult',
            ['phase_name', 'phase_result', 'raised_exception'])):
    """Wrap's a phases name, result and whether it raised an exception or not."""


class PhaseExecutorThread(threads.KillableThread):
    """Handles the execution and result of a single test phase.

  The thread's result will be stored in phase_thread.result after it's finished,
  DIDNT_FINISH until then. It will be an instance of TestPhaseResult.