コード例 #1
0
def ProvisionDevices(options):
  if options.device is not None:
    devices = [options.device]
  else:
    devices = android_commands.GetAttachedDevices()
  for device_serial in devices:
    device = device_utils.DeviceUtils(device_serial)
    device.old_interface.EnableAdbRoot()
    install_output = GetCmdOutput(
      ['%s/build/android/adb_install_apk.py' % constants.DIR_SOURCE_ROOT,
       '--apk',
       '%s/build/android/CheckInstallApk-debug.apk' % constants.DIR_SOURCE_ROOT
       ])
    failure_string = 'Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]'
    if failure_string in install_output:
      WipeDeviceData(device)
    _ConfigureLocalProperties(device)
    device_settings.ConfigureContentSettingsDict(
        device, device_settings.DETERMINISTIC_DEVICE_SETTINGS)
    # TODO(tonyg): We eventually want network on. However, currently radios
    # can cause perfbots to drain faster than they charge.
    if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower():
      device_settings.ConfigureContentSettingsDict(
          device, device_settings.NETWORK_DISABLED_SETTINGS)
    device.old_interface.RunShellCommandWithSU('date -u %f' % time.time())
    (_, props) = device.old_interface.GetShellCommandStatusAndOutput('getprop')
    for prop in props:
      print prop
  if options.auto_reconnect:
    PushAndLaunchAdbReboot(devices, options.target)
コード例 #2
0
def main(argv):
    option_parser = optparse.OptionParser()
    option_parser.add_option(
        '--enable_asserts',
        dest='set_asserts',
        action='store_true',
        default=None,
        help='Sets the dalvik.vm.enableassertions property to "all"')
    option_parser.add_option(
        '--disable_asserts',
        dest='set_asserts',
        action='store_false',
        default=None,
        help='Removes the dalvik.vm.enableassertions property')
    options, _ = option_parser.parse_args(argv)

    # TODO(jbudorick): Accept optional serial number and run only for the
    # specified device when present.
    devices = android_commands.GetAttachedDevices()
    for device in [device_utils.DeviceUtils(serial) for serial in devices]:
        if options.set_asserts != None:
            if device.old_interface.SetJavaAssertsEnabled(options.set_asserts):
                # TODO(jbudorick) How to best do shell restarts after the
                #                 android_commands refactor?
                device.RunShellCommand('stop')
                device.RunShellCommand('start')
コード例 #3
0
def RunJavaTest(fname, suite, test, ports_to_forward):
    device = android_commands.GetAttachedDevices()[0]
    package_name = _GetPackageName(fname)
    test = package_name + '.' + suite + '#' + test
    java_test_runner = TestRunner(False, device, [test], False, False, False,
                                  False, 0, ports_to_forward)
    return java_test_runner.Run()
コード例 #4
0
def DispatchPythonTests(options):
  """Dispatches the Monkey tests, sharding it if there multiple devices."""
  logger = logging.getLogger()
  logger.setLevel(logging.DEBUG)
  attached_devices = android_commands.GetAttachedDevices()
  if not attached_devices:
    raise Exception('You have no devices attached or visible!')

  # Actually run the tests.
  logging.debug('Running monkey tests.')
  # TODO(frankf): This is a stop-gap solution. Come up with a
  # general way for running tests on every devices.
  available_tests = []
  for k in range(len(attached_devices)):
    new_method = 'testMonkey%d' % k
    setattr(MonkeyTest, new_method, MonkeyTest.testMonkey)
    available_tests.append(MonkeyTest(new_method))
  options.ensure_value('shard_retries', 1)
  sharder = python_test_sharder.PythonTestSharder(
      attached_devices, available_tests, options)
  results = sharder.RunShardedTests()
  report_results.LogFull(
      results=results,
      test_type='Monkey',
      test_package='Monkey',
      build_type=options.build_type)
  report_results.PrintAnnotation(results)
