Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
def RunFyiTests(options, webdriver_checkout):
    """Runs tests for the FYI buildbot configuration."""
    print '@@@BUILD_STEP java_continuous_tests@@@'
    revision = continuous_archive.GetLatestRevision()
    print '@@@STEP_TEXT@r%s@@@' % revision
    temp_dir = util.MakeTempDir()

    chrome_path = continuous_archive.DownloadChrome(revision, temp_dir)
    chromedriver_path = continuous_archive.DownloadChromeDriver(
        revision, temp_dir)

    PrintTestResults(
        java_tests.Run(test_target=java_tests.CHROME_TESTS,
                       test_filter=options.filter,
                       webdriver_dir=webdriver_checkout,
                       chromedriver_path=chromedriver_path,
                       chrome_path=chrome_path))

    print '@@@BUILD_STEP java_stable_tests@@@'
    print '@@@STEP_TEXT@chromedriver r%s@@@' % revision
    PrintTestResults(
        java_tests.Run(test_target=java_tests.CHROME_TESTS,
                       test_filter=options.filter,
                       webdriver_dir=webdriver_checkout,
                       chromedriver_path=chromedriver_path,
                       chrome_path=None))
def _Run(java_tests_src_dir, test_filter,
         chromedriver_path, chrome_path, android_package,
         verbose, debug):
  """Run the WebDriver Java tests and return the test results.

  Args:
    java_tests_src_dir: the java test source code directory.
    test_filter: the filter to use when choosing tests to run. Format is same
        as Google C++ Test format.
    chromedriver_path: path to ChromeDriver exe.
    chrome_path: path to Chrome exe.
    android_package: name of Chrome's Android package.
    verbose: whether the output should be verbose.
    debug: whether the tests should wait until attached by a debugger.

  Returns:
    A list of |TestResult|s.
  """
  test_dir = util.MakeTempDir()
  keystore_path = ('java', 'client', 'test', 'keystore')
  required_dirs = [keystore_path[:-1],
                   ('javascript',),
                   ('third_party', 'closure', 'goog'),
                   ('third_party', 'js')]
  for required_dir in required_dirs:
    os.makedirs(os.path.join(test_dir, *required_dir))

  test_jar = 'test-standalone.jar'
  class_path = test_jar
  shutil.copyfile(os.path.join(java_tests_src_dir, 'keystore'),
                  os.path.join(test_dir, *keystore_path))
  util.Unzip(os.path.join(java_tests_src_dir, 'common.zip'), test_dir)
  shutil.copyfile(os.path.join(java_tests_src_dir, test_jar),
                  os.path.join(test_dir, test_jar))

  sys_props = ['selenium.browser=chrome',
               'webdriver.chrome.driver=' + os.path.abspath(chromedriver_path)]
  if chrome_path is not None:
    sys_props += ['webdriver.chrome.binary=' + os.path.abspath(chrome_path)]
  if android_package is not None:
    sys_props += ['webdriver.chrome.android_package=' + android_package]
  if test_filter:
    # Test jar actually takes a regex. Convert from glob.
    test_filter = test_filter.replace('*', '.*')
    sys_props += ['filter=' + test_filter]

  jvm_args = []
  if debug:
    jvm_args += ['-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,'
                 'address=33081']
    # Unpack the sources into the test directory and add to the class path
    # for ease of debugging, particularly with jdb.
    util.Unzip(os.path.join(java_tests_src_dir, 'test-nodeps-srcs.jar'),
               test_dir)
    class_path += ':' + test_dir

  return _RunAntTest(
      test_dir, 'org.openqa.selenium.chrome.ChromeDriverTests',
      class_path, sys_props, jvm_args, verbose)
Ejemplo n.º 4
0
def _PutTestResultsLog(platform, test_results_log):
  """Pushes the given test results log to google storage."""
  temp_dir = util.MakeTempDir()
  log_name = TEST_LOG_FORMAT % platform
  log_path = os.path.join(temp_dir, log_name)
  with open(log_path, 'wb') as log_file:
    json.dump(test_results_log, log_file)
  if slave_utils.GSUtilCopyFile(log_path, GS_CHROMEDRIVER_DATA_BUCKET):
    raise Exception('Failed to upload test results log to google storage')
Ejemplo n.º 5
0
def _DownloadPrebuilts():
  """Downloads the most recent prebuilts from google storage."""
  util.MarkBuildStepStart('Download latest chromedriver')

  zip_path = os.path.join(util.MakeTempDir(), 'build.zip')
  if gsutil_download.DownloadLatestFile(GS_PREBUILTS_URL, 'r', zip_path):
    util.MarkBuildStepError()

  util.Unzip(zip_path, chrome_paths.GetBuildDir(['host_forwarder']))
