def MaybeRelease(revision):
  # Version is embedded as: const char kChromeDriverVersion[] = "0.1";
  # Minimum supported Chrome version is embedded as:
  # const int kMinimumSupportedChromeVersion[] = {27, 0, 1453, 0};
  with open(os.path.join(_THIS_DIR, 'chrome', 'version.cc'), 'r') as f:
    lines = f.readlines()
    version_line = filter(lambda x: 'kChromeDriverVersion' in x, lines)
    chrome_min_version_line = filter(
        lambda x: 'kMinimumSupportedChromeVersion' in x, lines)
  version = version_line[0].split('"')[1]
  chrome_min_version = chrome_min_version_line[0].split('{')[1].split(',')[0]
  with open(os.path.join(chrome_paths.GetSrc(), 'chrome', 'VERSION'), 'r') as f:
    chrome_max_version = f.readlines()[0].split('=')[1]

  bitness = '32'
  if util.IsLinux() and platform.architecture()[0] == '64bit':
    bitness = '64'
  zip_name = 'chromedriver_%s%s_%s.zip' % (
      util.GetPlatformName(), bitness, version)

  site = 'https://code.google.com/p/chromedriver/downloads/list'
  s = urllib2.urlopen(site)
  downloads = s.read()
  s.close()

  if zip_name in downloads:
    return 0

  util.MarkBuildStepStart('releasing %s' % zip_name)
  if util.IsWindows():
    server_orig_name = 'chromedriver2_server.exe'
    server_name = 'chromedriver.exe'
  else:
    server_orig_name = 'chromedriver2_server'
    server_name = 'chromedriver'
  server = os.path.join(chrome_paths.GetBuildDir([server_orig_name]),
                        server_orig_name)

  print 'Zipping ChromeDriver server', server
  temp_dir = util.MakeTempDir()
  zip_path = os.path.join(temp_dir, zip_name)
  f = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED)
  f.write(server, server_name)
  f.close()

  cmd = [
      sys.executable,
      os.path.join(_THIS_DIR, 'third_party', 'googlecode',
                   'googlecode_upload.py'),
      '--summary',
      'ChromeDriver server for %s%s (v%s.%s.dyu) supports Chrome v%s-%s' % (
          util.GetPlatformName(), bitness, version, revision,
          chrome_min_version, chrome_max_version),
      '--project', 'chromedriver',
      '--user', '*****@*****.**',
      zip_path
  ]
  with open(os.devnull, 'wb') as no_output:
    if subprocess.Popen(cmd, stdout=no_output, stderr=no_output).wait():
      util.MarkBuildStepError()
示例#2
0
def _GetDesktopNegativeFilter(version_name):
  filter = _NEGATIVE_FILTER + _DESKTOP_NEGATIVE_FILTER
  os = util.GetPlatformName()
  if os in _OS_SPECIFIC_FILTER:
    filter += _OS_SPECIFIC_FILTER[os]
  if version_name in _VERSION_SPECIFIC_FILTER:
    filter += _VERSION_SPECIFIC_FILTER[version_name]
  return filter
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-packages',
        help='Comma separated list of application package names, '
        'if running tests on Android.')
    parser.add_option('-r', '--revision', type='int', help='Chromium revision')
    parser.add_option(
        '',
        '--update-log',
        action='store_true',
        help='Update the test results log (only applicable to Android)')
    options, _ = parser.parse_args()

    bitness = '32'
    if util.IsLinux() and platform_module.architecture()[0] == '64bit':
        bitness = '64'
    platform = '%s%s' % (util.GetPlatformName(), bitness)
    if options.android_packages:
        platform = 'android'

    if platform != 'android':
        _KillChromes()
    _CleanTmpDir()

    if platform == 'android':
        if not options.revision and options.update_log:
            parser.error('Must supply a --revision with --update-log')
        _DownloadPrebuilts()
    else:
        if not options.revision:
            parser.error('Must supply a --revision')
        if platform == 'linux64':
            _ArchivePrebuilts(options.revision)
        _WaitForLatestSnapshot(options.revision)

    _AddToolsToPath(platform)

    cmd = [
        sys.executable,
        os.path.join(_THIS_DIR, 'test', 'run_all_tests.py'),
    ]
    if platform == 'android':
        cmd.append('--android-packages=' + options.android_packages)

    passed = (util.RunCommand(cmd) == 0)

    _ArchiveServerLogs()

    if platform == 'android':
        if options.update_log:
            util.MarkBuildStepStart('update test result log')
            _UpdateTestResultsLog(platform, options.revision, passed)
    elif passed:
        _ArchiveGoodBuild(platform, options.revision)
        _MaybeRelease(platform)
示例#4
0
def _KillChromes():
    chrome_map = {
        'win': 'chrome.exe',
        'mac': 'Chromium',
        'linux': 'chrome',
    }
    if util.IsWindows():
        cmd = ['taskkill', '/F', '/IM']
    else:
        cmd = ['killall', '-9']
    cmd.append(chrome_map[util.GetPlatformName()])
    util.RunCommand(cmd)
示例#5
0
def StartChromeDriverServer(chromedriver_binary, options):
    chromedriver = util.GetAbsolutePathOfUserPath(chromedriver_binary)
    if (not os.path.exists(chromedriver) and util.GetPlatformName() == "win"
            and not chromedriver.lower().endswith(".exe")):
        chromedriver = chromedriver + ".exe"
    if options.output_log_path:
        options.output_log_path = util.GetAbsolutePathOfUserPath(
            options.output_log_path)

    chromedriver_server = server.Server(chromedriver_binary,
                                        log_path=options.output_log_path)

    return chromedriver_server
