[email protected] | cb155a8 | 2011-11-29 17:25:34 | [diff] [blame] | 1 | #!/usr/bin/env python |
[email protected] | 5e93cf16 | 2012-01-28 02:16:56 | [diff] [blame] | 2 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | """Snapshot Build Bisect Tool |
| 7 | |
[email protected] | 7ad66a7 | 2009-09-04 17:52:33 | [diff] [blame] | 8 | This script bisects a snapshot archive using binary search. It starts at |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 9 | a bad revision (it will try to guess HEAD) and asks for a last known-good |
| 10 | revision. It will then binary search across this revision range by downloading, |
| 11 | unzipping, and opening Chromium for you. After testing the specific revision, |
| 12 | it will ask you whether it is good or bad before continuing the search. |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 13 | """ |
| 14 | |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 15 | from __future__ import print_function |
| 16 | |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 17 | # The base URL for stored build archives. |
| 18 | CHROMIUM_BASE_URL = ('http://commondatastorage.googleapis.com' |
| 19 | '/chromium-browser-snapshots') |
| 20 | WEBKIT_BASE_URL = ('http://commondatastorage.googleapis.com' |
| 21 | '/chromium-webkit-snapshots') |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 22 | ASAN_BASE_URL = ('http://commondatastorage.googleapis.com' |
| 23 | '/chromium-browser-asan') |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 24 | |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 25 | # URL template for viewing changelogs between revisions. |
pshenoy | 9ce271f | 2014-09-02 22:14:05 | [diff] [blame] | 26 | CHANGELOG_URL = ('https://chromium.googlesource.com/chromium/src/+log/%s..%s') |
| 27 | |
| 28 | # URL to convert SVN revision to git hash. |
pshenoy | 13cb79e0 | 2014-09-05 01:42:53 | [diff] [blame] | 29 | CRREV_URL = ('https://cr-rev.appspot.com/_ah/api/crrev/v1/redirect/') |
[email protected] | f6a71a7 | 2009-10-08 19:55:38 | [diff] [blame] | 30 | |
[email protected] | b2fe7f2 | 2011-10-25 22:58:31 | [diff] [blame] | 31 | # DEPS file URL. |
Di Mu | 08c5968 | 2016-07-11 23:05:07 | [diff] [blame] | 32 | DEPS_FILE = ('https://chromium.googlesource.com/chromium/src/+/%s/DEPS') |
[email protected] | b2fe7f2 | 2011-10-25 22:58:31 | [diff] [blame] | 33 | |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 34 | # Blink changelogs URL. |
| 35 | BLINK_CHANGELOG_URL = ('http://build.chromium.org' |
| 36 | '/f/chromium/perf/dashboard/ui/changelog_blink.html' |
| 37 | '?url=/trunk&range=%d%%3A%d') |
| 38 | |
| 39 | DONE_MESSAGE_GOOD_MIN = ('You are probably looking for a change made after %s (' |
| 40 | 'known good), but no later than %s (first known bad).') |
| 41 | DONE_MESSAGE_GOOD_MAX = ('You are probably looking for a change made after %s (' |
| 42 | 'known bad), but no later than %s (first known good).') |
[email protected] | 05ff3fd | 2012-04-17 23:24:06 | [diff] [blame] | 43 | |
[email protected] | 3e7c8532 | 2014-06-27 20:27:36 | [diff] [blame] | 44 | CHROMIUM_GITHASH_TO_SVN_URL = ( |
| 45 | 'https://chromium.googlesource.com/chromium/src/+/%s?format=json') |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 46 | |
[email protected] | 3e7c8532 | 2014-06-27 20:27:36 | [diff] [blame] | 47 | BLINK_GITHASH_TO_SVN_URL = ( |
| 48 | 'https://chromium.googlesource.com/chromium/blink/+/%s?format=json') |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 49 | |
| 50 | GITHASH_TO_SVN_URL = { |
| 51 | 'chromium': CHROMIUM_GITHASH_TO_SVN_URL, |
| 52 | 'blink': BLINK_GITHASH_TO_SVN_URL, |
| 53 | } |
| 54 | |
| 55 | # Search pattern to be matched in the JSON output from |
[email protected] | 3e7c8532 | 2014-06-27 20:27:36 | [diff] [blame] | 56 | # CHROMIUM_GITHASH_TO_SVN_URL to get the chromium revision (svn revision). |
pshenoy | b23a145 | 2014-09-05 22:52:05 | [diff] [blame] | 57 | CHROMIUM_SEARCH_PATTERN_OLD = ( |
[email protected] | 3e7c8532 | 2014-06-27 20:27:36 | [diff] [blame] | 58 | r'.*git-svn-id: svn://svn.chromium.org/chrome/trunk/src@(\d+) ') |
pshenoy | b23a145 | 2014-09-05 22:52:05 | [diff] [blame] | 59 | CHROMIUM_SEARCH_PATTERN = ( |
| 60 | r'Cr-Commit-Position: refs/heads/master@{#(\d+)}') |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 61 | |
[email protected] | 3e7c8532 | 2014-06-27 20:27:36 | [diff] [blame] | 62 | # Search pattern to be matched in the json output from |
| 63 | # BLINK_GITHASH_TO_SVN_URL to get the blink revision (svn revision). |
| 64 | BLINK_SEARCH_PATTERN = ( |
| 65 | r'.*git-svn-id: svn://svn.chromium.org/blink/trunk@(\d+) ') |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 66 | |
| 67 | SEARCH_PATTERN = { |
| 68 | 'chromium': CHROMIUM_SEARCH_PATTERN, |
| 69 | 'blink': BLINK_SEARCH_PATTERN, |
| 70 | } |
[email protected] | 3e7c8532 | 2014-06-27 20:27:36 | [diff] [blame] | 71 | |
[email protected] | 48036978 | 2014-08-22 20:15:58 | [diff] [blame] | 72 | CREDENTIAL_ERROR_MESSAGE = ('You are attempting to access protected data with ' |
| 73 | 'no configured credentials') |
| 74 | |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 75 | ############################################################################### |
| 76 | |
Dominic Mazzoni | 215e80b | 2017-11-29 20:05:27 | [diff] [blame] | 77 | import glob |
[email protected] | 8304850 | 2014-08-21 16:48:44 | [diff] [blame] | 78 | import httplib |
[email protected] | 4c6fec6b | 2013-09-17 17:44:08 | [diff] [blame] | 79 | import json |
[email protected] | 7ad66a7 | 2009-09-04 17:52:33 | [diff] [blame] | 80 | import optparse |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 81 | import os |
| 82 | import re |
[email protected] | 61ea90a | 2013-09-26 10:17:34 | [diff] [blame] | 83 | import shlex |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 84 | import shutil |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 85 | import subprocess |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 86 | import sys |
[email protected] | 7ad66a7 | 2009-09-04 17:52:33 | [diff] [blame] | 87 | import tempfile |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 88 | import threading |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 89 | import urllib |
[email protected] | d0149c5c | 2012-05-29 21:12:11 | [diff] [blame] | 90 | from distutils.version import LooseVersion |
[email protected] | 183706d9 | 2011-06-10 13:06:22 | [diff] [blame] | 91 | from xml.etree import ElementTree |
[email protected] | bd8dcb9 | 2010-03-31 01:05:24 | [diff] [blame] | 92 | import zipfile |
| 93 | |
[email protected] | cb155a8 | 2011-11-29 17:25:34 | [diff] [blame] | 94 | |
[email protected] | 183706d9 | 2011-06-10 13:06:22 | [diff] [blame] | 95 | class PathContext(object): |
| 96 | """A PathContext is used to carry the information used to construct URLs and |
| 97 | paths when dealing with the storage server and archives.""" |
[email protected] | 4c6fec6b | 2013-09-17 17:44:08 | [diff] [blame] | 98 | def __init__(self, base_url, platform, good_revision, bad_revision, |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 99 | is_asan, use_local_cache, flash_path = None): |
[email protected] | 183706d9 | 2011-06-10 13:06:22 | [diff] [blame] | 100 | super(PathContext, self).__init__() |
| 101 | # Store off the input parameters. |
[email protected] | 4c6fec6b | 2013-09-17 17:44:08 | [diff] [blame] | 102 | self.base_url = base_url |
[email protected] | 183706d9 | 2011-06-10 13:06:22 | [diff] [blame] | 103 | self.platform = platform # What's passed in to the '-a/--archive' option. |
| 104 | self.good_revision = good_revision |
| 105 | self.bad_revision = bad_revision |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 106 | self.is_asan = is_asan |
| 107 | self.build_type = 'release' |
[email protected] | fc3702e | 2013-11-09 04:23:00 | [diff] [blame] | 108 | self.flash_path = flash_path |
[email protected] | 3e7c8532 | 2014-06-27 20:27:36 | [diff] [blame] | 109 | # Dictionary which stores svn revision number as key and it's |
| 110 | # corresponding git hash as value. This data is populated in |
| 111 | # _FetchAndParse and used later in GetDownloadURL while downloading |
| 112 | # the build. |
| 113 | self.githash_svn_dict = {} |
[email protected] | 183706d9 | 2011-06-10 13:06:22 | [diff] [blame] | 114 | # The name of the ZIP file in a revision directory on the server. |
| 115 | self.archive_name = None |
| 116 | |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 117 | # Whether to cache and use the list of known revisions in a local file to |
| 118 | # speed up the initialization of the script at the next run. |
| 119 | self.use_local_cache = use_local_cache |
| 120 | |
| 121 | # Locate the local checkout to speed up the script by using locally stored |
| 122 | # metadata. |
| 123 | abs_file_path = os.path.abspath(os.path.realpath(__file__)) |
| 124 | local_src_path = os.path.join(os.path.dirname(abs_file_path), '..') |
| 125 | if abs_file_path.endswith(os.path.join('tools', 'bisect-builds.py')) and\ |
| 126 | os.path.exists(os.path.join(local_src_path, '.git')): |
| 127 | self.local_src_path = os.path.normpath(local_src_path) |
| 128 | else: |
| 129 | self.local_src_path = None |
[email protected] | 6a7a5d6 | 2014-07-09 04:45:50 | [diff] [blame] | 130 | |
[email protected] | 183706d9 | 2011-06-10 13:06:22 | [diff] [blame] | 131 | # Set some internal members: |
| 132 | # _listing_platform_dir = Directory that holds revisions. Ends with a '/'. |
| 133 | # _archive_extract_dir = Uncompressed directory in the archive_name file. |
| 134 | # _binary_name = The name of the executable to run. |
dmazzoni | 76e907d | 2015-01-22 08:14:49 | [diff] [blame] | 135 | if self.platform in ('linux', 'linux64', 'linux-arm', 'chromeos'): |
[email protected] | 183706d9 | 2011-06-10 13:06:22 | [diff] [blame] | 136 | self._binary_name = 'chrome' |
[email protected] | 48036978 | 2014-08-22 20:15:58 | [diff] [blame] | 137 | elif self.platform in ('mac', 'mac64'): |
[email protected] | 183706d9 | 2011-06-10 13:06:22 | [diff] [blame] | 138 | self.archive_name = 'chrome-mac.zip' |
| 139 | self._archive_extract_dir = 'chrome-mac' |
[email protected] | 48036978 | 2014-08-22 20:15:58 | [diff] [blame] | 140 | elif self.platform in ('win', 'win64'): |
Dominic Mazzoni | e84e40b | 2018-10-08 06:44:45 | [diff] [blame] | 141 | # Note: changed at revision 591483; see GetDownloadURL and GetLaunchPath |
| 142 | # below where these are patched. |
[email protected] | 183706d9 | 2011-06-10 13:06:22 | [diff] [blame] | 143 | self.archive_name = 'chrome-win32.zip' |
| 144 | self._archive_extract_dir = 'chrome-win32' |
| 145 | self._binary_name = 'chrome.exe' |
| 146 | else: |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 147 | raise Exception('Invalid platform: %s' % self.platform) |
[email protected] | 183706d9 | 2011-06-10 13:06:22 | [diff] [blame] | 148 | |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 149 | if self.platform in ('linux', 'linux64', 'linux-arm', 'chromeos'): |
Dominic Mazzoni | e84e40b | 2018-10-08 06:44:45 | [diff] [blame] | 150 | # Note: changed at revision 591483; see GetDownloadURL and GetLaunchPath |
| 151 | # below where these are patched. |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 152 | self.archive_name = 'chrome-linux.zip' |
| 153 | self._archive_extract_dir = 'chrome-linux' |
[email protected] | d0149c5c | 2012-05-29 21:12:11 | [diff] [blame] | 154 | if self.platform == 'linux': |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 155 | self._listing_platform_dir = 'Linux/' |
[email protected] | d0149c5c | 2012-05-29 21:12:11 | [diff] [blame] | 156 | elif self.platform == 'linux64': |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 157 | self._listing_platform_dir = 'Linux_x64/' |
| 158 | elif self.platform == 'linux-arm': |
| 159 | self._listing_platform_dir = 'Linux_ARM_Cross-Compile/' |
| 160 | elif self.platform == 'chromeos': |
| 161 | self._listing_platform_dir = 'Linux_ChromiumOS_Full/' |
| 162 | elif self.platform in ('mac', 'mac64'): |
| 163 | self._listing_platform_dir = 'Mac/' |
| 164 | self._binary_name = 'Chromium.app/Contents/MacOS/Chromium' |
| 165 | elif self.platform == 'win': |
| 166 | self._listing_platform_dir = 'Win/' |
jiawei.shao | 734efbc9 | 2016-09-23 02:11:45 | [diff] [blame] | 167 | elif self.platform == 'win64': |
| 168 | self._listing_platform_dir = 'Win_x64/' |
[email protected] | d0149c5c | 2012-05-29 21:12:11 | [diff] [blame] | 169 | |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 170 | def GetASANPlatformDir(self): |
| 171 | """ASAN builds are in directories like "linux-release", or have filenames |
| 172 | like "asan-win32-release-277079.zip". This aligns to our platform names |
| 173 | except in the case of Windows where they use "win32" instead of "win".""" |
| 174 | if self.platform == 'win': |
| 175 | return 'win32' |
| 176 | else: |
| 177 | return self.platform |
| 178 | |
[email protected] | 183706d9 | 2011-06-10 13:06:22 | [diff] [blame] | 179 | def GetListingURL(self, marker=None): |
| 180 | """Returns the URL for a directory listing, with an optional marker.""" |
| 181 | marker_param = '' |
| 182 | if marker: |
| 183 | marker_param = '&marker=' + str(marker) |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 184 | if self.is_asan: |
| 185 | prefix = '%s-%s' % (self.GetASANPlatformDir(), self.build_type) |
| 186 | return self.base_url + '/?delimiter=&prefix=' + prefix + marker_param |
| 187 | else: |
| 188 | return (self.base_url + '/?delimiter=/&prefix=' + |
| 189 | self._listing_platform_dir + marker_param) |
[email protected] | 183706d9 | 2011-06-10 13:06:22 | [diff] [blame] | 190 | |
| 191 | def GetDownloadURL(self, revision): |
| 192 | """Gets the download URL for a build archive of a specific revision.""" |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 193 | if self.is_asan: |
| 194 | return '%s/%s-%s/%s-%d.zip' % ( |
| 195 | ASAN_BASE_URL, self.GetASANPlatformDir(), self.build_type, |
| 196 | self.GetASANBaseName(), revision) |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 197 | if str(revision) in self.githash_svn_dict: |
| 198 | revision = self.githash_svn_dict[str(revision)] |
Dominic Mazzoni | e84e40b | 2018-10-08 06:44:45 | [diff] [blame] | 199 | archive_name = self.archive_name |
| 200 | |
| 201 | # At revision 591483, the names of two of the archives changed |
| 202 | # due to: https://chromium-review.googlesource.com/#/q/1226086 |
| 203 | # See: http://crbug.com/789612 |
| 204 | if revision >= 591483: |
| 205 | if self.platform == 'chromeos': |
| 206 | archive_name = 'chrome-chromeos.zip' |
| 207 | elif self.platform in ('win', 'win64'): |
| 208 | archive_name = 'chrome-win.zip' |
| 209 | |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 210 | return '%s/%s%s/%s' % (self.base_url, self._listing_platform_dir, |
Dominic Mazzoni | e84e40b | 2018-10-08 06:44:45 | [diff] [blame] | 211 | revision, archive_name) |
[email protected] | 183706d9 | 2011-06-10 13:06:22 | [diff] [blame] | 212 | |
| 213 | def GetLastChangeURL(self): |
| 214 | """Returns a URL to the LAST_CHANGE file.""" |
[email protected] | 4c6fec6b | 2013-09-17 17:44:08 | [diff] [blame] | 215 | return self.base_url + '/' + self._listing_platform_dir + 'LAST_CHANGE' |
[email protected] | 183706d9 | 2011-06-10 13:06:22 | [diff] [blame] | 216 | |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 217 | def GetASANBaseName(self): |
| 218 | """Returns the base name of the ASAN zip file.""" |
| 219 | if 'linux' in self.platform: |
| 220 | return 'asan-symbolized-%s-%s' % (self.GetASANPlatformDir(), |
| 221 | self.build_type) |
| 222 | else: |
| 223 | return 'asan-%s-%s' % (self.GetASANPlatformDir(), self.build_type) |
| 224 | |
| 225 | def GetLaunchPath(self, revision): |
[email protected] | 183706d9 | 2011-06-10 13:06:22 | [diff] [blame] | 226 | """Returns a relative path (presumably from the archive extraction location) |
| 227 | that is used to run the executable.""" |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 228 | if self.is_asan: |
| 229 | extract_dir = '%s-%d' % (self.GetASANBaseName(), revision) |
| 230 | else: |
| 231 | extract_dir = self._archive_extract_dir |
Dominic Mazzoni | e84e40b | 2018-10-08 06:44:45 | [diff] [blame] | 232 | |
| 233 | # At revision 591483, the names of two of the archives changed |
| 234 | # due to: https://chromium-review.googlesource.com/#/q/1226086 |
| 235 | # See: http://crbug.com/789612 |
| 236 | if revision >= 591483: |
| 237 | if self.platform == 'chromeos': |
| 238 | extract_dir = 'chrome-chromeos' |
| 239 | elif self.platform in ('win', 'win64'): |
Lei Zhang | 1c8c6f7e | 2018-11-09 16:46:30 | [diff] [blame] | 240 | extract_dir = 'chrome-win' |
Dominic Mazzoni | e84e40b | 2018-10-08 06:44:45 | [diff] [blame] | 241 | |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 242 | return os.path.join(extract_dir, self._binary_name) |
[email protected] | 183706d9 | 2011-06-10 13:06:22 | [diff] [blame] | 243 | |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 244 | def ParseDirectoryIndex(self, last_known_rev): |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 245 | """Parses the Google Storage directory listing into a list of revision |
[email protected] | eadd95d | 2012-11-02 22:42:09 | [diff] [blame] | 246 | numbers.""" |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 247 | |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 248 | def _GetMarkerForRev(revision): |
| 249 | if self.is_asan: |
| 250 | return '%s-%s/%s-%d.zip' % ( |
| 251 | self.GetASANPlatformDir(), self.build_type, |
| 252 | self.GetASANBaseName(), revision) |
| 253 | return '%s%d' % (self._listing_platform_dir, revision) |
| 254 | |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 255 | def _FetchAndParse(url): |
| 256 | """Fetches a URL and returns a 2-Tuple of ([revisions], next-marker). If |
| 257 | next-marker is not None, then the listing is a partial listing and another |
| 258 | fetch should be performed with next-marker being the marker= GET |
| 259 | parameter.""" |
| 260 | handle = urllib.urlopen(url) |
| 261 | document = ElementTree.parse(handle) |
| 262 | |
| 263 | # All nodes in the tree are namespaced. Get the root's tag name to extract |
| 264 | # the namespace. Etree does namespaces as |{namespace}tag|. |
| 265 | root_tag = document.getroot().tag |
| 266 | end_ns_pos = root_tag.find('}') |
| 267 | if end_ns_pos == -1: |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 268 | raise Exception('Could not locate end namespace for directory index') |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 269 | namespace = root_tag[:end_ns_pos + 1] |
| 270 | |
| 271 | # Find the prefix (_listing_platform_dir) and whether or not the list is |
| 272 | # truncated. |
| 273 | prefix_len = len(document.find(namespace + 'Prefix').text) |
| 274 | next_marker = None |
| 275 | is_truncated = document.find(namespace + 'IsTruncated') |
| 276 | if is_truncated is not None and is_truncated.text.lower() == 'true': |
| 277 | next_marker = document.find(namespace + 'NextMarker').text |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 278 | # Get a list of all the revisions. |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 279 | revisions = [] |
[email protected] | 3e7c8532 | 2014-06-27 20:27:36 | [diff] [blame] | 280 | githash_svn_dict = {} |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 281 | if self.is_asan: |
| 282 | asan_regex = re.compile(r'.*%s-(\d+)\.zip$' % (self.GetASANBaseName())) |
| 283 | # Non ASAN builds are in a <revision> directory. The ASAN builds are |
| 284 | # flat |
| 285 | all_prefixes = document.findall(namespace + 'Contents/' + |
| 286 | namespace + 'Key') |
| 287 | for prefix in all_prefixes: |
| 288 | m = asan_regex.match(prefix.text) |
| 289 | if m: |
| 290 | try: |
| 291 | revisions.append(int(m.group(1))) |
| 292 | except ValueError: |
| 293 | pass |
| 294 | else: |
| 295 | all_prefixes = document.findall(namespace + 'CommonPrefixes/' + |
| 296 | namespace + 'Prefix') |
| 297 | # The <Prefix> nodes have content of the form of |
| 298 | # |_listing_platform_dir/revision/|. Strip off the platform dir and the |
| 299 | # trailing slash to just have a number. |
| 300 | for prefix in all_prefixes: |
| 301 | revnum = prefix.text[prefix_len:-1] |
| 302 | try: |
dimu | a1dfa0ce | 2016-03-31 01:08:45 | [diff] [blame] | 303 | revnum = int(revnum) |
| 304 | revisions.append(revnum) |
| 305 | # Notes: |
| 306 | # Ignore hash in chromium-browser-snapshots as they are invalid |
| 307 | # Resulting in 404 error in fetching pages: |
| 308 | # https://chromium.googlesource.com/chromium/src/+/[rev_hash] |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 309 | except ValueError: |
| 310 | pass |
[email protected] | 3e7c8532 | 2014-06-27 20:27:36 | [diff] [blame] | 311 | return (revisions, next_marker, githash_svn_dict) |
[email protected] | 9639b00 | 2013-08-30 14:45:52 | [diff] [blame] | 312 | |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 313 | # Fetch the first list of revisions. |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 314 | if last_known_rev: |
| 315 | revisions = [] |
| 316 | # Optimization: Start paging at the last known revision (local cache). |
| 317 | next_marker = _GetMarkerForRev(last_known_rev) |
| 318 | # Optimization: Stop paging at the last known revision (remote). |
| 319 | last_change_rev = GetChromiumRevision(self, self.GetLastChangeURL()) |
| 320 | if last_known_rev == last_change_rev: |
| 321 | return [] |
| 322 | else: |
| 323 | (revisions, next_marker, new_dict) = _FetchAndParse(self.GetListingURL()) |
| 324 | self.githash_svn_dict.update(new_dict) |
| 325 | last_change_rev = None |
| 326 | |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 327 | # If the result list was truncated, refetch with the next marker. Do this |
| 328 | # until an entire directory listing is done. |
| 329 | while next_marker: |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 330 | sys.stdout.write('\rFetching revisions at marker %s' % next_marker) |
| 331 | sys.stdout.flush() |
| 332 | |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 333 | next_url = self.GetListingURL(next_marker) |
[email protected] | 3e7c8532 | 2014-06-27 20:27:36 | [diff] [blame] | 334 | (new_revisions, next_marker, new_dict) = _FetchAndParse(next_url) |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 335 | revisions.extend(new_revisions) |
[email protected] | 3e7c8532 | 2014-06-27 20:27:36 | [diff] [blame] | 336 | self.githash_svn_dict.update(new_dict) |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 337 | if last_change_rev and last_change_rev in new_revisions: |
| 338 | break |
| 339 | sys.stdout.write('\r') |
| 340 | sys.stdout.flush() |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 341 | return revisions |
| 342 | |
[email protected] | 6a7a5d6 | 2014-07-09 04:45:50 | [diff] [blame] | 343 | def _GetSVNRevisionFromGitHashWithoutGitCheckout(self, git_sha1, depot): |
[email protected] | 3e7c8532 | 2014-06-27 20:27:36 | [diff] [blame] | 344 | json_url = GITHASH_TO_SVN_URL[depot] % git_sha1 |
[email protected] | 2e0f267 | 2014-08-13 20:32:58 | [diff] [blame] | 345 | response = urllib.urlopen(json_url) |
| 346 | if response.getcode() == 200: |
| 347 | try: |
| 348 | data = json.loads(response.read()[4:]) |
| 349 | except ValueError: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 350 | print('ValueError for JSON URL: %s' % json_url) |
[email protected] | 2e0f267 | 2014-08-13 20:32:58 | [diff] [blame] | 351 | raise ValueError |
| 352 | else: |
| 353 | raise ValueError |
[email protected] | 3e7c8532 | 2014-06-27 20:27:36 | [diff] [blame] | 354 | if 'message' in data: |
| 355 | message = data['message'].split('\n') |
| 356 | message = [line for line in message if line.strip()] |
| 357 | search_pattern = re.compile(SEARCH_PATTERN[depot]) |
| 358 | result = search_pattern.search(message[len(message)-1]) |
| 359 | if result: |
| 360 | return result.group(1) |
pshenoy | b23a145 | 2014-09-05 22:52:05 | [diff] [blame] | 361 | else: |
| 362 | if depot == 'chromium': |
| 363 | result = re.search(CHROMIUM_SEARCH_PATTERN_OLD, |
| 364 | message[len(message)-1]) |
| 365 | if result: |
| 366 | return result.group(1) |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 367 | print('Failed to get svn revision number for %s' % git_sha1) |
[email protected] | 1f99f4d | 2014-07-23 16:44:14 | [diff] [blame] | 368 | raise ValueError |
[email protected] | 3e7c8532 | 2014-06-27 20:27:36 | [diff] [blame] | 369 | |
[email protected] | 6a7a5d6 | 2014-07-09 04:45:50 | [diff] [blame] | 370 | def _GetSVNRevisionFromGitHashFromGitCheckout(self, git_sha1, depot): |
| 371 | def _RunGit(command, path): |
| 372 | command = ['git'] + command |
[email protected] | 6a7a5d6 | 2014-07-09 04:45:50 | [diff] [blame] | 373 | shell = sys.platform.startswith('win') |
| 374 | proc = subprocess.Popen(command, shell=shell, stdout=subprocess.PIPE, |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 375 | stderr=subprocess.PIPE, cwd=path) |
[email protected] | 6a7a5d6 | 2014-07-09 04:45:50 | [diff] [blame] | 376 | (output, _) = proc.communicate() |
[email protected] | 6a7a5d6 | 2014-07-09 04:45:50 | [diff] [blame] | 377 | return (output, proc.returncode) |
| 378 | |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 379 | path = self.local_src_path |
[email protected] | 6a7a5d6 | 2014-07-09 04:45:50 | [diff] [blame] | 380 | if depot == 'blink': |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 381 | path = os.path.join(self.local_src_path, 'third_party', 'WebKit') |
| 382 | revision = None |
| 383 | try: |
[email protected] | 6a7a5d6 | 2014-07-09 04:45:50 | [diff] [blame] | 384 | command = ['svn', 'find-rev', git_sha1] |
| 385 | (git_output, return_code) = _RunGit(command, path) |
| 386 | if not return_code: |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 387 | revision = git_output.strip('\n') |
| 388 | except ValueError: |
| 389 | pass |
| 390 | if not revision: |
| 391 | command = ['log', '-n1', '--format=%s', git_sha1] |
| 392 | (git_output, return_code) = _RunGit(command, path) |
| 393 | if not return_code: |
| 394 | revision = re.match('SVN changes up to revision ([0-9]+)', git_output) |
| 395 | revision = revision.group(1) if revision else None |
| 396 | if revision: |
| 397 | return revision |
| 398 | raise ValueError |
[email protected] | 6a7a5d6 | 2014-07-09 04:45:50 | [diff] [blame] | 399 | |
| 400 | def GetSVNRevisionFromGitHash(self, git_sha1, depot='chromium'): |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 401 | if not self.local_src_path: |
[email protected] | 6a7a5d6 | 2014-07-09 04:45:50 | [diff] [blame] | 402 | return self._GetSVNRevisionFromGitHashWithoutGitCheckout(git_sha1, depot) |
| 403 | else: |
| 404 | return self._GetSVNRevisionFromGitHashFromGitCheckout(git_sha1, depot) |
| 405 | |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 406 | def GetRevList(self): |
| 407 | """Gets the list of revision numbers between self.good_revision and |
| 408 | self.bad_revision.""" |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 409 | |
| 410 | cache = {} |
| 411 | # The cache is stored in the same directory as bisect-builds.py |
| 412 | cache_filename = os.path.join( |
| 413 | os.path.abspath(os.path.dirname(__file__)), |
| 414 | '.bisect-builds-cache.json') |
| 415 | cache_dict_key = self.GetListingURL() |
| 416 | |
| 417 | def _LoadBucketFromCache(): |
| 418 | if self.use_local_cache: |
| 419 | try: |
| 420 | with open(cache_filename) as cache_file: |
rob | 1c83605 | 2015-05-18 16:34:02 | [diff] [blame] | 421 | for (key, value) in json.load(cache_file).items(): |
| 422 | cache[key] = value |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 423 | revisions = cache.get(cache_dict_key, []) |
| 424 | githash_svn_dict = cache.get('githash_svn_dict', {}) |
| 425 | if revisions: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 426 | print('Loaded revisions %d-%d from %s' % |
| 427 | (revisions[0], revisions[-1], cache_filename)) |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 428 | return (revisions, githash_svn_dict) |
| 429 | except (EnvironmentError, ValueError): |
| 430 | pass |
| 431 | return ([], {}) |
| 432 | |
| 433 | def _SaveBucketToCache(): |
| 434 | """Save the list of revisions and the git-svn mappings to a file. |
| 435 | The list of revisions is assumed to be sorted.""" |
| 436 | if self.use_local_cache: |
| 437 | cache[cache_dict_key] = revlist_all |
| 438 | cache['githash_svn_dict'] = self.githash_svn_dict |
| 439 | try: |
| 440 | with open(cache_filename, 'w') as cache_file: |
| 441 | json.dump(cache, cache_file) |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 442 | print('Saved revisions %d-%d to %s' % |
| 443 | (revlist_all[0], revlist_all[-1], cache_filename)) |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 444 | except EnvironmentError: |
| 445 | pass |
| 446 | |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 447 | # Download the revlist and filter for just the range between good and bad. |
[email protected] | eadd95d | 2012-11-02 22:42:09 | [diff] [blame] | 448 | minrev = min(self.good_revision, self.bad_revision) |
| 449 | maxrev = max(self.good_revision, self.bad_revision) |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 450 | |
| 451 | (revlist_all, self.githash_svn_dict) = _LoadBucketFromCache() |
| 452 | last_known_rev = revlist_all[-1] if revlist_all else 0 |
| 453 | if last_known_rev < maxrev: |
| 454 | revlist_all.extend(map(int, self.ParseDirectoryIndex(last_known_rev))) |
| 455 | revlist_all = list(set(revlist_all)) |
| 456 | revlist_all.sort() |
| 457 | _SaveBucketToCache() |
[email protected] | 37ed317 | 2013-09-24 23:49:30 | [diff] [blame] | 458 | |
| 459 | revlist = [x for x in revlist_all if x >= int(minrev) and x <= int(maxrev)] |
[email protected] | 37ed317 | 2013-09-24 23:49:30 | [diff] [blame] | 460 | |
| 461 | # Set good and bad revisions to be legit revisions. |
| 462 | if revlist: |
| 463 | if self.good_revision < self.bad_revision: |
| 464 | self.good_revision = revlist[0] |
| 465 | self.bad_revision = revlist[-1] |
| 466 | else: |
| 467 | self.bad_revision = revlist[0] |
| 468 | self.good_revision = revlist[-1] |
| 469 | |
| 470 | # Fix chromium rev so that the deps blink revision matches REVISIONS file. |
| 471 | if self.base_url == WEBKIT_BASE_URL: |
| 472 | revlist_all.sort() |
| 473 | self.good_revision = FixChromiumRevForBlink(revlist, |
| 474 | revlist_all, |
| 475 | self, |
| 476 | self.good_revision) |
| 477 | self.bad_revision = FixChromiumRevForBlink(revlist, |
| 478 | revlist_all, |
| 479 | self, |
| 480 | self.bad_revision) |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 481 | return revlist |
| 482 | |
prasadv | 2375e6d | 2017-03-20 19:23:23 | [diff] [blame] | 483 | |
| 484 | def IsMac(): |
| 485 | return sys.platform.startswith('darwin') |
| 486 | |
| 487 | |
[email protected] | fc3702e | 2013-11-09 04:23:00 | [diff] [blame] | 488 | def UnzipFilenameToDir(filename, directory): |
| 489 | """Unzip |filename| to |directory|.""" |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 490 | cwd = os.getcwd() |
| 491 | if not os.path.isabs(filename): |
| 492 | filename = os.path.join(cwd, filename) |
[email protected] | bd8dcb9 | 2010-03-31 01:05:24 | [diff] [blame] | 493 | # Make base. |
[email protected] | fc3702e | 2013-11-09 04:23:00 | [diff] [blame] | 494 | if not os.path.isdir(directory): |
| 495 | os.mkdir(directory) |
| 496 | os.chdir(directory) |
prasadv | 2375e6d | 2017-03-20 19:23:23 | [diff] [blame] | 497 | |
| 498 | # The Python ZipFile does not support symbolic links, which makes it |
| 499 | # unsuitable for Mac builds. so use ditto instead. |
| 500 | if IsMac(): |
| 501 | unzip_cmd = ['ditto', '-x', '-k', filename, '.'] |
| 502 | proc = subprocess.Popen(unzip_cmd, bufsize=0, stdout=subprocess.PIPE, |
| 503 | stderr=subprocess.PIPE) |
| 504 | proc.communicate() |
| 505 | os.chdir(cwd) |
| 506 | return |
| 507 | |
| 508 | zf = zipfile.ZipFile(filename) |
[email protected] | e29c08c | 2012-09-17 20:50:50 | [diff] [blame] | 509 | # Extract files. |
| 510 | for info in zf.infolist(): |
| 511 | name = info.filename |
| 512 | if name.endswith('/'): # dir |
| 513 | if not os.path.isdir(name): |
| 514 | os.makedirs(name) |
| 515 | else: # file |
[email protected] | fc3702e | 2013-11-09 04:23:00 | [diff] [blame] | 516 | directory = os.path.dirname(name) |
John Budorick | 06e5df1 | 2015-02-27 17:44:27 | [diff] [blame] | 517 | if not os.path.isdir(directory): |
[email protected] | fc3702e | 2013-11-09 04:23:00 | [diff] [blame] | 518 | os.makedirs(directory) |
[email protected] | e29c08c | 2012-09-17 20:50:50 | [diff] [blame] | 519 | out = open(name, 'wb') |
| 520 | out.write(zf.read(name)) |
| 521 | out.close() |
| 522 | # Set permissions. Permission info in external_attr is shifted 16 bits. |
| 523 | os.chmod(name, info.external_attr >> 16L) |
| 524 | os.chdir(cwd) |
[email protected] | bd8dcb9 | 2010-03-31 01:05:24 | [diff] [blame] | 525 | |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 526 | |
[email protected] | 468a977 | 2011-08-09 18:42:00 | [diff] [blame] | 527 | def FetchRevision(context, rev, filename, quit_event=None, progress_event=None): |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 528 | """Downloads and unzips revision |rev|. |
| 529 | @param context A PathContext instance. |
| 530 | @param rev The Chromium revision number/tag to download. |
| 531 | @param filename The destination for the downloaded file. |
| 532 | @param quit_event A threading.Event which will be set by the master thread to |
| 533 | indicate that the download should be aborted. |
[email protected] | 468a977 | 2011-08-09 18:42:00 | [diff] [blame] | 534 | @param progress_event A threading.Event which will be set by the master thread |
| 535 | to indicate that the progress of the download should be |
| 536 | displayed. |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 537 | """ |
| 538 | def ReportHook(blocknum, blocksize, totalsize): |
[email protected] | 946be75 | 2011-10-25 23:34:21 | [diff] [blame] | 539 | if quit_event and quit_event.isSet(): |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 540 | raise RuntimeError('Aborting download of revision %s' % str(rev)) |
[email protected] | 946be75 | 2011-10-25 23:34:21 | [diff] [blame] | 541 | if progress_event and progress_event.isSet(): |
[email protected] | 468a977 | 2011-08-09 18:42:00 | [diff] [blame] | 542 | size = blocknum * blocksize |
| 543 | if totalsize == -1: # Total size not known. |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 544 | progress = 'Received %d bytes' % size |
[email protected] | 468a977 | 2011-08-09 18:42:00 | [diff] [blame] | 545 | else: |
| 546 | size = min(totalsize, size) |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 547 | progress = 'Received %d of %d bytes, %.2f%%' % ( |
[email protected] | 468a977 | 2011-08-09 18:42:00 | [diff] [blame] | 548 | size, totalsize, 100.0 * size / totalsize) |
| 549 | # Send a \r to let all progress messages use just one line of output. |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 550 | sys.stdout.write('\r' + progress) |
[email protected] | 468a977 | 2011-08-09 18:42:00 | [diff] [blame] | 551 | sys.stdout.flush() |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 552 | download_url = context.GetDownloadURL(rev) |
| 553 | try: |
John Budorick | 06e5df1 | 2015-02-27 17:44:27 | [diff] [blame] | 554 | urllib.urlretrieve(download_url, filename, ReportHook) |
[email protected] | 946be75 | 2011-10-25 23:34:21 | [diff] [blame] | 555 | if progress_event and progress_event.isSet(): |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 556 | print() |
mikecase | e2b6ce8 | 2015-02-06 18:22:39 | [diff] [blame] | 557 | |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 558 | except RuntimeError: |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 559 | pass |
[email protected] | 7ad66a7 | 2009-09-04 17:52:33 | [diff] [blame] | 560 | |
[email protected] | 7ad66a7 | 2009-09-04 17:52:33 | [diff] [blame] | 561 | |
Dominic Mazzoni | 215e80b | 2017-11-29 20:05:27 | [diff] [blame] | 562 | def CopyMissingFileFromCurrentSource(src_glob, dst): |
| 563 | """Work around missing files in archives. |
| 564 | This happens when archives of Chrome don't contain all of the files |
| 565 | needed to build it. In many cases we can work around this using |
| 566 | files from the current checkout. The source is in the form of a glob |
| 567 | so that it can try to look for possible sources of the file in |
| 568 | multiple locations, but we just arbitrarily try the first match. |
| 569 | |
| 570 | Silently fail if this doesn't work because we don't yet have clear |
| 571 | markers for builds that require certain files or a way to test |
| 572 | whether or not launching Chrome succeeded. |
| 573 | """ |
| 574 | if not os.path.exists(dst): |
| 575 | matches = glob.glob(src_glob) |
| 576 | if matches: |
| 577 | shutil.copy2(matches[0], dst) |
| 578 | |
| 579 | |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 580 | def RunRevision(context, revision, zip_file, profile, num_runs, command, args): |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 581 | """Given a zipped revision, unzip it and run the test.""" |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 582 | print('Trying revision %s...' % str(revision)) |
[email protected] | 3ff00b7 | 2011-07-20 21:34:47 | [diff] [blame] | 583 | |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 584 | # Create a temp directory and unzip the revision into it. |
[email protected] | 7ad66a7 | 2009-09-04 17:52:33 | [diff] [blame] | 585 | cwd = os.getcwd() |
| 586 | tempdir = tempfile.mkdtemp(prefix='bisect_tmp') |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 587 | UnzipFilenameToDir(zip_file, tempdir) |
dmazzoni | 76e907d | 2015-01-22 08:14:49 | [diff] [blame] | 588 | |
Dominic Mazzoni | 215e80b | 2017-11-29 20:05:27 | [diff] [blame] | 589 | # Hack: Some Chrome OS archives are missing some files; try to copy them |
| 590 | # from the local directory. |
Dominic Mazzoni | e84e40b | 2018-10-08 06:44:45 | [diff] [blame] | 591 | if context.platform == 'chromeos' and revision < 591483: |
Dominic Mazzoni | 215e80b | 2017-11-29 20:05:27 | [diff] [blame] | 592 | CopyMissingFileFromCurrentSource('third_party/icu/common/icudtl.dat', |
| 593 | '%s/chrome-linux/icudtl.dat' % tempdir) |
| 594 | CopyMissingFileFromCurrentSource('*out*/*/libminigbm.so', |
| 595 | '%s/chrome-linux/libminigbm.so' % tempdir) |
dmazzoni | 76e907d | 2015-01-22 08:14:49 | [diff] [blame] | 596 | |
[email protected] | 7ad66a7 | 2009-09-04 17:52:33 | [diff] [blame] | 597 | os.chdir(tempdir) |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 598 | |
[email protected] | 5e93cf16 | 2012-01-28 02:16:56 | [diff] [blame] | 599 | # Run the build as many times as specified. |
[email protected] | 4646a75 | 2013-07-19 22:14:34 | [diff] [blame] | 600 | testargs = ['--user-data-dir=%s' % profile] + args |
[email protected] | d0149c5c | 2012-05-29 21:12:11 | [diff] [blame] | 601 | # The sandbox must be run as root on Official Chrome, so bypass it. |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 602 | if (context.flash_path and context.platform.startswith('linux')): |
[email protected] | d0149c5c | 2012-05-29 21:12:11 | [diff] [blame] | 603 | testargs.append('--no-sandbox') |
[email protected] | fc3702e | 2013-11-09 04:23:00 | [diff] [blame] | 604 | if context.flash_path: |
| 605 | testargs.append('--ppapi-flash-path=%s' % context.flash_path) |
| 606 | # We have to pass a large enough Flash version, which currently needs not |
| 607 | # be correct. Instead of requiring the user of the script to figure out and |
| 608 | # pass the correct version we just spoof it. |
| 609 | testargs.append('--ppapi-flash-version=99.9.999.999') |
[email protected] | d0149c5c | 2012-05-29 21:12:11 | [diff] [blame] | 610 | |
[email protected] | 4646a75 | 2013-07-19 22:14:34 | [diff] [blame] | 611 | runcommand = [] |
[email protected] | 61ea90a | 2013-09-26 10:17:34 | [diff] [blame] | 612 | for token in shlex.split(command): |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 613 | if token == '%a': |
[email protected] | 4646a75 | 2013-07-19 22:14:34 | [diff] [blame] | 614 | runcommand.extend(testargs) |
| 615 | else: |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 616 | runcommand.append( |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 617 | token.replace('%p', os.path.abspath(context.GetLaunchPath(revision))). |
| 618 | replace('%s', ' '.join(testargs))) |
[email protected] | fb61fc3 | 2019-04-18 19:47:20 | [diff] [blame] | 619 | result = None |
[email protected] | 7ad66a7 | 2009-09-04 17:52:33 | [diff] [blame] | 620 | try: |
[email protected] | fb61fc3 | 2019-04-18 19:47:20 | [diff] [blame] | 621 | for _ in range(num_runs): |
| 622 | subproc = subprocess.Popen( |
| 623 | runcommand, |
| 624 | bufsize=-1, |
| 625 | stdout=subprocess.PIPE, |
| 626 | stderr=subprocess.PIPE) |
| 627 | (stdout, stderr) = subproc.communicate() |
| 628 | result = (subproc.returncode, stdout, stderr) |
| 629 | if subproc.returncode: |
| 630 | break |
| 631 | return result |
| 632 | finally: |
| 633 | os.chdir(cwd) |
| 634 | try: |
| 635 | shutil.rmtree(tempdir, True) |
| 636 | except Exception: |
| 637 | pass |
[email protected] | 79f1474 | 2010-03-10 01:01:57 | [diff] [blame] | 638 | |
[email protected] | cb155a8 | 2011-11-29 17:25:34 | [diff] [blame] | 639 | |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 640 | # The arguments status, stdout and stderr are unused. |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 641 | # They are present here because this function is passed to Bisect which then |
| 642 | # calls it with 5 arguments. |
| 643 | # pylint: disable=W0613 |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 644 | def AskIsGoodBuild(rev, exit_status, stdout, stderr): |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 645 | """Asks the user whether build |rev| is good or bad.""" |
Fergal Daly | 0dd1953 | 2019-04-04 07:45:33 | [diff] [blame] | 646 | if exit_status: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 647 | print('Chrome exit_status: %d. Use s to see output' % exit_status) |
[email protected] | 79f1474 | 2010-03-10 01:01:57 | [diff] [blame] | 648 | # Loop until we get a response that we can parse. |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 649 | while True: |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 650 | response = raw_input('Revision %s is ' |
wangxianzhu | d8c4c56 | 2015-12-15 23:39:51 | [diff] [blame] | 651 | '[(g)ood/(b)ad/(r)etry/(u)nknown/(s)tdout/(q)uit]: ' % |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 652 | str(rev)) |
wangxianzhu | d8c4c56 | 2015-12-15 23:39:51 | [diff] [blame] | 653 | if response in ('g', 'b', 'r', 'u'): |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 654 | return response |
wangxianzhu | d8c4c56 | 2015-12-15 23:39:51 | [diff] [blame] | 655 | if response == 'q': |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 656 | raise SystemExit() |
wangxianzhu | d8c4c56 | 2015-12-15 23:39:51 | [diff] [blame] | 657 | if response == 's': |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 658 | print(stdout) |
| 659 | print(stderr) |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 660 | |
[email protected] | cb155a8 | 2011-11-29 17:25:34 | [diff] [blame] | 661 | |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 662 | def IsGoodASANBuild(rev, exit_status, stdout, stderr): |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 663 | """Determine if an ASAN build |rev| is good or bad |
| 664 | |
| 665 | Will examine stderr looking for the error message emitted by ASAN. If not |
| 666 | found then will fallback to asking the user.""" |
| 667 | if stderr: |
| 668 | bad_count = 0 |
| 669 | for line in stderr.splitlines(): |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 670 | print(line) |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 671 | if line.find('ERROR: AddressSanitizer:') != -1: |
| 672 | bad_count += 1 |
| 673 | if bad_count > 0: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 674 | print('Revision %d determined to be bad.' % rev) |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 675 | return 'b' |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 676 | return AskIsGoodBuild(rev, exit_status, stdout, stderr) |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 677 | |
| 678 | |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 679 | def DidCommandSucceed(rev, exit_status, stdout, stderr): |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 680 | if exit_status: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 681 | print('Bad revision: %s' % rev) |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 682 | return 'b' |
| 683 | else: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 684 | print('Good revision: %s' % rev) |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 685 | return 'g' |
| 686 | |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 687 | |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 688 | class DownloadJob(object): |
| 689 | """DownloadJob represents a task to download a given Chromium revision.""" |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 690 | |
| 691 | def __init__(self, context, name, rev, zip_file): |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 692 | super(DownloadJob, self).__init__() |
| 693 | # Store off the input parameters. |
| 694 | self.context = context |
| 695 | self.name = name |
| 696 | self.rev = rev |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 697 | self.zip_file = zip_file |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 698 | self.quit_event = threading.Event() |
| 699 | self.progress_event = threading.Event() |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 700 | self.thread = None |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 701 | |
| 702 | def Start(self): |
| 703 | """Starts the download.""" |
| 704 | fetchargs = (self.context, |
| 705 | self.rev, |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 706 | self.zip_file, |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 707 | self.quit_event, |
| 708 | self.progress_event) |
| 709 | self.thread = threading.Thread(target=FetchRevision, |
| 710 | name=self.name, |
| 711 | args=fetchargs) |
| 712 | self.thread.start() |
| 713 | |
| 714 | def Stop(self): |
| 715 | """Stops the download which must have been started previously.""" |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 716 | assert self.thread, 'DownloadJob must be started before Stop is called.' |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 717 | self.quit_event.set() |
| 718 | self.thread.join() |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 719 | os.unlink(self.zip_file) |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 720 | |
| 721 | def WaitFor(self): |
| 722 | """Prints a message and waits for the download to complete. The download |
| 723 | must have been started previously.""" |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 724 | assert self.thread, 'DownloadJob must be started before WaitFor is called.' |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 725 | print('Downloading revision %s...' % str(self.rev)) |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 726 | self.progress_event.set() # Display progress of download. |
rob | 8a4543f | 2016-01-20 00:43:59 | [diff] [blame] | 727 | try: |
| 728 | while self.thread.isAlive(): |
| 729 | # The parameter to join is needed to keep the main thread responsive to |
| 730 | # signals. Without it, the program will not respond to interruptions. |
| 731 | self.thread.join(1) |
| 732 | except (KeyboardInterrupt, SystemExit): |
| 733 | self.Stop() |
| 734 | raise |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 735 | |
| 736 | |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 737 | def VerifyEndpoint(fetch, context, rev, profile, num_runs, command, try_args, |
| 738 | evaluate, expected_answer): |
| 739 | fetch.WaitFor() |
| 740 | try: |
Roman Sorokin | 760f06cd | 2019-12-24 08:35:41 | [diff] [blame] | 741 | answer = 'r' |
| 742 | # This is intended to allow evaluate() to return 'r' to retry RunRevision. |
| 743 | while answer == 'r': |
| 744 | (exit_status, stdout, stderr) = RunRevision( |
| 745 | context, rev, fetch.zip_file, profile, num_runs, command, try_args) |
| 746 | answer = evaluate(rev, exit_status, stdout, stderr); |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 747 | except Exception, e: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 748 | print(e, file=sys.stderr) |
Lei Zhang | 2fa7630 | 2018-11-09 20:16:31 | [diff] [blame] | 749 | raise SystemExit |
Roman Sorokin | 760f06cd | 2019-12-24 08:35:41 | [diff] [blame] | 750 | if (answer != expected_answer): |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 751 | print('Unexpected result at a range boundary! Your range is not correct.') |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 752 | raise SystemExit |
| 753 | |
| 754 | |
[email protected] | 2e0f267 | 2014-08-13 20:32:58 | [diff] [blame] | 755 | def Bisect(context, |
[email protected] | 5e93cf16 | 2012-01-28 02:16:56 | [diff] [blame] | 756 | num_runs=1, |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 757 | command='%p %a', |
[email protected] | 60ac66e3 | 2011-07-18 16:08:25 | [diff] [blame] | 758 | try_args=(), |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 759 | profile=None, |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 760 | evaluate=AskIsGoodBuild, |
| 761 | verify_range=False): |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 762 | """Given known good and known bad revisions, run a binary search on all |
| 763 | archived revisions to determine the last known good revision. |
[email protected] | 60ac66e3 | 2011-07-18 16:08:25 | [diff] [blame] | 764 | |
[email protected] | 2e0f267 | 2014-08-13 20:32:58 | [diff] [blame] | 765 | @param context PathContext object initialized with user provided parameters. |
[email protected] | 5e93cf16 | 2012-01-28 02:16:56 | [diff] [blame] | 766 | @param num_runs Number of times to run each build for asking good/bad. |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 767 | @param try_args A tuple of arguments to pass to the test application. |
| 768 | @param profile The name of the user profile to run with. |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 769 | @param evaluate A function which returns 'g' if the argument build is good, |
| 770 | 'b' if it's bad or 'u' if unknown. |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 771 | @param verify_range If true, tests the first and last revisions in the range |
| 772 | before proceeding with the bisect. |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 773 | |
| 774 | Threading is used to fetch Chromium revisions in the background, speeding up |
| 775 | the user's experience. For example, suppose the bounds of the search are |
| 776 | good_rev=0, bad_rev=100. The first revision to be checked is 50. Depending on |
| 777 | whether revision 50 is good or bad, the next revision to check will be either |
| 778 | 25 or 75. So, while revision 50 is being checked, the script will download |
| 779 | revisions 25 and 75 in the background. Once the good/bad verdict on rev 50 is |
| 780 | known: |
| 781 | |
| 782 | - If rev 50 is good, the download of rev 25 is cancelled, and the next test |
| 783 | is run on rev 75. |
| 784 | |
| 785 | - If rev 50 is bad, the download of rev 75 is cancelled, and the next test |
| 786 | is run on rev 25. |
[email protected] | 60ac66e3 | 2011-07-18 16:08:25 | [diff] [blame] | 787 | """ |
| 788 | |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 789 | if not profile: |
| 790 | profile = 'profile' |
| 791 | |
[email protected] | 2e0f267 | 2014-08-13 20:32:58 | [diff] [blame] | 792 | good_rev = context.good_revision |
| 793 | bad_rev = context.bad_revision |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 794 | cwd = os.getcwd() |
| 795 | |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 796 | print('Downloading list of known revisions...', end=' ') |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 797 | if not context.use_local_cache: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 798 | print('(use --use-local-cache to cache and re-use the list of revisions)') |
[email protected] | 28a3c12 | 2014-08-09 11:04:51 | [diff] [blame] | 799 | else: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 800 | print() |
[email protected] | d0149c5c | 2012-05-29 21:12:11 | [diff] [blame] | 801 | _GetDownloadPath = lambda rev: os.path.join(cwd, |
| 802 | '%s-%s' % (str(rev), context.archive_name)) |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 803 | revlist = context.GetRevList() |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 804 | |
| 805 | # Get a list of revisions to bisect across. |
| 806 | if len(revlist) < 2: # Don't have enough builds to bisect. |
| 807 | msg = 'We don\'t have enough builds to bisect. revlist: %s' % revlist |
| 808 | raise RuntimeError(msg) |
| 809 | |
| 810 | # Figure out our bookends and first pivot point; fetch the pivot revision. |
[email protected] | eadd95d | 2012-11-02 22:42:09 | [diff] [blame] | 811 | minrev = 0 |
| 812 | maxrev = len(revlist) - 1 |
| 813 | pivot = maxrev / 2 |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 814 | rev = revlist[pivot] |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 815 | fetch = DownloadJob(context, 'initial_fetch', rev, _GetDownloadPath(rev)) |
[email protected] | eadd95d | 2012-11-02 22:42:09 | [diff] [blame] | 816 | fetch.Start() |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 817 | |
| 818 | if verify_range: |
| 819 | minrev_fetch = DownloadJob( |
| 820 | context, 'minrev_fetch', revlist[minrev], |
| 821 | _GetDownloadPath(revlist[minrev])) |
| 822 | maxrev_fetch = DownloadJob( |
| 823 | context, 'maxrev_fetch', revlist[maxrev], |
| 824 | _GetDownloadPath(revlist[maxrev])) |
| 825 | minrev_fetch.Start() |
| 826 | maxrev_fetch.Start() |
| 827 | try: |
| 828 | VerifyEndpoint(minrev_fetch, context, revlist[minrev], profile, num_runs, |
| 829 | command, try_args, evaluate, 'b' if bad_rev < good_rev else 'g') |
| 830 | VerifyEndpoint(maxrev_fetch, context, revlist[maxrev], profile, num_runs, |
| 831 | command, try_args, evaluate, 'g' if bad_rev < good_rev else 'b') |
| 832 | except (KeyboardInterrupt, SystemExit): |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 833 | print('Cleaning up...') |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 834 | fetch.Stop() |
| 835 | sys.exit(0) |
| 836 | finally: |
| 837 | minrev_fetch.Stop() |
| 838 | maxrev_fetch.Stop() |
| 839 | |
[email protected] | eadd95d | 2012-11-02 22:42:09 | [diff] [blame] | 840 | fetch.WaitFor() |
[email protected] | 60ac66e3 | 2011-07-18 16:08:25 | [diff] [blame] | 841 | |
| 842 | # Binary search time! |
Bruce Dawson | 6225741 | 2020-01-17 17:39:53 | [diff] [blame] | 843 | prefetch_revisions = True |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 844 | while fetch and fetch.zip_file and maxrev - minrev > 1: |
[email protected] | eadd95d | 2012-11-02 22:42:09 | [diff] [blame] | 845 | if bad_rev < good_rev: |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 846 | min_str, max_str = 'bad', 'good' |
[email protected] | eadd95d | 2012-11-02 22:42:09 | [diff] [blame] | 847 | else: |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 848 | min_str, max_str = 'good', 'bad' |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 849 | print( |
| 850 | 'Bisecting range [%s (%s), %s (%s)], ' |
| 851 | 'roughly %d steps left.' % (revlist[minrev], min_str, revlist[maxrev], |
| 852 | max_str, int(maxrev - minrev).bit_length())) |
[email protected] | eadd95d | 2012-11-02 22:42:09 | [diff] [blame] | 853 | |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 854 | # Pre-fetch next two possible pivots |
| 855 | # - down_pivot is the next revision to check if the current revision turns |
| 856 | # out to be bad. |
| 857 | # - up_pivot is the next revision to check if the current revision turns |
| 858 | # out to be good. |
[email protected] | eadd95d | 2012-11-02 22:42:09 | [diff] [blame] | 859 | down_pivot = int((pivot - minrev) / 2) + minrev |
Bruce Dawson | 6225741 | 2020-01-17 17:39:53 | [diff] [blame] | 860 | if prefetch_revisions: |
| 861 | down_fetch = None |
| 862 | if down_pivot != pivot and down_pivot != minrev: |
| 863 | down_rev = revlist[down_pivot] |
| 864 | down_fetch = DownloadJob(context, 'down_fetch', down_rev, |
| 865 | _GetDownloadPath(down_rev)) |
| 866 | down_fetch.Start() |
[email protected] | 60ac66e3 | 2011-07-18 16:08:25 | [diff] [blame] | 867 | |
[email protected] | eadd95d | 2012-11-02 22:42:09 | [diff] [blame] | 868 | up_pivot = int((maxrev - pivot) / 2) + pivot |
Bruce Dawson | 6225741 | 2020-01-17 17:39:53 | [diff] [blame] | 869 | if prefetch_revisions: |
| 870 | up_fetch = None |
| 871 | if up_pivot != pivot and up_pivot != maxrev: |
| 872 | up_rev = revlist[up_pivot] |
| 873 | up_fetch = DownloadJob(context, 'up_fetch', up_rev, |
| 874 | _GetDownloadPath(up_rev)) |
| 875 | up_fetch.Start() |
[email protected] | 60ac66e3 | 2011-07-18 16:08:25 | [diff] [blame] | 876 | |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 877 | # Run test on the pivot revision. |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 878 | exit_status = None |
[email protected] | e29c08c | 2012-09-17 20:50:50 | [diff] [blame] | 879 | stdout = None |
| 880 | stderr = None |
| 881 | try: |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 882 | (exit_status, stdout, stderr) = RunRevision( |
| 883 | context, rev, fetch.zip_file, profile, num_runs, command, try_args) |
[email protected] | e29c08c | 2012-09-17 20:50:50 | [diff] [blame] | 884 | except Exception, e: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 885 | print(e, file=sys.stderr) |
[email protected] | 60ac66e3 | 2011-07-18 16:08:25 | [diff] [blame] | 886 | |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 887 | # Call the evaluate function to see if the current revision is good or bad. |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 888 | # On that basis, kill one of the background downloads and complete the |
| 889 | # other, as described in the comments above. |
| 890 | try: |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 891 | answer = evaluate(rev, exit_status, stdout, stderr) |
Bruce Dawson | 6225741 | 2020-01-17 17:39:53 | [diff] [blame] | 892 | prefetch_revisions = True |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 893 | if ((answer == 'g' and good_rev < bad_rev) |
| 894 | or (answer == 'b' and bad_rev < good_rev)): |
[email protected] | 1d4a0624 | 2013-08-20 22:53:12 | [diff] [blame] | 895 | fetch.Stop() |
[email protected] | eadd95d | 2012-11-02 22:42:09 | [diff] [blame] | 896 | minrev = pivot |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 897 | if down_fetch: |
| 898 | down_fetch.Stop() # Kill the download of the older revision. |
[email protected] | 1d4a0624 | 2013-08-20 22:53:12 | [diff] [blame] | 899 | fetch = None |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 900 | if up_fetch: |
| 901 | up_fetch.WaitFor() |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 902 | pivot = up_pivot |
[email protected] | eadd95d | 2012-11-02 22:42:09 | [diff] [blame] | 903 | fetch = up_fetch |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 904 | elif ((answer == 'b' and good_rev < bad_rev) |
| 905 | or (answer == 'g' and bad_rev < good_rev)): |
[email protected] | 1d4a0624 | 2013-08-20 22:53:12 | [diff] [blame] | 906 | fetch.Stop() |
[email protected] | eadd95d | 2012-11-02 22:42:09 | [diff] [blame] | 907 | maxrev = pivot |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 908 | if up_fetch: |
| 909 | up_fetch.Stop() # Kill the download of the newer revision. |
[email protected] | 1d4a0624 | 2013-08-20 22:53:12 | [diff] [blame] | 910 | fetch = None |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 911 | if down_fetch: |
| 912 | down_fetch.WaitFor() |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 913 | pivot = down_pivot |
[email protected] | eadd95d | 2012-11-02 22:42:09 | [diff] [blame] | 914 | fetch = down_fetch |
[email protected] | 1d4a0624 | 2013-08-20 22:53:12 | [diff] [blame] | 915 | elif answer == 'r': |
Bruce Dawson | 6225741 | 2020-01-17 17:39:53 | [diff] [blame] | 916 | # Don't redundantly prefetch. |
| 917 | prefetch_revisions = False |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 918 | elif answer == 'u': |
| 919 | # Nuke the revision from the revlist and choose a new pivot. |
[email protected] | 1d4a0624 | 2013-08-20 22:53:12 | [diff] [blame] | 920 | fetch.Stop() |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 921 | revlist.pop(pivot) |
[email protected] | eadd95d | 2012-11-02 22:42:09 | [diff] [blame] | 922 | maxrev -= 1 # Assumes maxrev >= pivot. |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 923 | |
[email protected] | eadd95d | 2012-11-02 22:42:09 | [diff] [blame] | 924 | if maxrev - minrev > 1: |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 925 | # Alternate between using down_pivot or up_pivot for the new pivot |
| 926 | # point, without affecting the range. Do this instead of setting the |
| 927 | # pivot to the midpoint of the new range because adjacent revisions |
| 928 | # are likely affected by the same issue that caused the (u)nknown |
| 929 | # response. |
| 930 | if up_fetch and down_fetch: |
| 931 | fetch = [up_fetch, down_fetch][len(revlist) % 2] |
| 932 | elif up_fetch: |
| 933 | fetch = up_fetch |
| 934 | else: |
| 935 | fetch = down_fetch |
| 936 | fetch.WaitFor() |
| 937 | if fetch == up_fetch: |
| 938 | pivot = up_pivot - 1 # Subtracts 1 because revlist was resized. |
| 939 | else: |
| 940 | pivot = down_pivot |
[email protected] | 53bb634 | 2012-06-01 04:11:00 | [diff] [blame] | 941 | |
| 942 | if down_fetch and fetch != down_fetch: |
| 943 | down_fetch.Stop() |
| 944 | if up_fetch and fetch != up_fetch: |
| 945 | up_fetch.Stop() |
| 946 | else: |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 947 | assert False, 'Unexpected return value from evaluate(): ' + answer |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 948 | except (KeyboardInterrupt, SystemExit): |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 949 | print('Cleaning up...') |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 950 | for f in [_GetDownloadPath(rev), |
| 951 | _GetDownloadPath(revlist[down_pivot]), |
[email protected] | 5e93cf16 | 2012-01-28 02:16:56 | [diff] [blame] | 952 | _GetDownloadPath(revlist[up_pivot])]: |
[email protected] | afe3066 | 2011-07-30 01:05:52 | [diff] [blame] | 953 | try: |
| 954 | os.unlink(f) |
| 955 | except OSError: |
| 956 | pass |
| 957 | sys.exit(0) |
| 958 | |
| 959 | rev = revlist[pivot] |
| 960 | |
[email protected] | 2e0f267 | 2014-08-13 20:32:58 | [diff] [blame] | 961 | return (revlist[minrev], revlist[maxrev], context) |
[email protected] | 60ac66e3 | 2011-07-18 16:08:25 | [diff] [blame] | 962 | |
| 963 | |
pshenoy | cd6bd68 | 2014-09-10 20:50:22 | [diff] [blame] | 964 | def GetBlinkDEPSRevisionForChromiumRevision(self, rev): |
[email protected] | 4c6fec6b | 2013-09-17 17:44:08 | [diff] [blame] | 965 | """Returns the blink revision that was in REVISIONS file at |
[email protected] | b2fe7f2 | 2011-10-25 22:58:31 | [diff] [blame] | 966 | chromium revision |rev|.""" |
pshenoy | cd6bd68 | 2014-09-10 20:50:22 | [diff] [blame] | 967 | |
| 968 | def _GetBlinkRev(url, blink_re): |
| 969 | m = blink_re.search(url.read()) |
| 970 | url.close() |
| 971 | if m: |
fmalita | a898d22 | 2016-07-12 22:29:03 | [diff] [blame] | 972 | return m.group(1) |
pshenoy | cd6bd68 | 2014-09-10 20:50:22 | [diff] [blame] | 973 | |
Di Mu | 08c5968 | 2016-07-11 23:05:07 | [diff] [blame] | 974 | url = urllib.urlopen(DEPS_FILE % GetGitHashFromSVNRevision(rev)) |
pshenoy | cd6bd68 | 2014-09-10 20:50:22 | [diff] [blame] | 975 | if url.getcode() == 200: |
Di Mu | 08c5968 | 2016-07-11 23:05:07 | [diff] [blame] | 976 | blink_re = re.compile(r'webkit_revision\D*\d+;\D*\d+;(\w+)') |
| 977 | blink_git_sha = _GetBlinkRev(url, blink_re) |
| 978 | return self.GetSVNRevisionFromGitHash(blink_git_sha, 'blink') |
pshenoy | cd6bd68 | 2014-09-10 20:50:22 | [diff] [blame] | 979 | raise Exception('Could not get Blink revision for Chromium rev %d' % rev) |
[email protected] | 37ed317 | 2013-09-24 23:49:30 | [diff] [blame] | 980 | |
| 981 | |
[email protected] | 2e0f267 | 2014-08-13 20:32:58 | [diff] [blame] | 982 | def GetBlinkRevisionForChromiumRevision(context, rev): |
[email protected] | 37ed317 | 2013-09-24 23:49:30 | [diff] [blame] | 983 | """Returns the blink revision that was in REVISIONS file at |
| 984 | chromium revision |rev|.""" |
[email protected] | 3e7c8532 | 2014-06-27 20:27:36 | [diff] [blame] | 985 | def _IsRevisionNumber(revision): |
| 986 | if isinstance(revision, int): |
| 987 | return True |
| 988 | else: |
| 989 | return revision.isdigit() |
[email protected] | 2e0f267 | 2014-08-13 20:32:58 | [diff] [blame] | 990 | if str(rev) in context.githash_svn_dict: |
| 991 | rev = context.githash_svn_dict[str(rev)] |
| 992 | file_url = '%s/%s%s/REVISIONS' % (context.base_url, |
| 993 | context._listing_platform_dir, rev) |
[email protected] | 4c6fec6b | 2013-09-17 17:44:08 | [diff] [blame] | 994 | url = urllib.urlopen(file_url) |
[email protected] | 2e0f267 | 2014-08-13 20:32:58 | [diff] [blame] | 995 | if url.getcode() == 200: |
| 996 | try: |
| 997 | data = json.loads(url.read()) |
| 998 | except ValueError: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 999 | print('ValueError for JSON URL: %s' % file_url) |
[email protected] | 2e0f267 | 2014-08-13 20:32:58 | [diff] [blame] | 1000 | raise ValueError |
| 1001 | else: |
| 1002 | raise ValueError |
[email protected] | b2fe7f2 | 2011-10-25 22:58:31 | [diff] [blame] | 1003 | url.close() |
[email protected] | 4c6fec6b | 2013-09-17 17:44:08 | [diff] [blame] | 1004 | if 'webkit_revision' in data: |
[email protected] | 3e7c8532 | 2014-06-27 20:27:36 | [diff] [blame] | 1005 | blink_rev = data['webkit_revision'] |
| 1006 | if not _IsRevisionNumber(blink_rev): |
[email protected] | 2e0f267 | 2014-08-13 20:32:58 | [diff] [blame] | 1007 | blink_rev = int(context.GetSVNRevisionFromGitHash(blink_rev, 'blink')) |
[email protected] | 3e7c8532 | 2014-06-27 20:27:36 | [diff] [blame] | 1008 | return blink_rev |
[email protected] | b2fe7f2 | 2011-10-25 22:58:31 | [diff] [blame] | 1009 | else: |
[email protected] | ff50d1c | 2013-04-17 18:49:36 | [diff] [blame] | 1010 | raise Exception('Could not get blink revision for cr rev %d' % rev) |
[email protected] | b2fe7f2 | 2011-10-25 22:58:31 | [diff] [blame] | 1011 | |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 1012 | |
[email protected] | 37ed317 | 2013-09-24 23:49:30 | [diff] [blame] | 1013 | def FixChromiumRevForBlink(revisions_final, revisions, self, rev): |
| 1014 | """Returns the chromium revision that has the correct blink revision |
| 1015 | for blink bisect, DEPS and REVISIONS file might not match since |
| 1016 | blink snapshots point to tip of tree blink. |
| 1017 | Note: The revisions_final variable might get modified to include |
| 1018 | additional revisions.""" |
pshenoy | cd6bd68 | 2014-09-10 20:50:22 | [diff] [blame] | 1019 | blink_deps_rev = GetBlinkDEPSRevisionForChromiumRevision(self, rev) |
[email protected] | 37ed317 | 2013-09-24 23:49:30 | [diff] [blame] | 1020 | |
| 1021 | while (GetBlinkRevisionForChromiumRevision(self, rev) > blink_deps_rev): |
| 1022 | idx = revisions.index(rev) |
| 1023 | if idx > 0: |
| 1024 | rev = revisions[idx-1] |
| 1025 | if rev not in revisions_final: |
| 1026 | revisions_final.insert(0, rev) |
| 1027 | |
| 1028 | revisions_final.sort() |
| 1029 | return rev |
[email protected] | b2fe7f2 | 2011-10-25 22:58:31 | [diff] [blame] | 1030 | |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 1031 | |
[email protected] | 5980b75 | 2014-07-02 00:34:40 | [diff] [blame] | 1032 | def GetChromiumRevision(context, url): |
[email protected] | 801fb65 | 2012-07-20 20:13:50 | [diff] [blame] | 1033 | """Returns the chromium revision read from given URL.""" |
| 1034 | try: |
| 1035 | # Location of the latest build revision number |
[email protected] | 5980b75 | 2014-07-02 00:34:40 | [diff] [blame] | 1036 | latest_revision = urllib.urlopen(url).read() |
| 1037 | if latest_revision.isdigit(): |
| 1038 | return int(latest_revision) |
| 1039 | return context.GetSVNRevisionFromGitHash(latest_revision) |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 1040 | except Exception: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 1041 | print('Could not determine latest revision. This could be bad...') |
[email protected] | 801fb65 | 2012-07-20 20:13:50 | [diff] [blame] | 1042 | return 999999999 |
| 1043 | |
pshenoy | cd6bd68 | 2014-09-10 20:50:22 | [diff] [blame] | 1044 | def GetGitHashFromSVNRevision(svn_revision): |
| 1045 | crrev_url = CRREV_URL + str(svn_revision) |
| 1046 | url = urllib.urlopen(crrev_url) |
| 1047 | if url.getcode() == 200: |
| 1048 | data = json.loads(url.read()) |
| 1049 | if 'git_sha' in data: |
| 1050 | return data['git_sha'] |
| 1051 | |
pshenoy | 9ce271f | 2014-09-02 22:14:05 | [diff] [blame] | 1052 | def PrintChangeLog(min_chromium_rev, max_chromium_rev): |
| 1053 | """Prints the changelog URL.""" |
| 1054 | |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 1055 | print(' ' + CHANGELOG_URL % (GetGitHashFromSVNRevision(min_chromium_rev), |
| 1056 | GetGitHashFromSVNRevision(max_chromium_rev))) |
| 1057 | |
pshenoy | 9ce271f | 2014-09-02 22:14:05 | [diff] [blame] | 1058 | |
elawrence | 446bcc3 | 2017-04-14 17:18:51 | [diff] [blame] | 1059 | def error_internal_option(option, opt, value, parser): |
[email protected] | fb61fc3 | 2019-04-18 19:47:20 | [diff] [blame] | 1060 | raise optparse.OptionValueError( |
| 1061 | 'The -o and -r options are only\navailable in the internal version of ' |
| 1062 | 'this script. Google\nemployees should visit http://go/bisect-builds ' |
| 1063 | 'for\nconfiguration instructions.') |
[email protected] | 801fb65 | 2012-07-20 20:13:50 | [diff] [blame] | 1064 | |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 1065 | def main(): |
[email protected] | 2c1d273 | 2009-10-29 19:52:17 | [diff] [blame] | 1066 | usage = ('%prog [options] [-- chromium-options]\n' |
[email protected] | 887c918 | 2013-02-12 20:30:31 | [diff] [blame] | 1067 | 'Perform binary search on the snapshot builds to find a minimal\n' |
| 1068 | 'range of revisions where a behavior change happened. The\n' |
| 1069 | 'behaviors are described as "good" and "bad".\n' |
| 1070 | 'It is NOT assumed that the behavior of the later revision is\n' |
[email protected] | 09c58da | 2013-01-07 21:30:17 | [diff] [blame] | 1071 | 'the bad one.\n' |
[email protected] | 178aab7 | 2010-10-08 17:21:38 | [diff] [blame] | 1072 | '\n' |
[email protected] | 887c918 | 2013-02-12 20:30:31 | [diff] [blame] | 1073 | 'Revision numbers should use\n' |
[email protected] | 887c918 | 2013-02-12 20:30:31 | [diff] [blame] | 1074 | ' SVN revisions (e.g. 123456) for chromium builds, from trunk.\n' |
| 1075 | ' Use base_trunk_revision from http://omahaproxy.appspot.com/\n' |
| 1076 | ' for earlier revs.\n' |
| 1077 | ' Chrome\'s about: build number and omahaproxy branch_revision\n' |
| 1078 | ' are incorrect, they are from branches.\n' |
| 1079 | '\n' |
Bruce Dawson | e357305 | 2020-06-29 23:14:35 | [diff] [blame^] | 1080 | 'Use "-- <args-to-pass-to-chromium>" to pass arbitrary extra \n' |
| 1081 | 'arguments to the test binaries.\n' |
| 1082 | 'E.g., add "-- --no-first-run" to bypass the first run prompts.') |
[email protected] | 7ad66a7 | 2009-09-04 17:52:33 | [diff] [blame] | 1083 | parser = optparse.OptionParser(usage=usage) |
[email protected] | 1a45d22 | 2009-09-19 01:58:57 | [diff] [blame] | 1084 | # Strangely, the default help output doesn't include the choice list. |
mikecase | a8cd284c | 2014-12-02 21:30:58 | [diff] [blame] | 1085 | choices = ['mac', 'mac64', 'win', 'win64', 'linux', 'linux64', 'linux-arm', |
dmazzoni | 76e907d | 2015-01-22 08:14:49 | [diff] [blame] | 1086 | 'chromeos'] |
[email protected] | 7ad66a7 | 2009-09-04 17:52:33 | [diff] [blame] | 1087 | parser.add_option('-a', '--archive', |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 1088 | choices=choices, |
| 1089 | help='The buildbot archive to bisect [%s].' % |
| 1090 | '|'.join(choices)) |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 1091 | parser.add_option('-b', '--bad', |
| 1092 | type='str', |
| 1093 | help='A bad revision to start bisection. ' |
| 1094 | 'May be earlier or later than the good revision. ' |
| 1095 | 'Default is HEAD.') |
| 1096 | parser.add_option('-f', '--flash_path', |
| 1097 | type='str', |
| 1098 | help='Absolute path to a recent Adobe Pepper Flash ' |
| 1099 | 'binary to be used in this bisection (e.g. ' |
| 1100 | 'on Windows C:\...\pepflashplayer.dll and on Linux ' |
| 1101 | '/opt/google/chrome/PepperFlash/' |
| 1102 | 'libpepflashplayer.so).') |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 1103 | parser.add_option('-g', '--good', |
| 1104 | type='str', |
| 1105 | help='A good revision to start bisection. ' + |
| 1106 | 'May be earlier or later than the bad revision. ' + |
| 1107 | 'Default is 0.') |
| 1108 | parser.add_option('-p', '--profile', '--user-data-dir', |
| 1109 | type='str', |
| 1110 | default='profile', |
| 1111 | help='Profile to use; this will not reset every run. ' |
| 1112 | 'Defaults to a clean profile.') |
| 1113 | parser.add_option('-t', '--times', |
| 1114 | type='int', |
| 1115 | default=1, |
| 1116 | help='Number of times to run each build before asking ' |
| 1117 | 'if it\'s good or bad. Temporary profiles are reused.') |
Bruce Dawson | e357305 | 2020-06-29 23:14:35 | [diff] [blame^] | 1118 | parser.add_option('-c', |
| 1119 | '--command', |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 1120 | type='str', |
| 1121 | default='%p %a', |
| 1122 | help='Command to execute. %p and %a refer to Chrome ' |
Bruce Dawson | e357305 | 2020-06-29 23:14:35 | [diff] [blame^] | 1123 | 'executable and specified extra arguments respectively. ' |
| 1124 | 'Use %s to specify all extra arguments as one string. ' |
| 1125 | 'Defaults to "%p %a". Note that any extra paths specified ' |
| 1126 | 'should be absolute. If you just need to append an ' |
| 1127 | 'argument to the Chrome command line use "-- ' |
| 1128 | '<args-to-pass-to-chromium>" instead.') |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 1129 | parser.add_option('-l', '--blink', |
| 1130 | action='store_true', |
| 1131 | help='Use Blink bisect instead of Chromium. ') |
| 1132 | parser.add_option('', '--not-interactive', |
| 1133 | action='store_true', |
| 1134 | default=False, |
| 1135 | help='Use command exit code to tell good/bad revision.') |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 1136 | parser.add_option('--asan', |
| 1137 | dest='asan', |
| 1138 | action='store_true', |
| 1139 | default=False, |
| 1140 | help='Allow the script to bisect ASAN builds') |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 1141 | parser.add_option('--use-local-cache', |
| 1142 | dest='use_local_cache', |
[email protected] | 6a7a5d6 | 2014-07-09 04:45:50 | [diff] [blame] | 1143 | action='store_true', |
| 1144 | default=False, |
rob | 724c906 | 2015-01-22 00:26:42 | [diff] [blame] | 1145 | help='Use a local file in the current directory to cache ' |
| 1146 | 'a list of known revisions to speed up the ' |
| 1147 | 'initialization of this script.') |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 1148 | parser.add_option('--verify-range', |
| 1149 | dest='verify_range', |
| 1150 | action='store_true', |
| 1151 | default=False, |
| 1152 | help='Test the first and last revisions in the range ' + |
| 1153 | 'before proceeding with the bisect.') |
elawrence | 446bcc3 | 2017-04-14 17:18:51 | [diff] [blame] | 1154 | parser.add_option("-r", action="callback", callback=error_internal_option) |
| 1155 | parser.add_option("-o", action="callback", callback=error_internal_option) |
[email protected] | b3b2051 | 2013-08-26 18:51:04 | [diff] [blame] | 1156 | |
[email protected] | 7ad66a7 | 2009-09-04 17:52:33 | [diff] [blame] | 1157 | (opts, args) = parser.parse_args() |
| 1158 | |
| 1159 | if opts.archive is None: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 1160 | print('Error: missing required parameter: --archive') |
| 1161 | print() |
[email protected] | 7ad66a7 | 2009-09-04 17:52:33 | [diff] [blame] | 1162 | parser.print_help() |
| 1163 | return 1 |
| 1164 | |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 1165 | if opts.asan: |
| 1166 | supported_platforms = ['linux', 'mac', 'win'] |
| 1167 | if opts.archive not in supported_platforms: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 1168 | print('Error: ASAN bisecting only supported on these platforms: [%s].' % |
| 1169 | ('|'.join(supported_platforms))) |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 1170 | return 1 |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 1171 | |
| 1172 | if opts.asan: |
| 1173 | base_url = ASAN_BASE_URL |
| 1174 | elif opts.blink: |
[email protected] | 4c6fec6b | 2013-09-17 17:44:08 | [diff] [blame] | 1175 | base_url = WEBKIT_BASE_URL |
| 1176 | else: |
| 1177 | base_url = CHROMIUM_BASE_URL |
| 1178 | |
[email protected] | 183706d9 | 2011-06-10 13:06:22 | [diff] [blame] | 1179 | # Create the context. Initialize 0 for the revisions as they are set below. |
[email protected] | 2e0f267 | 2014-08-13 20:32:58 | [diff] [blame] | 1180 | context = PathContext(base_url, opts.archive, opts.good, opts.bad, |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 1181 | opts.asan, opts.use_local_cache, |
vitalybuka | 4d1e1e41 | 2015-07-06 17:21:06 | [diff] [blame] | 1182 | opts.flash_path) |
mikecase | a8cd284c | 2014-12-02 21:30:58 | [diff] [blame] | 1183 | |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 1184 | # Pick a starting point, try to get HEAD for this. |
[email protected] | 2e0f267 | 2014-08-13 20:32:58 | [diff] [blame] | 1185 | if not opts.bad: |
| 1186 | context.bad_revision = '999.0.0.0' |
| 1187 | context.bad_revision = GetChromiumRevision( |
| 1188 | context, context.GetLastChangeURL()) |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 1189 | |
| 1190 | # Find out when we were good. |
[email protected] | 2e0f267 | 2014-08-13 20:32:58 | [diff] [blame] | 1191 | if not opts.good: |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 1192 | context.good_revision = 0 |
[email protected] | 801fb65 | 2012-07-20 20:13:50 | [diff] [blame] | 1193 | |
[email protected] | fc3702e | 2013-11-09 04:23:00 | [diff] [blame] | 1194 | if opts.flash_path: |
[email protected] | 2e0f267 | 2014-08-13 20:32:58 | [diff] [blame] | 1195 | msg = 'Could not find Flash binary at %s' % opts.flash_path |
| 1196 | assert os.path.exists(opts.flash_path), msg |
[email protected] | fc3702e | 2013-11-09 04:23:00 | [diff] [blame] | 1197 | |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 1198 | context.good_revision = int(context.good_revision) |
| 1199 | context.bad_revision = int(context.bad_revision) |
[email protected] | 801fb65 | 2012-07-20 20:13:50 | [diff] [blame] | 1200 | |
[email protected] | 5e93cf16 | 2012-01-28 02:16:56 | [diff] [blame] | 1201 | if opts.times < 1: |
| 1202 | print('Number of times to run (%d) must be greater than or equal to 1.' % |
| 1203 | opts.times) |
| 1204 | parser.print_help() |
| 1205 | return 1 |
| 1206 | |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 1207 | if opts.not_interactive: |
| 1208 | evaluator = DidCommandSucceed |
| 1209 | elif opts.asan: |
[email protected] | 01188669 | 2014-08-01 21:00:21 | [diff] [blame] | 1210 | evaluator = IsGoodASANBuild |
| 1211 | else: |
| 1212 | evaluator = AskIsGoodBuild |
| 1213 | |
[email protected] | 2e0f267 | 2014-08-13 20:32:58 | [diff] [blame] | 1214 | # Save these revision numbers to compare when showing the changelog URL |
| 1215 | # after the bisect. |
| 1216 | good_rev = context.good_revision |
| 1217 | bad_rev = context.bad_revision |
| 1218 | |
| 1219 | (min_chromium_rev, max_chromium_rev, context) = Bisect( |
| 1220 | context, opts.times, opts.command, args, opts.profile, |
skobes | 21b5cdfb | 2016-03-21 23:13:02 | [diff] [blame] | 1221 | evaluator, opts.verify_range) |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 1222 | |
[email protected] | ff50d1c | 2013-04-17 18:49:36 | [diff] [blame] | 1223 | # Get corresponding blink revisions. |
[email protected] | b2fe7f2 | 2011-10-25 22:58:31 | [diff] [blame] | 1224 | try: |
[email protected] | 4c6fec6b | 2013-09-17 17:44:08 | [diff] [blame] | 1225 | min_blink_rev = GetBlinkRevisionForChromiumRevision(context, |
| 1226 | min_chromium_rev) |
| 1227 | max_blink_rev = GetBlinkRevisionForChromiumRevision(context, |
| 1228 | max_chromium_rev) |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 1229 | except Exception: |
[email protected] | b2fe7f2 | 2011-10-25 22:58:31 | [diff] [blame] | 1230 | # Silently ignore the failure. |
[email protected] | ff50d1c | 2013-04-17 18:49:36 | [diff] [blame] | 1231 | min_blink_rev, max_blink_rev = 0, 0 |
[email protected] | b2fe7f2 | 2011-10-25 22:58:31 | [diff] [blame] | 1232 | |
[email protected] | 3bdaa475 | 2013-09-30 20:13:36 | [diff] [blame] | 1233 | if opts.blink: |
| 1234 | # We're done. Let the user know the results in an official manner. |
| 1235 | if good_rev > bad_rev: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 1236 | print(DONE_MESSAGE_GOOD_MAX % (str(min_blink_rev), str(max_blink_rev))) |
[email protected] | 3bdaa475 | 2013-09-30 20:13:36 | [diff] [blame] | 1237 | else: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 1238 | print(DONE_MESSAGE_GOOD_MIN % (str(min_blink_rev), str(max_blink_rev))) |
[email protected] | eadd95d | 2012-11-02 22:42:09 | [diff] [blame] | 1239 | |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 1240 | print('BLINK CHANGELOG URL:') |
| 1241 | print(' ' + BLINK_CHANGELOG_URL % (max_blink_rev, min_blink_rev)) |
[email protected] | 3bdaa475 | 2013-09-30 20:13:36 | [diff] [blame] | 1242 | |
[email protected] | d0149c5c | 2012-05-29 21:12:11 | [diff] [blame] | 1243 | else: |
[email protected] | 3bdaa475 | 2013-09-30 20:13:36 | [diff] [blame] | 1244 | # We're done. Let the user know the results in an official manner. |
| 1245 | if good_rev > bad_rev: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 1246 | print(DONE_MESSAGE_GOOD_MAX % (str(min_chromium_rev), |
| 1247 | str(max_chromium_rev))) |
[email protected] | 3bdaa475 | 2013-09-30 20:13:36 | [diff] [blame] | 1248 | else: |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 1249 | print(DONE_MESSAGE_GOOD_MIN % (str(min_chromium_rev), |
| 1250 | str(max_chromium_rev))) |
[email protected] | 3bdaa475 | 2013-09-30 20:13:36 | [diff] [blame] | 1251 | if min_blink_rev != max_blink_rev: |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 1252 | print ('NOTE: There is a Blink roll in the range, ' |
| 1253 | 'you might also want to do a Blink bisect.') |
[email protected] | 3bdaa475 | 2013-09-30 20:13:36 | [diff] [blame] | 1254 | |
Raul Tambre | 57e09d6 | 2019-09-22 17:18:52 | [diff] [blame] | 1255 | print('CHANGELOG URL:') |
Jason Kersey | 97bb027a | 2016-05-11 20:10:43 | [diff] [blame] | 1256 | PrintChangeLog(min_chromium_rev, max_chromium_rev) |
[email protected] | cb155a8 | 2011-11-29 17:25:34 | [diff] [blame] | 1257 | |
[email protected] | 4df583c | 2014-07-31 17:11:55 | [diff] [blame] | 1258 | |
[email protected] | 67e0bc6 | 2009-09-03 22:06:09 | [diff] [blame] | 1259 | if __name__ == '__main__': |
[email protected] | 7ad66a7 | 2009-09-04 17:52:33 | [diff] [blame] | 1260 | sys.exit(main()) |