Exemple #1
0
def PrintAnnotationForTestResults(test_results):
    if test_results.timed_out:
        buildbot_report.PrintWarning()
    elif test_results.failed or test_results.crashed or test_results.overall_fail:
        buildbot_report.PrintError()
    else:
        print 'Step success!'  # No annotation needed
def RunCmd(command, flunk_on_failure=True):
  """Run a command relative to the chrome source root."""
  code = SpawnCmd(command).wait()
  print '<', ' '.join(map(pipes.quote, command))
  if code != 0:
    print 'ERROR: process exited with code %d' % code
    if flunk_on_failure:
      buildbot_report.PrintError()
    else:
      buildbot_report.PrintWarning()
  return code
Exemple #3
0
def RunCmd(command, flunk_on_failure=True):
  """Run a command relative to the chrome source root."""
  code = SpawnCmd(command).wait()
  print '<', ' '.join(map(pipes.quote, command))
  if code != 0:
    print 'ERROR: non-zero status %d from %s' % (code, command)
    if flunk_on_failure:
      buildbot_report.PrintError()
    else:
      buildbot_report.PrintWarning()
  return code
Exemple #4
0
def RunCmd(command,
           flunk_on_failure=True,
           halt_on_failure=False,
           warning_code=88):
    """Run a command relative to the chrome source root."""
    code = SpawnCmd(command).wait()
    print '<', CommandToString(command)
    if code != 0:
        print 'ERROR: process exited with code %d' % code
        if code != warning_code and flunk_on_failure:
            buildbot_report.PrintError()
        else:
            buildbot_report.PrintWarning()
        # Allow steps to have both halting (i.e. 1) and non-halting exit codes.
        if code != warning_code and halt_on_failure:
            raise OSError()
    return code
def _RunATestSuite(options):
    """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.

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

    if options.use_emulator:
        for n in range(options.emulator_count):
            t = TimeProfile('Emulator launch %d' % n)
            avd_name = None
            if n > 0:
                # Creates a temporary AVD for the extra emulators.
                avd_name = 'run_tests_avd_%d' % n
            buildbot_emulator = emulator.Emulator(avd_name,
                                                  options.fast_and_loose)
            buildbot_emulator.Launch(kill_all_emulators=n == 0)
            t.Stop()
            buildbot_emulators.append(buildbot_emulator)
            attached_devices.append(buildbot_emulator.device)
        # Wait for all emulators to boot completed.
        map(lambda buildbot_emulator: buildbot_emulator.ConfirmLaunch(True),
            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.')
        buildbot_report.PrintError()
        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.performance_test or options.gtest_filter:
        # These configuration can't be split in multiple devices.
        attached_devices = [attached_devices[0]]
    sharder = TestSharder(attached_devices, options.test_suite,
                          options.gtest_filter, options.test_arguments,
                          options.timeout, options.rebaseline,
                          options.performance_test, options.cleanup_test_files,
                          options.tool, options.log_dump,
                          options.fast_and_loose, options.build_type)
    test_results = sharder.RunShardedTests()

    for buildbot_emulator in buildbot_emulators:
        buildbot_emulator.Shutdown()

    # Another chance if we timed out?  At this point It is safe(r) to
    # run fast and loose since we just uploaded all the test data and
    # binary.
    if test_results.timed_out and options.repeat:
        logging.critical('Timed out; repeating in fast_and_loose mode.')
        options.fast_and_loose = True
        options.repeat -= 1
        logging.critical('Repeats left: ' + str(options.repeat))
        return _RunATestSuite(options)
    return len(test_results.failed)
Exemple #6
0
def _RunATestSuite(options):
  """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.

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

  if options.use_emulator:
    for n in range(options.emulator_count):
      t = time_profile.TimeProfile('Emulator launch %d' % n)
      avd_name = None
      if n > 0:
        # Creates a temporary AVD for the extra emulators.
        avd_name = 'run_tests_avd_%d' % n
      buildbot_emulator = emulator.Emulator(avd_name, options.fast_and_loose)
      buildbot_emulator.Launch(kill_all_emulators=n == 0)
      t.Stop()
      buildbot_emulators.append(buildbot_emulator)
      attached_devices.append(buildbot_emulator.device)
    # Wait for all emulators to boot completed.
    map(lambda buildbot_emulator: buildbot_emulator.ConfirmLaunch(True),
        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.')
    buildbot_report.PrintError()
    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 = TestSharder(
      attached_devices,
      options.test_suite,
      options.gtest_filter,
      options.test_arguments,
      options.timeout,
      options.cleanup_test_files,
      options.tool,
      options.log_dump,
      options.fast_and_loose,
      options.build_type,
      options.webkit,
      options.flakiness_dashboard_server)
  test_results = sharder.RunShardedTests()

  for buildbot_emulator in buildbot_emulators:
    buildbot_emulator.Shutdown()

  return len(test_results.failed)
Exemple #7
0
def PrintAnnotation(results):
    """Print buildbot annotations for test results."""
    if not results.DidRunPass():
        buildbot_report.PrintError()
    else:
        print 'Step success!'  # No annotation needed
 def PrintAnnotation(self):
   """Print buildbot annotations for test results."""
   if self.GetAllBroken():
     buildbot_report.PrintError()
   else:
     print 'Step success!'  # No annotation needed