コード例 #5
0
def main():
    parser = optparse.OptionParser()
    parser.add_option('',
                      '--out-dir',
                      help='Directory where the device path is stored',
                      default=os.path.join(os.path.dirname(__file__), '..',
                                           '..', 'out'))

    options, args = parser.parse_args()
    if args:
        parser.error('Unknown options %s' % args)
    buildbot_report.PrintNamedStep('Device Status Check')
    devices = android_commands.GetAttachedDevices()
    types, builds, reports, errors = [], [], [], []
    if devices:
        types, builds, reports, errors = zip(
            *[DeviceInfo(dev) for dev in devices])

    unique_types = list(set(types))
    unique_builds = list(set(builds))

    buildbot_report.PrintMsg('Online devices: %d. Device types %s, builds %s' %
                             (len(devices), unique_types, unique_builds))
    print '\n'.join(reports)

    full_errors = []
    for serial, device_errors in zip(devices, errors):
        full_errors.extend('%s: %s' % (serial, error)
                           for error in device_errors)
    if full_errors:
        buildbot_report.PrintWarning()
        print '\n'.join(full_errors)

    CheckForMissingDevices(options, devices)
コード例 #6
0
def ProvisionDevices(options):
    is_perf = 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower()
    # TODO(jbudorick): Parallelize provisioning of all attached devices after
    # switching from AndroidCommands.
    if options.device is not None:
        devices = [options.device]
    else:
        devices = android_commands.GetAttachedDevices()

    # Wipe devices (unless --skip-wipe was specified)
    if not options.skip_wipe:
        WipeDevicesIfPossible(devices)

    bad_devices = []
    # Provision devices
    for device_serial in devices:
        try:
            ProvisionDevice(device_serial, is_perf, options.disable_location)
        except errors.WaitForResponseTimedOutError:
            logging.info(
                'Timed out waiting for device %s. Adding to blacklist.',
                device_serial)
            bad_devices.append(device_serial)
            # Device black list is reset by bb_device_status_check.py per build.
            device_blacklist.ExtendBlacklist([device_serial])
    devices = [device for device in devices if device not in bad_devices]

    # If there are no good devices
    if not devices:
        raise device_errors.NoDevicesError

    try:
        device_utils.DeviceUtils.parallel(devices).Reboot(True)
    except errors.DeviceUnresponsiveError:
        pass

    bad_devices = []
    for device_serial in devices:
        device = device_utils.DeviceUtils(device_serial)
        try:
            device.WaitUntilFullyBooted(timeout=90)
            (_, prop
             ) = device.old_interface.GetShellCommandStatusAndOutput('getprop')
            for p in prop:
                print p
        except errors.WaitForResponseTimedOutError:
            logging.info(
                'Timed out waiting for device %s. Adding to blacklist.',
                device_serial)
            bad_devices.append(device_serial)
            # Device black list is reset by bb_device_status_check.py per build.
            device_blacklist.ExtendBlacklist([device_serial])
    devices = [device for device in devices if device not in bad_devices]

    # If there are no good devices
    if not devices:
        raise device_errors.NoDevicesError

    if options.auto_reconnect:
        PushAndLaunchAdbReboot(devices, options.target)
コード例 #7
0
def PrepareShellRun(config):
    """
  Returns a context allowing a shell to be run.

  This will start an internal http server to serve mojo applications, forward a
  local port on the device to this http server and install the current version
  of the mojo shell.
  """
    build_dir = Paths(config).build_dir
    constants.SetOutputDirectort(build_dir)

    httpd = _SilentTCPServer(('127.0.0.1', 0),
                             _GetHandlerClassForPath(build_dir))
    atexit.register(httpd.shutdown)
    host_port = httpd.server_address[1]

    http_thread = threading.Thread(target=httpd.serve_forever)
    http_thread.daemon = True
    http_thread.start()

    device = android_commands.AndroidCommands(
        android_commands.GetAttachedDevices()[0])
    device.EnableAdbRoot()

    device.ManagedInstall(os.path.join(build_dir, 'apks', 'MojoShell.apk'),
                          keep_data=True,
                          package_name=MOJO_SHELL_PACKAGE_NAME)

    atexit.register(forwarder.Forwarder.UnmapAllDevicePorts, device)
    forwarder.Forwarder.Map([(0, host_port)], device)
    context = Context(device,
                      forwarder.Forwarder.DevicePortForHostPort(host_port))

    atexit.register(StopShell, context)
    return context