Ejemplo n.º 6
0
def DownloadChrome(version_name, revision, download_site):
  util.MarkBuildStepStart('download %s' % version_name)
  try:
    temp_dir = util.MakeTempDir()
    return (temp_dir, archive.DownloadChrome(revision, temp_dir, download_site))
  except Exception:
    traceback.print_exc()
    util.AddBuildStepText('Skip Java and Python tests')
    util.MarkBuildStepError()
    return (None, None)
Ejemplo n.º 7
0
def _GetFirstBuildAfterBranch(branch_position):
    latest_revision = GetLatestSnapshotPosition()
    for commit_position in range(int(branch_position), int(latest_revision)):
        git_hash = _GetGitHashFromCommitPosition(commit_position)
        try:
            _ = DownloadChrome(git_hash, util.MakeTempDir(), GetDownloadSite())
            return git_hash
        except:
            continue
    return None
Ejemplo n.º 8
0
 def testConnectToRemoteBrowser(self):
   port = self.FindFreePort()
   temp_dir = util.MakeTempDir()
   process = subprocess.Popen([_CHROME_BINARY,
                               '--remote-debugging-port=%d' % port,
                               '--user-data-dir=%s' % temp_dir])
   if process is None:
     raise RuntimeError('Chrome could not be started with debugging port')
   try:
     driver = self.CreateDriver(debugger_address='127.0.0.1:%d' % port)
     driver.ExecuteScript('console.info("%s")' % 'connecting at %d!' % port)
     driver.Quit()
   finally:
     process.terminate()
Ejemplo n.º 9
0
def Run(src_dir, test_filter, chromedriver_path, chrome_path):
  """Run the WebDriver Java tests and return the test results.

  Args:
    src_dir: the chromium source checkout directory.
    test_filter: the filter to use when choosing tests to run. Format is
        ClassName#testMethod.
    chromedriver_path: path to ChromeDriver exe.
    chrome_path: path to Chrome exe.

  Returns:
    A list of |TestResult|s.
  """
  test_dir = util.MakeTempDir()
  keystore_path = ('java', 'client', 'test', 'keystore')
  required_dirs = [keystore_path[:-1],
                   ('javascript',),
                   ('third_party', 'closure', 'goog')]
  for required_dir in required_dirs:
    os.makedirs(os.path.join(test_dir, *required_dir))

  test_jar = 'test-standalone.jar'
  java_tests_src_dir = os.path.join(
      src_dir, 'third_party', 'webdriver', 'java_tests')
  shutil.copyfile(os.path.join(java_tests_src_dir, 'keystore'),
                  os.path.join(test_dir, *keystore_path))
  shutil.copytree(os.path.join(java_tests_src_dir, 'common'),
                  os.path.join(test_dir, 'common'))
  shutil.copyfile(os.path.join(java_tests_src_dir, test_jar),
                  os.path.join(test_dir, test_jar))

  sys_props = ['selenium.browser=chrome',
               'webdriver.chrome.driver=' + chromedriver_path]
  if chrome_path is not None:
    sys_props += ['webdriver.chrome.binary=' + chrome_path]
  if test_filter is not None:
    parts = test_filter.split('#')
    if len(parts) > 2:
      raise RuntimeError('Filter should be of form: SomeClass#testMethod')
    elif len(parts) == 2:
      sys_props += ['method=' + parts[1]]
    if len(parts[0]) > 0:
      sys_props += ['only_run=' + parts[0]]

  return _RunAntTest(
      test_dir, 'org.openqa.selenium.chrome.ChromeDriverTests',
      test_jar, sys_props)
Ejemplo n.º 10
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--filter',
        type='string',
        default=None,
        help=
        'Filter for specifying what tests to run. E.g., MyClass#testMethod.')
    options, args = parser.parse_args()

    if 'WEBDRIVER_CHECKOUT' not in os.environ:
        raise RuntimeError(
            'WEBDRIVER_CHECKOUT must be defined in the environment')
    webdriver_checkout = os.environ['WEBDRIVER_CHECKOUT']

    print '@@@BUILD_STEP java_continuous_tests@@@'
    # We use the latest revision in the continuous archive instead of the
    # extracted build for two reasons:
    # 1) Builds are only archived if they have passed some set of tests. This
    #    results in less false failures.
    # 2) I don't want to add chromedriver to the chromium_builder_tests target in
    #    all.gyp, since that will probably add a minute or so to every build.
    revision = continuous_archive.GetLatestRevision()
    print '@@@STEP_TEXT@r%s@@@' % revision
    temp_dir = util.MakeTempDir()

    chrome_path = continuous_archive.DownloadChrome(revision, temp_dir)
    chromedriver_path = continuous_archive.DownloadChromeDriver(
        revision, temp_dir)

    PrintTestResults(
        java_tests.Run(test_target=java_tests.CHROME_TESTS,
                       test_filter=options.filter,
                       webdriver_dir=webdriver_checkout,
                       chromedriver_path=chromedriver_path,
                       chrome_path=chrome_path))

    print '@@@BUILD_STEP java_stable_tests@@@'
    print '@@@STEP_TEXT@chromedriver r%s@@@' % revision
    PrintTestResults(
        java_tests.Run(test_target=java_tests.CHROME_TESTS,
                       test_filter=options.filter,
                       webdriver_dir=webdriver_checkout,
                       chromedriver_path=chromedriver_path,
                       chrome_path=None))