def StartChromeDriverServer(chromedriver_binary,
                            output_log_path,
                            devtools_replay_path="",
                            replayable=False):
    chromedriver = util.GetAbsolutePathOfUserPath(chromedriver_binary)
    if (not os.path.exists(chromedriver) and util.GetPlatformName() == "win"
            and not chromedriver.lower().endswith(".exe")):
        chromedriver = chromedriver + ".exe"
    if output_log_path:
        output_log_path = util.GetAbsolutePathOfUserPath(output_log_path)

    chromedriver_server = server.Server(
        chromedriver_binary,
        log_path=output_log_path,
        devtools_replay_path=devtools_replay_path,
        replayable=replayable)

    return chromedriver_server
示例#7
0
  def __init__(self, *args, **kwargs):
    try:
      self._InternalInit(*args, **kwargs)
    except Exception as e:
      if not e.message.startswith('timed out'):
        raise
      else:
        # Temp code for debugging https://crbug.com/chromedriver/2778.
        # If enabled, trigger a core dump on first timeout.
        # The code is only intended for Linux, where the above bug is observed.
        global enable_core_dump
        if enable_core_dump and util.GetPlatformName() == 'linux':
          enable_core_dump = False
          import psutil
          import signal
          this_process = psutil.Process()
          chromedriver_process = this_process.children()[0]
          if chromedriver_process.name() == 'chromedriver':
            chrome_processes = chromedriver_process.children()
            if len(chrome_processes) == 1:
              # Remove core file size limit, then use SIGABRT to dump core.
              # Newer versions of psutil.Process have rlimit method, while older
              # versions have set_rlimit method.
              if hasattr(chrome_processes[0], 'rlimit'):
                rlimit_method = chrome_processes[0].rlimit
              else:
                rlimit_method = chrome_processes[0].set_rlimit
              rlimit_method(
                  psutil.RLIMIT_CORE,
                  (psutil.RLIM_INFINITY, psutil.RLIM_INFINITY))
              chrome_processes[0].send_signal(signal.SIGABRT)
            else:
              print 'Skipping core dump as ChromeDriver has unexpected children'
          else:
            print 'Unable to find ChromeDriver process, skipping core dump'

        if ChromeDriver.retry_count < MAX_RETRY_COUNT:
          ChromeDriver.retry_count = ChromeDriver.retry_count + 1
          ChromeDriver.retried_tests.append(kwargs.get('test_name'))
          self._InternalInit(*args, **kwargs)
        else:
          raise
示例#8
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-package',
        help='Application package name, if running tests on Android.')
    # Option 'chrome-version' is for desktop only.
    parser.add_option(
        '',
        '--chrome-version',
        help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.'
        'Default is to run tests against all of these versions.'
        'Notice: this option only applies to desktop.')
    options, _ = parser.parse_args()

    exe_postfix = ''
    if util.IsWindows():
        exe_postfix = '.exe'
    cpp_tests_name = 'chromedriver2_tests' + exe_postfix
    server_name = 'chromedriver2_server' + exe_postfix

    required_build_outputs = [server_name]
    if not options.android_package:
        required_build_outputs += [cpp_tests_name]
    build_dir = chrome_paths.GetBuildDir(required_build_outputs)
    print 'Using build outputs from', build_dir

    chromedriver = os.path.join(build_dir, server_name)
    platform_name = util.GetPlatformName()
    if util.IsLinux() and platform.architecture()[0] == '64bit':
        platform_name += '64'
    ref_chromedriver = os.path.join(
        chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party',
        'java_tests', 'reference_builds',
        'chromedriver_%s%s' % (platform_name, exe_postfix))

    if util.IsLinux():
        # Set LD_LIBRARY_PATH to enable successful loading of shared object files,
        # when chromedriver2.so is not a static build.
        _AppendEnvironmentPath('LD_LIBRARY_PATH',
                               os.path.join(build_dir, 'lib'))
    elif util.IsWindows():
        # For Windows bots: add ant, java(jre) and the like to system path.
        _AddToolsToSystemPathForWindows()

    if options.android_package:
        os.environ['PATH'] += os.pathsep + os.path.join(_THIS_DIR, 'chrome')
        code1 = RunPythonTests(chromedriver,
                               ref_chromedriver,
                               android_package=options.android_package)
        code2 = RunJavaTests(chromedriver,
                             android_package=options.android_package)
        return code1 or code2
    else:
        latest_snapshot_revision = archive.GetLatestRevision(
            archive.Site.SNAPSHOT)
        versions = [['HEAD', latest_snapshot_revision],
                    ['28', archive.CHROME_28_REVISION],
                    ['27', archive.CHROME_27_REVISION]]
        code = 0
        for version in versions:
            if options.chrome_version and version[0] != options.chrome_version:
                continue
            download_site = archive.Site.CONTINUOUS
            version_name = version[0]
            if version_name == 'HEAD':
                version_name = version[1]
                download_site = archive.Site.SNAPSHOT
            chrome_path = archive.DownloadChrome(version[1],
                                                 util.MakeTempDir(),
                                                 download_site)
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome=chrome_path,
                                   chrome_version=version[0],
                                   chrome_version_name=version_name)
            code2 = RunJavaTests(chromedriver,
                                 chrome=chrome_path,
                                 chrome_version=version[0],
                                 chrome_version_name=version_name)
            code = code or code1 or code2
        cpp_tests = os.path.join(build_dir, cpp_tests_name)
        return RunCppTests(cpp_tests) or code