コード例 #8
0
 def testDeviceManagement(self):
     self._drivers = [
         self.CreateDriver() for x in android_commands.GetAttachedDevices()
     ]
     self.assertRaises(chromedriver.UnknownError, self.CreateDriver)
     self._drivers[0].Quit()
     self._drivers[0] = self.CreateDriver()
コード例 #9
0
def main(argv):
  logging.basicConfig(level=logging.INFO)

  parser = optparse.OptionParser()
  parser.add_option('-w', '--wipe', action='store_true',
                    help='Wipe device data from all attached devices.')
  parser.add_option('-d', '--device',
                    help='The serial number of the device to be provisioned')
  parser.add_option('-t', '--target', default='Debug', help='The build target')
  parser.add_option(
      '-r', '--auto-reconnect', action='store_true',
      help='Push binary which will reboot the device on adb disconnections.')
  options, args = parser.parse_args(argv[1:])
  constants.SetBuildType(options.target)

  if args:
    print >> sys.stderr, 'Unused args %s' % args
    return 1

  if options.wipe:
    devices = android_commands.GetAttachedDevices()
    for device_serial in devices:
      device = device_utils.DeviceUtils(device_serial)
      WipeDeviceData(device)
    device_utils.RebootDevices()
  else:
    ProvisionDevices(options)
コード例 #10
0
def main(argv):
  parser = optparse.OptionParser()
  AddInstallAPKOption(parser)
  options, args = parser.parse_args(argv)
  constants.SetBuildType(options.build_type)
  ValidateInstallAPKOption(parser, options)
  if len(args) > 1:
    raise Exception('Error: Unknown argument:', args[1:])

  retry_times = 5
  retry_interval = 15
  while retry_times > 0:
    devices = android_commands.GetAttachedDevices()
    if not devices:
      print 'No connected devices found, '\
            'kill adb server and retry in %d seconds...' % retry_interval
      android_commands.AndroidCommands().KillAdbServer()
      time.sleep(retry_interval)
      retry_interval *= 2
      retry_times -= 1
    else:
      break

  if not devices:
    raise Exception('Error: no connected devices')

  if not options.apk_package:
    options.apk_package = apk_helper.GetPackageName(options.apk)

  pool = multiprocessing.Pool(len(devices))
  # Send a tuple (apk_path, apk_package, device) per device.
  pool.map(_InstallApk, zip([options.apk] * len(devices),
                            [options.apk_package] * len(devices),
                            [options.keep_data] * len(devices),
                            devices))
コード例 #11
0
def _GetAttachedDevices(wait_for_debugger=False, test_device=None):
    """Get all attached devices.

  If we are using a debugger, limit to only one device.

  Args:
    wait_for_debugger: True if this run will use a debugger.
    test_device: Name of a specific device to use.

  Returns:
    A list of attached devices.
  """
    attached_devices = []

    attached_devices = android_commands.GetAttachedDevices()
    if test_device:
        assert test_device in attached_devices, (
            'Did not find device %s among attached device. Attached devices: %s'
            % (test_device, ', '.join(attached_devices)))
        attached_devices = [test_device]

    if len(attached_devices) > 1 and wait_for_debugger:
        logging.warning(
            'Debugger can not be sharded, using first available device')
        attached_devices = attached_devices[:1]

    return attached_devices
コード例 #12
0
ファイル: tombstones.py プロジェクト: mYoda/CustomBrs
def main():
  parser = optparse.OptionParser()
  parser.add_option('--device',
                    help='The serial number of the device. If not specified '
                         'will use all devices.')
  parser.add_option('-a', '--all-tombstones', action='store_true',
                    help="""Resolve symbols for all tombstones, rather than just
                         the most recent""")
  parser.add_option('-s', '--stack', action='store_true',
                    help='Also include symbols for stack data')
  parser.add_option('-w', '--wipe-tombstones', action='store_true',
                    help='Erase all tombstones from device after processing')
  parser.add_option('-j', '--jobs', type='int',
                    default=4,
                    help='Number of jobs to use when processing multiple '
                         'crash stacks.')
  options, _ = parser.parse_args()

  if options.device:
    devices = [options.device]
  else:
    devices = android_commands.GetAttachedDevices()

  tombstones = []
  for device_serial in devices:
    device = device_utils.DeviceUtils(device_serial)
    tombstones += _GetTombstonesForDevice(device, options)

  _ResolveTombstones(options.jobs, tombstones)