Ejemplo n.º 11
0
def _Release(build, version, platform):
  """Releases the given candidate build."""
  release_name = 'chromedriver_%s.zip' % platform
  util.MarkBuildStepStart('releasing %s' % release_name)
  temp_dir = util.MakeTempDir()
  slave_utils.GSUtilCopy(build, temp_dir)
  zip_path = os.path.join(temp_dir, os.path.basename(build))

  if util.IsLinux():
    util.Unzip(zip_path, temp_dir)
    server_path = os.path.join(temp_dir, 'chromedriver')
    util.RunCommand(['strip', server_path])
    zip_path = util.Zip(server_path)

  slave_utils.GSUtilCopy(
      zip_path, '%s/%s/%s' % (GS_CHROMEDRIVER_BUCKET, version, release_name))

  _MaybeUpdateLatestRelease(version)
Ejemplo n.º 12
0
def Download():
    util.MarkBuildStepStart('Download chromedriver prebuilts')

    temp_dir = util.MakeTempDir()
    zip_path = os.path.join(temp_dir, 'chromedriver2_prebuilts.zip')
    cmd = [
        sys.executable, DOWNLOAD_SCRIPT,
        '--url=%s' % GS_BUCKET,
        '--partial-name=%s' % GS_ZIP_PREFIX,
        '--dst=%s' % zip_path
    ]
    if util.RunCommand(cmd):
        util.MarkBuildStepError()

    build_dir = chrome_paths.GetBuildDir(['host_forwarder'])
    print 'Unzipping prebuilts %s to %s' % (zip_path, build_dir)
    f = zipfile.ZipFile(zip_path, 'r')
    f.extractall(build_dir)
    f.close()
    # Workaround for Python bug: http://bugs.python.org/issue15795
    os.chmod(os.path.join(build_dir, 'chromedriver2_server'), 0700)
Ejemplo n.º 13
0
def Archive(revision):
  util.MarkBuildStepStart('archive')
  prebuilts = ['chromedriver2_server',
               'chromedriver2_unittests', 'chromedriver2_tests']
  build_dir = chrome_paths.GetBuildDir(prebuilts[0:1])
  zip_name = '%s_r%s.zip' % (GS_ZIP_PREFIX, revision)
  temp_dir = util.MakeTempDir()
  zip_path = os.path.join(temp_dir, zip_name)
  print 'Zipping prebuilts %s' % zip_path
  f = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED)
  for prebuilt in prebuilts:
    f.write(os.path.join(build_dir, prebuilt), prebuilt)
  f.close()

  cmd = [
      sys.executable,
      UPLOAD_SCRIPT,
      '--source_filepath=%s' % zip_path,
      '--dest_gsbase=%s' % GS_BUCKET
  ]
  if util.RunCommand(cmd):
    util.MarkBuildStepError()
Ejemplo n.º 14
0
def main():
    parser = optparse.OptionParser()
    parser.add_option('',
                      '--filter',
                      type='string',
                      default=None,
                      help='Filter for specifying what tests to run. E.g., ' +
                      'ElementFindingTest#testShouldReturnTitleOfPageIfSet.')
    options, args = parser.parse_args()

    print '@@@BUILD_STEP java_continuous_tests@@@'
    # We use the latest revision in the continuous archive instead of the
    # extracted build for two reasons:
    # 1) Builds are only archived if they have passed some set of tests. This
    #    results in less false failures.
    # 2) I don't want to add chromedriver to the chromium_builder_tests target in
    #    all.gyp, since that will probably add a minute or so to every build.
    revision = continuous_archive.GetLatestRevision()
    print '@@@STEP_TEXT@r%s@@@' % revision
    temp_dir = util.MakeTempDir()

    chrome_path = continuous_archive.DownloadChrome(revision, temp_dir)
    chromedriver_path = continuous_archive.DownloadChromeDriver(
        revision, temp_dir)

    PrintTestResults(
        java_tests.Run(src_dir=test_paths.SRC_PATH,
                       test_filter=options.filter,
                       chromedriver_path=chromedriver_path,
                       chrome_path=chrome_path))

    print '@@@BUILD_STEP java_stable_tests@@@'
    print '@@@STEP_TEXT@chromedriver r%s@@@' % revision
    PrintTestResults(
        java_tests.Run(src_dir=test_paths.SRC_PATH,
                       test_filter=options.filter,
                       chromedriver_path=chromedriver_path,
                       chrome_path=None))