示例#9
0
    def _InternalInit(self,
                      server_url,
                      chrome_binary=None,
                      android_package=None,
                      android_activity=None,
                      android_process=None,
                      android_use_running_app=None,
                      chrome_switches=None,
                      chrome_extensions=None,
                      chrome_log_path=None,
                      debugger_address=None,
                      logging_prefs=None,
                      mobile_emulation=None,
                      experimental_options=None,
                      download_dir=None,
                      network_connection=None,
                      send_w3c_capability=True,
                      send_w3c_request=True,
                      page_load_strategy=None,
                      unexpected_alert_behaviour=None,
                      devtools_events_to_log=None,
                      accept_insecure_certs=None,
                      timeouts=None,
                      test_name=None):
        self._executor = command_executor.CommandExecutor(server_url)
        self._server_url = server_url
        self.w3c_compliant = False
        self._websocket = None

        options = {}

        if experimental_options:
            assert isinstance(experimental_options, dict)
            options = experimental_options.copy()

        if android_package:
            options['androidPackage'] = android_package
            if android_activity:
                options['androidActivity'] = android_activity
            if android_process:
                options['androidProcess'] = android_process
            if android_use_running_app:
                options['androidUseRunningApp'] = android_use_running_app
        elif chrome_binary:
            options['binary'] = chrome_binary

        if sys.platform.startswith('linux') and android_package is None:
            if chrome_switches is None:
                chrome_switches = []
            # Workaround for crbug.com/611886.
            chrome_switches.append('no-sandbox')
            # https://bugs.chromium.org/p/chromedriver/issues/detail?id=1695
            chrome_switches.append('disable-gpu')

        if chrome_switches is None:
            chrome_switches = []
        chrome_switches.append('force-color-profile=srgb')

        if chrome_switches:
            assert type(chrome_switches) is list
            options['args'] = chrome_switches

            # TODO(crbug.com/1011000): Work around a bug with headless on Mac.
            if util.GetPlatformName(
            ) == 'mac' and '--headless' in chrome_switches:
                options['excludeSwitches'] = ['--enable-logging']

        if mobile_emulation:
            assert type(mobile_emulation) is dict
            options['mobileEmulation'] = mobile_emulation

        if chrome_extensions:
            assert type(chrome_extensions) is list
            options['extensions'] = chrome_extensions

        if chrome_log_path:
            assert type(chrome_log_path) is str
            options['logPath'] = chrome_log_path

        if debugger_address:
            assert type(debugger_address) is str
            options['debuggerAddress'] = debugger_address

        if logging_prefs:
            assert type(logging_prefs) is dict
            log_types = [
                'client', 'driver', 'browser', 'server', 'performance',
                'devtools'
            ]
            log_levels = ['ALL', 'DEBUG', 'INFO', 'WARNING', 'SEVERE', 'OFF']
            for log_type, log_level in logging_prefs.items():
                assert log_type in log_types
                assert log_level in log_levels
        else:
            logging_prefs = {}

        if devtools_events_to_log:
            assert type(devtools_events_to_log) is list
            options['devToolsEventsToLog'] = devtools_events_to_log

        download_prefs = {}
        if download_dir:
            if 'prefs' not in options:
                options['prefs'] = {}
            if 'download' not in options['prefs']:
                options['prefs']['download'] = {}
            options['prefs']['download']['default_directory'] = download_dir

        if send_w3c_capability is not None:
            options['w3c'] = send_w3c_capability

        params = {
            'goog:chromeOptions': options,
            'se:options': {
                'loggingPrefs': logging_prefs
            }
        }

        if page_load_strategy:
            assert type(page_load_strategy) is str
            params['pageLoadStrategy'] = page_load_strategy

        if unexpected_alert_behaviour:
            assert type(unexpected_alert_behaviour) is str
            if send_w3c_request:
                params['unhandledPromptBehavior'] = unexpected_alert_behaviour
            else:
                params['unexpectedAlertBehaviour'] = unexpected_alert_behaviour

        if network_connection:
            params['networkConnectionEnabled'] = network_connection

        if accept_insecure_certs is not None:
            params['acceptInsecureCerts'] = accept_insecure_certs

        if timeouts is not None:
            params['timeouts'] = timeouts

        if test_name is not None:
            params['goog:testName'] = test_name

        if send_w3c_request:
            params = {'capabilities': {'alwaysMatch': params}}
        else:
            params = {'desiredCapabilities': params}

        response = self._ExecuteCommand(Command.NEW_SESSION, params)
        if len(response.keys()) == 1 and 'value' in response.keys():
            self.w3c_compliant = True
            self._session_id = response['value']['sessionId']
            self.capabilities = self._UnwrapValue(
                response['value']['capabilities'])
            self.debuggerAddress = str(
                self.capabilities['goog:chromeOptions']['debuggerAddress'])
        elif isinstance(response['status'], int):
            self.w3c_compliant = False
            self._session_id = response['sessionId']
            self.capabilities = self._UnwrapValue(response['value'])
        else:
            raise UnknownError("unexpected response")