コード例 #13
0
def main(argv):
    parser = optparse.OptionParser()
    parser.set_usage("usage: %prog [options] target")
    AddInstallAPKOption(parser)
    options, args = parser.parse_args(argv)

    if len(args) > 1 and options.apk:
        parser.error("Appending the apk as argument can't be used with --apk.")
    elif len(args) > 2:
        parser.error("Too many arguments.")

    constants.SetBuildType(options.build_type)
    ValidateInstallAPKOption(parser, options, args)

    devices = android_commands.GetAttachedDevices()

    if options.device:
        if options.device not in devices:
            raise Exception('Error: %s not in attached devices %s' %
                            (options.device, ','.join(devices)))
        devices = [options.device]

    if not devices:
        raise Exception('Error: no connected devices')

    device_utils.DeviceUtils.parallel(devices).Install(
        options.apk, reinstall=options.keep_data)
コード例 #14
0
    def setUp(self):
        if not os.getenv('BUILDTYPE'):
            os.environ['BUILDTYPE'] = 'Debug'

        devices = android_commands.GetAttachedDevices()
        self.assertGreater(len(devices), 0, 'No device attached!')
        self.ac = android_commands.AndroidCommands(device=devices[0])
コード例 #15
0
def main(argv):
    parser = optparse.OptionParser()
    parser.add_option('-s',
                      '--steps',
                      help='A JSON file containing all the steps to be '
                      'sharded.')
    parser.add_option('-p',
                      '--print_results',
                      help='Only prints the results for the previously '
                      'executed step, do not run it again.')
    options, urls = parser.parse_args(argv)
    if options.print_results:
        return _PrintStepOutput(options.print_results)

    # At this point, we should kill everything that may have been left over from
    # previous runs.
    _KillPendingServers()

    # Reset the test port allocation. It's important to do it before starting
    # to dispatch any step.
    if not ports.ResetTestServerPortAllocation():
        raise Exception('Failed to reset test server port.')

    # Sort the devices so that we'll try to always run a step in the same device.
    devices = sorted(android_commands.GetAttachedDevices())
    if not devices:
        print 'You must attach a device'
        return 1

    with file(options.steps, 'r') as f:
        steps = json.load(f)
    return _RunShardedSteps(steps, devices)
コード例 #16
0
def _KillPendingServers():
    for retry in range(5):
        for server in ['lighttpd', 'web-page-replay']:
            pids = [p.pid for p in psutil.process_iter() if server in p.name]
            for pid in pids:
                try:
                    logging.warning('Killing %s %s', server, pid)
                    os.kill(pid, signal.SIGQUIT)
                except Exception as e:
                    logging.warning('Failed killing %s %s %s', server, pid, e)
    # Restart the adb server with taskset to set a single CPU affinity.
    cmd_helper.RunCmd(['adb', 'kill-server'])
    cmd_helper.RunCmd(['taskset', '-c', '0', 'adb', 'start-server'])
    cmd_helper.RunCmd(['taskset', '-c', '0', 'adb', 'root'])
    i = 1
    while not android_commands.GetAttachedDevices():
        time.sleep(i)
        i *= 2
        if i > 10:
            break
    # Reset the test port allocation. It's important to do it before starting
    # to dispatch any step.
    if not ports.ResetTestServerPortAllocation():
        raise Exception('Failed to reset test server port.')

    forwarder.Forwarder.UseMultiprocessing()
コード例 #17
0
ファイル: emulator.py プロジェクト: xinchao1230/kalpa
def _KillAllEmulators():
  """Kill all running emulators that look like ones we started.

  There are odd 'sticky' cases where there can be no emulator process
  running but a device slot is taken.  A little bot trouble and and
  we're out of room forever.
  """
  emulators = android_commands.GetAttachedDevices(hardware=False)
  if not emulators:
    return
  for emu_name in emulators:
    cmd_helper.RunCmd(['adb', '-s', emu_name, 'emu', 'kill'])
  logging.info('Emulator killing is async; give a few seconds for all to die.')
  for i in range(5):
    if not android_commands.GetAttachedDevices(hardware=False):
      return
    time.sleep(1)