Ejemplo n.º 15
0
def DownloadChrome(version_name, revision, download_site):
  util.MarkBuildStepStart('download %s' % version_name)
  return archive.DownloadChrome(revision, util.MakeTempDir(), download_site)
Ejemplo n.º 16
0
def _Run(java_tests_src_dir, test_filter, chromedriver_path, chrome_path,
         log_path, android_package_key, verbose, debug):
    """Run the WebDriver Java tests and return the test results.

  Args:
    java_tests_src_dir: the java test source code directory.
    test_filter: the filter to use when choosing tests to run. Format is same
        as Google C++ Test format.
    chromedriver_path: path to ChromeDriver exe.
    chrome_path: path to Chrome exe.
    log_path: path to server log.
    android_package_key: name of Chrome's Android package.
    verbose: whether the output should be verbose.
    debug: whether the tests should wait until attached by a debugger.

  Returns:
    A list of |TestResult|s.
  """
    test_dir = util.MakeTempDir()
    keystore_path = ('java', 'client', 'test', 'keystore')
    required_dirs = [
        keystore_path[:-1], ('javascript', ),
        ('third_party', 'closure', 'goog'), ('third_party', 'js')
    ]
    for required_dir in required_dirs:
        os.makedirs(os.path.join(test_dir, *required_dir))

    test_jar = 'test-standalone.jar'
    class_path = test_jar
    shutil.copyfile(os.path.join(java_tests_src_dir, 'keystore'),
                    os.path.join(test_dir, *keystore_path))
    util.Unzip(os.path.join(java_tests_src_dir, 'common.zip'), test_dir)
    shutil.copyfile(os.path.join(java_tests_src_dir, test_jar),
                    os.path.join(test_dir, test_jar))

    sys_props = [
        'selenium.browser=chrome',
        'webdriver.chrome.driver=' + os.path.abspath(chromedriver_path)
    ]
    if chrome_path:
        if util.IsLinux() and android_package_key is None:
            # Workaround for crbug.com/611886 and
            # https://bugs.chromium.org/p/chromedriver/issues/detail?id=1695
            chrome_wrapper_path = os.path.join(test_dir,
                                               'chrome-wrapper-no-sandbox')
            with open(chrome_wrapper_path, 'w') as f:
                f.write('#!/bin/sh\n')
                f.write('exec %s --no-sandbox --disable-gpu "$@"\n' %
                        os.path.abspath(chrome_path))
            st = os.stat(chrome_wrapper_path)
            os.chmod(chrome_wrapper_path, st.st_mode | stat.S_IEXEC)
        else:
            chrome_wrapper_path = os.path.abspath(chrome_path)
        sys_props += ['webdriver.chrome.binary=' + chrome_wrapper_path]
    if log_path:
        sys_props += ['webdriver.chrome.logfile=' + log_path]
    if android_package_key:
        android_package = constants.PACKAGE_INFO[android_package_key].package
        sys_props += ['webdriver.chrome.android_package=' + android_package]
        if android_package_key == 'chromedriver_webview_shell':
            android_activity = constants.PACKAGE_INFO[
                android_package_key].activity
            android_process = '%s:main' % android_package
            sys_props += [
                'webdriver.chrome.android_activity=' + android_activity
            ]
            sys_props += [
                'webdriver.chrome.android_process=' + android_process
            ]
    if test_filter:
        # Test jar actually takes a regex. Convert from glob.
        test_filter = test_filter.replace('*', '.*')
        sys_props += ['filter=' + test_filter]

    jvm_args = []
    if debug:
        transport = 'dt_socket'
        if util.IsWindows():
            transport = 'dt_shmem'
        jvm_args += [
            '-agentlib:jdwp=transport=%s,server=y,suspend=y,'
            'address=33081' % transport
        ]
        # Unpack the sources into the test directory and add to the class path
        # for ease of debugging, particularly with jdb.
        util.Unzip(os.path.join(java_tests_src_dir, 'test-nodeps-srcs.jar'),
                   test_dir)
        class_path += ':' + test_dir

    return _RunAntTest(test_dir,
                       'org.openqa.selenium.chrome.ChromeDriverTests',
                       class_path, sys_props, jvm_args, verbose)
Ejemplo n.º 17
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
Ejemplo n.º 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 = archive.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')