示例#10
0
def main():
  parser = optparse.OptionParser()
  parser.add_option(
      '', '--android-packages',
      help=('Comma separated list of application package names, '
            'if running tests on Android.'))
  parser.add_option(
      '-r', '--revision', help='Chromium git revision hash')
  parser.add_option(
      '', '--update-log', action='store_true',
      help='Update the test results log (only applicable to Android)')
  options, _ = parser.parse_args()

  bitness = '32'
  if util.Is64Bit():
    bitness = '64'
  platform = '%s%s' % (util.GetPlatformName(), bitness)
  if options.android_packages:
    platform = 'android'

  if not options.revision:
    commit_position = None
  else:
    commit_position = archive.GetCommitPositionFromGitHash(options.revision)
    if commit_position is None:
      raise Exception('Failed to convert revision to commit position')

  if platform == 'android':
    if not options.revision and options.update_log:
      parser.error('Must supply a --revision with --update-log')
    _DownloadPrebuilts()
  else:
    if not options.revision:
      parser.error('Must supply a --revision')
    if platform == 'linux64':
      _ArchivePrebuilts(commit_position)
    _WaitForLatestSnapshot(commit_position)

  _AddToolsToPath(platform)

  cmd = [
      sys.executable,
      os.path.join(_THIS_DIR, 'test', 'run_all_tests.py'),
  ]
  if platform == 'android':
    cmd.append('--android-packages=' + options.android_packages)

  passed = (util.RunCommand(cmd) == 0)

  _ArchiveServerLogs()

  if platform == 'android':
    if options.update_log:
      util.MarkBuildStepStart('update test result log')
      _UpdateTestResultsLog(platform, commit_position, passed)
  elif passed:
    _ArchiveGoodBuild(platform, commit_position)
    _MaybeRelease(platform)

  if not passed:
    # Make sure the build is red if there is some uncaught exception during
    # running run_all_tests.py.
    util.MarkBuildStepStart('run_all_tests.py')
    util.MarkBuildStepError()

  # Add a "cleanup" step so that errors from runtest.py or bb_device_steps.py
  # (which invoke this script) are kept in their own build step.
  util.MarkBuildStepStart('cleanup')

  return 0 if passed else 1
示例#11
0
    host = Host()
    port = host.port_factory.get()
    path_finder = PathFinder(host.filesystem)

    # Starts WPT Serve to serve the WPT WebDriver test content.
    port.start_wptserve()

    # WebDriverExpectations stores skipped and failed WebDriver tests.
    expectations = parse_webdriver_expectations(host, port)
    skipped_tests = preprocess_skipped_tests(test_results, expectations,
                                             path_finder)

    options.chromedriver = util.GetAbsolutePathOfUserPath(options.chromedriver)
    if (not os.path.exists(options.chromedriver)
            and util.GetPlatformName() == 'win'
            and not options.chromedriver.lower().endswith('.exe')):
        options.chromedriver = options.chromedriver + '.exe'

    if not os.path.exists(options.chromedriver):
        parser.error('Path given by --chromedriver is invalid.\n' +
                     'Please run "%s --help" for help' % __file__)

    # Due to occasional timeout in starting ChromeDriver, retry once when needed.
    try:
        chromedriver_server = server.Server(options.chromedriver,
                                            options.log_path)
    except RuntimeError as e:
        _log.warn('Error starting ChromeDriver, retrying...')
        chromedriver_server = server.Server(options.chromedriver,
                                            options.log_path)
示例#12
0
def main():
  parser = optparse.OptionParser()
  parser.add_option(
      '', '--android-packages',
      help='Comma separated list of application package names, '
           'if running tests on Android.')
  # Option 'chrome-version' is for desktop only.
  parser.add_option(
      '', '--chrome-version',
      help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.'
           'Default is to run tests against all of these versions.'
           'Notice: this option only applies to desktop.')
  options, _ = parser.parse_args()

  exe_postfix = ''
  if util.IsWindows():
    exe_postfix = '.exe'
  cpp_tests_name = 'chromedriver_tests' + exe_postfix
  server_name = 'chromedriver' + exe_postfix

  required_build_outputs = [server_name]
  if not options.android_packages:
    required_build_outputs += [cpp_tests_name]
  try:
    build_dir = chrome_paths.GetBuildDir(required_build_outputs)
  except RuntimeError:
    util.MarkBuildStepStart('check required binaries')
    traceback.print_exc()
    util.MarkBuildStepError()
  constants.SetBuildType(os.path.basename(build_dir))
  print 'Using build outputs from', build_dir

  chromedriver = os.path.join(build_dir, server_name)
  platform_name = util.GetPlatformName()
  if util.IsLinux() and util.Is64Bit():
    platform_name += '64'
  ref_chromedriver = os.path.join(
      chrome_paths.GetSrc(),
      'chrome', 'test', 'chromedriver', 'third_party', 'java_tests',
      'reference_builds',
      'chromedriver_%s%s' % (platform_name, exe_postfix))

  if options.android_packages:
    os.environ['PATH'] += os.pathsep + os.path.join(
        _THIS_DIR, os.pardir, 'chrome')
    code = 0
    for package in options.android_packages.split(','):
      code1 = RunPythonTests(chromedriver,
                             ref_chromedriver,
                             chrome_version_name=package,
                             android_package=package)
      code2 = RunJavaTests(chromedriver,
                           chrome_version_name=package,
                           android_package=package,
                           verbose=True)
      code = code or code1 or code2
    return code
  else:
    versions = {'HEAD': archive.GetLatestRevision()}
    if util.IsLinux() and not util.Is64Bit():
      # Linux32 builds need to be special-cased, because 1) they are keyed by
      # git hash rather than commit position, and 2) come from a different
      # download site (so we can't just convert the commit position to a hash).
      versions['63'] = 'adb61db19020ed8ecee5e91b1a0ea4c924ae2988'
      versions['62'] = '17030e3a08cfbb6e591991f7dbf0eb703454b365'
      versions['61'] = '77132a2bc78e8dc9ce411e8166bfd009f6476f6f'

      # TODO(samuong): speculative fix for crbug.com/611886
      os.environ['CHROME_DEVEL_SANDBOX'] = '/opt/chromium/chrome_sandbox'

    # Linux64 build numbers
    elif util.IsLinux():
      versions['65'] = '530372'
      versions['64'] = '520842'
      versions['63'] = '508578'

    # Mac build numbers
    elif util.IsMac():
      versions['65'] = '530368'
      versions['64'] = '520840'
      versions['63'] = '508578'

    # Windows build numbers
    elif util.IsWindows():
      versions['65'] = '530366'
      versions['64'] = '520840'
      versions['63'] = '508578'

    code = 0
    for version, revision in versions.iteritems():
      if options.chrome_version and version != options.chrome_version:
        continue
      download_site = archive.GetDownloadSite()
      version_name = version
      if version_name == 'HEAD':
        version_name = revision
      temp_dir, chrome_path = DownloadChrome(version_name, revision,
                                             download_site)
      if not chrome_path:
        code = 1
        continue
      code1 = RunPythonTests(chromedriver,
                             ref_chromedriver,
                             chrome=chrome_path,
                             chrome_version=version,
                             chrome_version_name='v%s' % version_name)
      code2 = RunJavaTests(chromedriver, chrome=chrome_path,
                           chrome_version=version,
                           chrome_version_name='v%s' % version_name)
      code = code or code1 or code2
      _KillChromes()
      shutil.rmtree(temp_dir)
    cpp_tests = os.path.join(build_dir, cpp_tests_name)
    return RunCppTests(cpp_tests) or code