コード例 #18
0
ファイル: dispatch.py プロジェクト: lihuan545890/webrtc_old
def _RunATestSuite(options, suite_name):
    """Run a single test suite.

  Helper for Dispatch() to allow stop/restart of the emulator across
  test bundles.  If using the emulator, we start it on entry and stop
  it on exit.

  Args:
    options: options for running the tests.
    suite_name: name of the test suite being run.

  Returns:
    0 if successful, number of failing tests otherwise.
  """
    step_name = os.path.basename(options.test_suite).replace('-debug.apk', '')
    attached_devices = []
    buildbot_emulators = []

    if options.use_emulator:
        buildbot_emulators = emulator.LaunchEmulators(options.emulator_count,
                                                      wait_for_boot=True)
        attached_devices = [e.device for e in buildbot_emulators]
    elif options.test_device:
        attached_devices = [options.test_device]
    else:
        attached_devices = android_commands.GetAttachedDevices()

    if not attached_devices:
        logging.critical('A device must be attached and online.')
        return 1

    # Reset the test port allocation. It's important to do it before starting
    # to dispatch any tests.
    if not ports.ResetTestServerPortAllocation():
        raise Exception('Failed to reset test server port.')

    if options.gtest_filter:
        logging.warning('Sharding is not possible with these configurations.')
        attached_devices = [attached_devices[0]]

    sharder = test_sharder.TestSharder(attached_devices, options.test_suite,
                                       options.gtest_filter,
                                       options.test_arguments, options.timeout,
                                       options.cleanup_test_files,
                                       options.tool, options.build_type,
                                       options.webkit)

    test_results = sharder.RunShardedTests()
    test_results.LogFull(test_type='Unit test',
                         test_package=suite_name,
                         build_type=options.build_type,
                         flakiness_server=options.flakiness_dashboard_server)
    test_results.PrintAnnotation()

    for buildbot_emulator in buildbot_emulators:
        buildbot_emulator.Shutdown()

    return len(test_results.GetAllBroken())
コード例 #19
0
def main():
  logger = logging.getLogger()
  logger.setLevel(logging.DEBUG)
  desc = (
      'Performs semi-automated application update verification testing. '
      'When given --save, it takes a snapshot of the application data '
      'on the device. (A dialog on the device will prompt the user to grant '
      'permission to backup the data.) Otherwise, it performs the update '
      'testing as follows: '
      '1. Installs the |from-apk| (optional). '
      '2. Restores the previously stored snapshot of application data '
      'given by |app-data| '
      '(A dialog on the device will prompt the user to grant permission to '
      'restore the data.) '
      '3. Verifies that |to-apk| cannot be installed side-by-side. '
      '4. Verifies that |to-apk| can replace |from-apk|.')
  parser = optparse.OptionParser(description=desc)
  parser.add_option('--package-name', help='Package name for the application.')
  parser.add_option('--save', action='store_true',
                    help=('Save a snapshot of application data. '
                          'This will be saved as backup.db in the '
                          'current directory if |app-data| directory '
                          'is not specifid.'))
  parser.add_option('--from-apk',
                    help=('APK to update from. This is optional if you already '
                          'have the app installed.'))
  parser.add_option('--to-apk', help='APK to update to.')
  parser.add_option('--app-data',
                    help=('Path to the application data to be restored or the '
                          'directory where the data should be saved.'))
  (options, args) = parser.parse_args()

  if args:
    parser.print_help(sys.stderr)
    parser.error('Unknown arguments: %s.' % args)

  devices = android_commands.GetAttachedDevices()
  if len(devices) != 1:
    parser.error('Exactly 1 device must be attached.')
  device = device_utils.DeviceUtils(devices[0])

  if options.from_apk:
    assert os.path.isfile(options.from_apk)

  if options.save:
    if not options.package_name:
      parser.print_help(sys.stderr)
      parser.error('Missing --package-name.')
    _SaveAppData(device, options.package_name, from_apk=options.from_apk,
                 data_dir=options.app_data)
  else:
    if not options.to_apk or not options.app_data:
      parser.print_help(sys.stderr)
      parser.error('Missing --to-apk or --app-data.')
    assert os.path.isfile(options.to_apk)
    assert os.path.isfile(options.app_data)
    _VerifyAppUpdate(device, options.to_apk, options.app_data,
                     from_apk=options.from_apk)