示例#13
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-packages',
        help='Comma separated list of application package names, '
        'if running tests on Android.')
    # Option 'chrome-version' is for desktop only.
    parser.add_option(
        '',
        '--chrome-version',
        help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.'
        'Default is to run tests against all of these versions.'
        'Notice: this option only applies to desktop.')
    options, _ = parser.parse_args()

    exe_postfix = ''
    if util.IsWindows():
        exe_postfix = '.exe'
    cpp_tests_name = 'chromedriver_tests' + exe_postfix
    server_name = 'chromedriver' + exe_postfix

    required_build_outputs = [server_name]
    if not options.android_packages:
        required_build_outputs += [cpp_tests_name]
    try:
        build_dir = chrome_paths.GetBuildDir(required_build_outputs)
    except RuntimeError:
        util.MarkBuildStepStart('check required binaries')
        traceback.print_exc()
        util.MarkBuildStepError()
    constants.SetBuildType(os.path.basename(build_dir))
    print 'Using build outputs from', build_dir

    chromedriver = os.path.join(build_dir, server_name)
    platform_name = util.GetPlatformName()
    if util.IsLinux() and util.Is64Bit():
        platform_name += '64'
    ref_chromedriver = os.path.join(
        chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party',
        'java_tests', 'reference_builds',
        'chromedriver_%s%s' % (platform_name, exe_postfix))

    if options.android_packages:
        os.environ['PATH'] += os.pathsep + os.path.join(
            _THIS_DIR, os.pardir, 'chrome')
        code = 0
        for package in options.android_packages.split(','):
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome_version_name=package,
                                   android_package=package)
            code2 = RunJavaTests(chromedriver,
                                 chrome_version_name=package,
                                 android_package=package,
                                 verbose=True)
            code = code or code1 or code2
        return code
    else:
        versions = {'HEAD': archive.GetLatestRevision()}
        if util.IsLinux() and not util.Is64Bit():
            # Linux32 builds need to be special-cased, because 1) they are keyed by
            # git hash rather than commit position, and 2) come from a different
            # download site (so we can't just convert the commit position to a hash).
            versions['51'] = '5a161bb6fe3d6bfbe2dafc0a7dd5831478f34277'
            versions['50'] = '4acbec91b57f31a501264906aded632cc64c9300'
            versions['49'] = '7acdedefe3ddcb27b3fc826027f519bdb5d04d7e'
        else:
            versions['51'] = '386266'
            versions['50'] = '378110'
            versions['49'] = '369932'
        code = 0
        for version, revision in versions.iteritems():
            if options.chrome_version and version != options.chrome_version:
                continue
            download_site = archive.GetDownloadSite()
            version_name = version
            if version_name == 'HEAD':
                version_name = revision
            temp_dir, chrome_path = DownloadChrome(version_name, revision,
                                                   download_site)
            if not chrome_path:
                code = 1
                continue
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome=chrome_path,
                                   chrome_version=version,
                                   chrome_version_name='v%s' % version_name)
            code2 = RunJavaTests(chromedriver,
                                 chrome=chrome_path,
                                 chrome_version=version,
                                 chrome_version_name='v%s' % version_name)
            code = code or code1 or code2
            _KillChromes()
            shutil.rmtree(temp_dir)
        cpp_tests = os.path.join(build_dir, cpp_tests_name)
        return RunCppTests(cpp_tests) or code
示例#14
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-packages',
        help='Comma separated list of application package names, '
        'if running tests on Android.')
    # Option 'chrome-version' is for desktop only.
    parser.add_option(
        '',
        '--chrome-version',
        help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.'
        'Default is to run tests against all of these versions.'
        'Notice: this option only applies to desktop.')
    options, _ = parser.parse_args()

    exe_postfix = ''
    if util.IsWindows():
        exe_postfix = '.exe'
    cpp_tests_name = 'chromedriver_tests' + exe_postfix
    server_name = 'chromedriver' + exe_postfix

    required_build_outputs = [server_name]
    if not options.android_packages:
        required_build_outputs += [cpp_tests_name]
    try:
        build_dir = chrome_paths.GetBuildDir(required_build_outputs)
    except RuntimeError:
        util.MarkBuildStepStart('check required binaries')
        traceback.print_exc()
        util.MarkBuildStepError()
    constants.SetBuildType(os.path.basename(build_dir))
    print 'Using build outputs from', build_dir

    chromedriver = os.path.join(build_dir, server_name)
    platform_name = util.GetPlatformName()
    if util.IsLinux() and util.Is64Bit():
        platform_name += '64'
    ref_chromedriver = os.path.join(
        chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party',
        'java_tests', 'reference_builds',
        'chromedriver_%s%s' % (platform_name, exe_postfix))

    if options.android_packages:
        os.environ['PATH'] += os.pathsep + os.path.join(
            _THIS_DIR, os.pardir, 'chrome')
        code = 0
        for package in options.android_packages.split(','):
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome_version_name=package,
                                   android_package=package)
            code2 = RunJavaTests(chromedriver,
                                 chrome_version_name=package,
                                 android_package=package,
                                 verbose=True)
            code = code or code1 or code2
        return code
    else:
        versions = {'HEAD': archive.GetLatestRevision()}
        if util.IsLinux() and not util.Is64Bit():
            # Linux32 builds need to be special-cased, because 1) they are keyed by
            # git hash rather than commit position, and 2) come from a different
            # download site (so we can't just convert the commit position to a hash).
            versions['55'] = 'e9bc4e0245c9a1e570ed2cf8e12152b9122275f2'
            versions['54'] = '13d140acdaa710770f42790044825b49f99e466c'
            versions['53'] = 'ac799c2fd50b8fb62b7a8186ff78b025de5b8718'
            # TODO(samuong): speculative fix for crbug.com/611886
            os.environ['CHROME_DEVEL_SANDBOX'] = '/opt/chromium/chrome_sandbox'
        else:
            versions['55'] = '423791'
            versions['54'] = '414545'
            versions['53'] = '403392'
        code = 0
        for version, revision in versions.iteritems():
            if options.chrome_version and version != options.chrome_version:
                continue
            download_site = archive.GetDownloadSite()
            version_name = version
            if version_name == 'HEAD':
                version_name = revision
            temp_dir, chrome_path = DownloadChrome(version_name, revision,
                                                   download_site)
            if not chrome_path:
                code = 1
                continue
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome=chrome_path,
                                   chrome_version=version,
                                   chrome_version_name='v%s' % version_name)
            code2 = RunJavaTests(chromedriver,
                                 chrome=chrome_path,
                                 chrome_version=version,
                                 chrome_version_name='v%s' % version_name)
            code = code or code1 or code2
            _KillChromes()
            shutil.rmtree(temp_dir)
        cpp_tests = os.path.join(build_dir, cpp_tests_name)
        return RunCppTests(cpp_tests) or code
示例#15
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-packages',
        help='Comma separated list of application package names, '
        'if running tests on Android.')
    # Option 'chrome-version' is for desktop only.
    parser.add_option(
        '',
        '--chrome-version',
        help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.'
        'Default is to run tests against all of these versions.'
        'Notice: this option only applies to desktop.')
    options, _ = parser.parse_args()

    exe_postfix = ''
    if util.IsWindows():
        exe_postfix = '.exe'
    cpp_tests_name = 'chromedriver_tests' + exe_postfix
    server_name = 'chromedriver' + exe_postfix

    required_build_outputs = [server_name]
    if not options.android_packages:
        required_build_outputs += [cpp_tests_name]
    try:
        build_dir = chrome_paths.GetBuildDir(required_build_outputs)
    except RuntimeError:
        util.MarkBuildStepStart('check required binaries')
        traceback.print_exc()
        util.MarkBuildStepError()
    constants.SetBuildType(os.path.basename(build_dir))
    print 'Using build outputs from', build_dir

    chromedriver = os.path.join(build_dir, server_name)
    platform_name = util.GetPlatformName()
    if util.IsLinux() and platform.architecture()[0] == '64bit':
        platform_name += '64'
    ref_chromedriver = os.path.join(
        chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party',
        'java_tests', 'reference_builds',
        'chromedriver_%s%s' % (platform_name, exe_postfix))

    if options.android_packages:
        os.environ['PATH'] += os.pathsep + os.path.join(
            _THIS_DIR, os.pardir, 'chrome')
        code = 0
        for package in options.android_packages.split(','):
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome_version_name=package,
                                   android_package=package)
            code2 = RunJavaTests(chromedriver,
                                 chrome_version_name=package,
                                 android_package=package,
                                 verbose=True)
            code = code or code1 or code2
        return code
    else:
        latest_snapshot_revision = archive.GetLatestSnapshotVersion()
        versions = [
            ['HEAD', latest_snapshot_revision],
            ['49', archive.CHROME_49_REVISION],
            ['48', archive.CHROME_48_REVISION],
            ['47', archive.CHROME_47_REVISION],
        ]
        code = 0
        for version in versions:
            if options.chrome_version and version[0] != options.chrome_version:
                continue
            download_site = archive.Site.CONTINUOUS
            version_name = version[0]
            if version_name == 'HEAD':
                version_name = version[1]
                download_site = archive.GetSnapshotDownloadSite()
            temp_dir, chrome_path = DownloadChrome(version_name, version[1],
                                                   download_site)
            if not chrome_path:
                code = 1
                continue
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome=chrome_path,
                                   chrome_version=version[0],
                                   chrome_version_name='v%s' % version_name)
            code2 = RunJavaTests(chromedriver,
                                 chrome=chrome_path,
                                 chrome_version=version[0],
                                 chrome_version_name='v%s' % version_name)
            code = code or code1 or code2
            _KillChromes()
            shutil.rmtree(temp_dir)
        cpp_tests = os.path.join(build_dir, cpp_tests_name)
        return RunCppTests(cpp_tests) or code