コード例 #20
0
def _GetAllDevices():
    devices_path = os.path.join(os.environ.get('CHROMIUM_OUT_DIR', 'out'),
                                device_list.LAST_DEVICES_FILENAME)
    try:
        devices = device_list.GetPersistentDeviceList(devices_path)
    except IOError as e:
        logging.error('Unable to find %s [%s]', devices_path, e)
        devices = android_commands.GetAttachedDevices()
    return sorted(devices)
コード例 #21
0
ファイル: dispatch.py プロジェクト: qingchen1984/SPA
def Dispatch(options):
    attached_devices = []
    if options.test_device:
        attached_devices = [options.test_device]
    else:
        attached_devices = android_commands.GetAttachedDevices()

    if not attached_devices:
        logging.critical('A device must be attached and online.')
        return 1

    # Reset the test port allocation. It's important to do it before starting
    # to dispatch any tests.
    if not ports.ResetTestServerPortAllocation():
        raise Exception('Failed to reset test server port.')

    test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(),
                                  options.build_type)
    options.test_suite = os.path.join(
        test_suite_dir, 'apks', constants.BROWSERTEST_SUITE_NAME + '.apk')

    # Constructs a new TestRunner with the current options.
    def RunnerFactory(device, shard_index):
        return test_runner.TestRunner(device, options.test_suite,
                                      options.test_arguments, options.timeout,
                                      options.cleanup_test_files, options.tool,
                                      options.build_type, options.webkit,
                                      constants.BROWSERTEST_TEST_PACKAGE_NAME,
                                      constants.BROWSERTEST_TEST_ACTIVITY_NAME,
                                      constants.BROWSERTEST_COMMAND_LINE_FILE)

        # Get tests and split them up based on the number of devices.

    if options.gtest_filter:
        all_tests = [t for t in options.gtest_filter.split(':') if t]
    else:
        all_enabled = gtest_dispatch.GetAllEnabledTests(
            RunnerFactory, attached_devices)
        all_tests = _FilterTests(all_enabled)

    # Run tests.
    # TODO(nileshagrawal): remove this abnormally long setup timeout once fewer
    # files are pushed to the devices for content_browsertests: crbug.com/138275
    setup_timeout = 20 * 60  # 20 minutes
    test_results = shard.ShardAndRunTests(RunnerFactory,
                                          attached_devices,
                                          all_tests,
                                          options.build_type,
                                          setup_timeout=setup_timeout,
                                          test_timeout=None,
                                          num_retries=options.num_retries)
    report_results.LogFull(results=test_results,
                           test_type='Unit test',
                           test_package=constants.BROWSERTEST_SUITE_NAME,
                           build_type=options.build_type,
                           flakiness_server=options.flakiness_dashboard_server)
    report_results.PrintAnnotation(test_results)
コード例 #22
0
ファイル: emulator.py プロジェクト: xinchao1230/kalpa
def _GetAvailablePort():
  """Returns an available TCP port for the console."""
  used_ports = []
  emulators = android_commands.GetAttachedDevices(hardware=False)
  for emulator in emulators:
    used_ports.append(emulator.split('-')[1])
  for port in PortPool.port_range():
    if str(port) not in used_ports:
      return port
コード例 #23
0
def DispatchPythonTests(options):
    """Dispatches the Python tests. If there are multiple devices, use sharding.

  Args:
    options: command line options.

  Returns:
    A list of test results.
  """

    attached_devices = android_commands.GetAttachedDevices()
    if not attached_devices:
        raise Exception('You have no devices attached or visible!')
    if options.device:
        attached_devices = [options.device]

    test_collection = TestInfoCollection()
    all_tests = _GetAllTests(options.python_test_root, options.official_build)
    test_collection.AddTests(all_tests)
    test_names = [t.qualified_name for t in all_tests]
    logging.debug('All available tests: ' + str(test_names))

    available_tests = test_collection.GetAvailableTests(
        options.annotations, options.exclude_annotations, options.test_filter)

    if not available_tests:
        logging.warning('No Python tests to run with current args.')
        return base_test_result.TestRunResults()

    test_names = [t.qualified_name for t in available_tests]
    logging.debug('Final list of tests to run: ' + str(test_names))

    # Copy files to each device before running any tests.
    for device_id in attached_devices:
        logging.debug('Pushing files to device %s', device_id)
        test_pkg = test_package.TestPackage(options.test_apk_path,
                                            options.test_apk_jar_path)
        test_files_copier = test_runner.TestRunner(options, device_id, 0,
                                                   test_pkg, [])
        test_files_copier.InstallTestPackage()
        if options.push_deps:
            logging.info('Pushing data deps to device.')
            test_files_copier.PushDataDeps()
        else:
            logging.warning('Skipping pushing data deps to device.')

    # Actually run the tests.
    if len(attached_devices) > 1 and options.wait_for_debugger:
        logging.warning('Debugger can not be sharded, '
                        'using first available device')
        attached_devices = attached_devices[:1]
    logging.debug('Running Python tests')
    sharder = PythonTestSharder(attached_devices, available_tests, options)
    test_results = sharder.RunShardedTests()

    return test_results
コード例 #24
0
def ProvisionDevices(options):
    if options.device is not None:
        devices = [options.device]
    else:
        devices = android_commands.GetAttachedDevices()
    for device in devices:
        android_cmd = android_commands.AndroidCommands(device)
        android_cmd.RunShellCommand('su -c date -u %f' % time.time())
    if options.auto_reconnect:
        PushAndLaunchAdbReboot(devices, options.target)
コード例 #25
0
  def setUp(self):
    devices = android_commands.GetAttachedDevices()
    self.browser = 'stable'
    self.package_info = profiler.GetSupportedBrowsers()[self.browser]
    self.device = device_utils.DeviceUtils(devices[0])

    adb = android_commands.AndroidCommands(devices[0])
    adb.StartActivity(self.package_info.package,
                      self.package_info.activity,
                      wait_for_completion=True)
コード例 #26
0
 def EnumerateDevices(self):
   # If a custom adb_path has been setup through settings, prepend that to the
   # PATH. The android_commands module will use that to locate adb.
   if (self.settings['adb_path'] and
       not os.environ['PATH'].startswith(self.settings['adb_path'])):
     os.environ['PATH'] = os.pathsep.join([self.settings['adb_path'],
                                          os.environ['PATH']])
   for device in android_commands.GetAttachedDevices():
     yield AndroidDevice(
         self, android_commands.AndroidCommands(device, api_strict_mode=True))
コード例 #27
0
    def setUp(self):
        devices = android_commands.GetAttachedDevices()
        self.browser = 'stable'
        self.package_info = profiler.GetSupportedBrowsers()[self.browser]
        self.device = device_utils.DeviceUtils(devices[0])

        self.device.StartActivity(intent.Intent(
            activity=self.package_info.activity,
            package=self.package_info.package),
                                  blocking=True)
コード例 #28
0
def main():
    while True:
        try:
            devices = android_commands.GetAttachedDevices()
            for device in devices:
                android_cmd = android_commands.AndroidCommands(device)
                android_cmd.RunShellCommand('touch /sdcard/host_heartbeat')
        except:
            # Keep the heatbeat running bypassing all errors.
            pass
        time.sleep(PULSE_PERIOD)
コード例 #29
0
 def GlobalSetUp():
   ChromeDriverTest._http_server = webserver.WebServer(
       chrome_paths.GetTestData())
   ChromeDriverTest._sync_server = webserver.SyncWebServer()
   if _ANDROID_PACKAGE_KEY:
     ChromeDriverTest._device = device_utils.DeviceUtils(
         android_commands.GetAttachedDevices()[0])
     http_host_port = ChromeDriverTest._http_server._server.server_port
     sync_host_port = ChromeDriverTest._sync_server._server.server_port
     forwarder.Forwarder.Map(
         [(http_host_port, http_host_port), (sync_host_port, sync_host_port)],
         ChromeDriverTest._device)
コード例 #30
0
def main():
    while True:
        try:
            devices = android_commands.GetAttachedDevices()
            for device_serial in devices:
                device_utils.DeviceUtils(
                    device_serial).old_interface.RunShellCommand(
                        'touch /sdcard/host_heartbeat')
        except:
            # Keep the heatbeat running bypassing all errors.
            pass
        time.sleep(PULSE_PERIOD)