示例#16
0
def main():
  parser = optparse.OptionParser()
  parser.add_option(
      '', '--android-packages',
      help='Comma separated list of application package names, '
           'if running tests on Android.')
  options, _ = parser.parse_args()

  exe_postfix = ''
  if util.IsWindows():
    exe_postfix = '.exe'
  cpp_tests_name = 'chromedriver_tests' + exe_postfix
  server_name = 'chromedriver' + exe_postfix

  required_build_outputs = [server_name]
  if not options.android_packages:
    required_build_outputs += [cpp_tests_name]
  try:
    build_dir = chrome_paths.GetBuildDir(required_build_outputs)
  except RuntimeError:
    util.MarkBuildStepStart('check required binaries')
    traceback.print_exc()
    util.MarkBuildStepError()
  constants.SetBuildType(os.path.basename(build_dir))
  print 'Using build outputs from', build_dir

  chromedriver = os.path.join(build_dir, server_name)
  platform_name = util.GetPlatformName()
  if util.IsLinux() and util.Is64Bit():
    platform_name += '64'
  ref_chromedriver = os.path.join(
      chrome_paths.GetSrc(),
      'chrome', 'test', 'chromedriver', 'third_party', 'java_tests',
      'reference_builds',
      'chromedriver_%s%s' % (platform_name, exe_postfix))

  if options.android_packages:
    os.environ['PATH'] += os.pathsep + os.path.join(
        _THIS_DIR, os.pardir, 'chrome')
    code = 0
    for package in options.android_packages.split(','):
      code1 = RunPythonTests(chromedriver,
                             ref_chromedriver,
                             chrome_version_name=package,
                             android_package=package)
      code2 = RunJavaTests(chromedriver,
                           chrome_version_name=package,
                           android_package=package,
                           verbose=True)
      code = code or code1 or code2
    return code
  else:
    code = 0
    download_site = archive.GetDownloadSite()
    revision = archive.GetLatestRevision()
    temp_dir, chrome_path = DownloadChrome(revision, revision,
                                             download_site)
    if not chrome_path:
      code = 1
    code1 = RunPythonTests(chromedriver,
                           ref_chromedriver,
                           chrome=chrome_path)
    code2 = RunJavaTests(chromedriver,
                         verbose=True,
                         chrome=chrome_path)
    code3 = RunReplayTests(chromedriver,
                           chrome=chrome_path)
    code = code or code1 or code2 or code3
    _KillChromes()
    shutil.rmtree(temp_dir)
    cpp_tests = os.path.join(build_dir, cpp_tests_name)
    return RunCppTests(cpp_tests) or code
示例#17
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-packages',
        help='Comma separated list of application package names, '
        'if running tests on Android.')
    # Option 'chrome-version' is for desktop only.
    parser.add_option(
        '',
        '--chrome-version',
        help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.'
        'Default is to run tests against all of these versions.'
        'Notice: this option only applies to desktop.')
    options, _ = parser.parse_args()

    exe_postfix = ''
    if util.IsWindows():
        exe_postfix = '.exe'
    cpp_tests_name = 'chromedriver_tests' + exe_postfix
    server_name = 'chromedriver' + exe_postfix

    required_build_outputs = [server_name]
    if not options.android_packages:
        required_build_outputs += [cpp_tests_name]
    try:
        build_dir = chrome_paths.GetBuildDir(required_build_outputs)
    except RuntimeError:
        util.MarkBuildStepStart('check required binaries')
        traceback.print_exc()
        util.MarkBuildStepError()
    constants.SetBuildType(os.path.basename(build_dir))
    print 'Using build outputs from', build_dir

    chromedriver = os.path.join(build_dir, server_name)
    platform_name = util.GetPlatformName()
    if util.IsLinux() and util.Is64Bit():
        platform_name += '64'
    ref_chromedriver = os.path.join(
        chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party',
        'java_tests', 'reference_builds',
        'chromedriver_%s%s' % (platform_name, exe_postfix))

    if options.android_packages:
        os.environ['PATH'] += os.pathsep + os.path.join(
            _THIS_DIR, os.pardir, 'chrome')
        code = 0
        for package in options.android_packages.split(','):
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome_version_name=package,
                                   android_package=package)
            code2 = RunJavaTests(chromedriver,
                                 chrome_version_name=package,
                                 android_package=package,
                                 verbose=True)
            code = code or code1 or code2
        return code
    else:
        versions = {'HEAD': archive.GetLatestRevision()}
        # Linux64 build numbers
        if util.IsLinux():
            versions['72'] = '612434'
            versions['71'] = '599034'
            versions['70'] = '587811'

        # Mac build numbers
        elif util.IsMac():
            versions['72'] = '612451'
            versions['71'] = '599028'
            versions['70'] = '587811'

        # Windows build numbers
        elif util.IsWindows():
            versions['72'] = '612432'
            versions['71'] = '598927'
            versions['70'] = '587814'

        code = 0
        for version, revision in versions.iteritems():
            if options.chrome_version and version != options.chrome_version:
                continue
            download_site = archive.GetDownloadSite()
            version_name = version
            if version_name == 'HEAD':
                version_name = revision
            temp_dir, chrome_path = DownloadChrome(version_name, revision,
                                                   download_site)
            if not chrome_path:
                code = 1
                continue
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome=chrome_path,
                                   chrome_version=version,
                                   chrome_version_name='v%s' % version_name)
            code2 = RunJavaTests(chromedriver,
                                 chrome=chrome_path,
                                 chrome_version=version,
                                 chrome_version_name='v%s' % version_name,
                                 verbose=True)
            code3 = RunReplayTests(chromedriver,
                                   chrome=chrome_path,
                                   chrome_version=version,
                                   chrome_version_name='v%s' % version_name)
            code = code or code1 or code2 or code3
            _KillChromes()
            shutil.rmtree(temp_dir)
        cpp_tests = os.path.join(build_dir, cpp_tests_name)
        return RunCppTests(cpp_tests) or code
示例#18
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-packages',
        help=('Comma separated list of application package names, '
              'if running tests on Android.'))
    parser.add_option('-r', '--revision', help='Chromium git revision hash')
    parser.add_option(
        '',
        '--update-log',
        action='store_true',
        help='Update the test results log (only applicable to Android)')
    options, _ = parser.parse_args()

    bitness = '32'
    if util.IsLinux() and platform_module.architecture()[0] == '64bit':
        bitness = '64'
    platform = '%s%s' % (util.GetPlatformName(), bitness)
    if options.android_packages:
        platform = 'android'

    _CleanTmpDir()

    # Make sure any subprocesses (i.e. chromedriver) create temp files under
    # $TMPDIR/chromedriver_*, so that they can be cleaned up by _CleanTempDir().
    if util.IsWindows():
        os.environ['TMP'] = os.environ['TEMP'] = util.MakeTempDir()
    else:
        os.environ['TMPDIR'] = util.MakeTempDir()

    if not options.revision:
        commit_position = None
    else:
        commit_position = _GetCommitPositionFromGitHash(options.revision)

    if platform == 'android':
        if not options.revision and options.update_log:
            parser.error('Must supply a --revision with --update-log')
        _DownloadPrebuilts()
    else:
        if not options.revision:
            parser.error('Must supply a --revision')
        if platform == 'linux64':
            _ArchivePrebuilts(commit_position)
        _WaitForLatestSnapshot(commit_position)

    _AddToolsToPath(platform)

    cmd = [
        sys.executable,
        os.path.join(_THIS_DIR, 'test', 'run_all_tests.py'),
    ]
    if platform == 'android':
        cmd.append('--android-packages=' + options.android_packages)

    passed = (util.RunCommand(cmd) == 0)

    _ArchiveServerLogs()

    if platform == 'android':
        if options.update_log:
            util.MarkBuildStepStart('update test result log')
            _UpdateTestResultsLog(platform, commit_position, passed)
    elif passed:
        _ArchiveGoodBuild(platform, commit_position)
        _MaybeRelease(platform)

    if not passed:
        # Make sure the build is red if there is some uncaught exception during
        # running run_all_tests.py.
        util.MarkBuildStepStart('run_all_tests.py')
        util.MarkBuildStepError()

    # Add a "cleanup" step so that errors from runtest.py or bb_device_steps.py
    # (which invoke this script) are kept in their own build step.
    util.MarkBuildStepStart('cleanup')
 def GetOS(self):
     return util.GetPlatformName()
示例#20
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-packages',
        help='Comma separated list of application package names, '
        'if running tests on Android.')
    # Option 'chrome-version' is for desktop only.
    parser.add_option(
        '',
        '--chrome-version',
        help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.'
        'Default is to run tests against all of these versions.'
        'Notice: this option only applies to desktop.')
    options, _ = parser.parse_args()

    exe_postfix = ''
    if util.IsWindows():
        exe_postfix = '.exe'
    cpp_tests_name = 'chromedriver_tests' + exe_postfix
    server_name = 'chromedriver' + exe_postfix

    required_build_outputs = [server_name]
    if not options.android_packages:
        required_build_outputs += [cpp_tests_name]
    try:
        build_dir = chrome_paths.GetBuildDir(required_build_outputs)
    except RuntimeError:
        util.MarkBuildStepStart('check required binaries')
        traceback.print_exc()
        util.MarkBuildStepError()
    constants.SetBuildType(os.path.basename(build_dir))
    print 'Using build outputs from', build_dir

    chromedriver = os.path.join(build_dir, server_name)
    platform_name = util.GetPlatformName()
    if util.IsLinux() and util.Is64Bit():
        platform_name += '64'
    ref_chromedriver = os.path.join(
        chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party',
        'java_tests', 'reference_builds',
        'chromedriver_%s%s' % (platform_name, exe_postfix))

    if options.android_packages:
        os.environ['PATH'] += os.pathsep + os.path.join(
            _THIS_DIR, os.pardir, 'chrome')
        code = 0
        for package in options.android_packages.split(','):
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome_version_name=package,
                                   android_package=package)
            code2 = RunJavaTests(chromedriver,
                                 chrome_version_name=package,
                                 android_package=package,
                                 verbose=True)
            code = code or code1 or code2
        return code
    else:
        versions = {'HEAD': archive.GetLatestRevision()}
        if util.IsLinux() and not util.Is64Bit():
            # Linux32 builds need to be special-cased, because 1) they are keyed by
            # git hash rather than commit position, and 2) come from a different
            # download site (so we can't just convert the commit position to a hash).
            versions['60'] = 'c1148176d6794fff0fd8dba2b9f7ed71ec52fed8'
            versions['59'] = 'c407e95a371a94bfd714e25eab788c9405de6975'
            versions['58'] = '7613176285d46fbc5b4712e42bd135aae99cbba5'
            # TODO(samuong): speculative fix for crbug.com/611886
            os.environ['CHROME_DEVEL_SANDBOX'] = '/opt/chromium/chrome_sandbox'
        else:
            versions['60'] = '474969'
            versions['59'] = '464674'
            versions['58'] = '454475'
        code = 0
        for version, revision in versions.iteritems():
            if options.chrome_version and version != options.chrome_version:
                continue
            download_site = archive.GetDownloadSite()
            version_name = version
            if version_name == 'HEAD':
                version_name = revision
            temp_dir, chrome_path = DownloadChrome(version_name, revision,
                                                   download_site)
            if not chrome_path:
                code = 1
                continue
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome=chrome_path,
                                   chrome_version=version,
                                   chrome_version_name='v%s' % version_name)
            code2 = RunJavaTests(chromedriver,
                                 chrome=chrome_path,
                                 chrome_version=version,
                                 chrome_version_name='v%s' % version_name)
            code = code or code1 or code2
            _KillChromes()
            shutil.rmtree(temp_dir)
        cpp_tests = os.path.join(build_dir, cpp_tests_name)
        return RunCppTests(cpp_tests) or code