Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Unified Diff: tools/bisect-perf-regression.py

Issue 12261026: Added separate checkout and config file generation to bisect script (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes from review. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/PRESUBMIT.py ('k') | tools/run-bisect-perf-regression.cfg » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/bisect-perf-regression.py
diff --git a/tools/bisect-perf-regression.py b/tools/bisect-perf-regression.py
index 4afe1cf384780ac04528d4a9b81f51e32c0ca8fe..0c3c9a43416508a32dd27d5ef932cc2bcc273ea6 100755
--- a/tools/bisect-perf-regression.py
+++ b/tools/bisect-perf-regression.py
@@ -35,14 +35,14 @@ An example usage (using git hashes):
"""
-
-import re
-import os
+import errno
import imp
-import sys
-import shlex
import optparse
+import os
+import re
+import shlex
import subprocess
+import sys
# The additional repositories that might need to be bisected.
@@ -89,6 +89,25 @@ DEPOT_NAMES = DEPOT_DEPS_NAME.keys()
FILE_DEPS_GIT = '.DEPS.git'
+GCLIENT_SPEC = """
+solutions = [
+ { "name" : "src",
+ "url" : "https://chromium.googlesource.com/chromium/src.git",
+ "deps_file" : ".DEPS.git",
+ "managed" : True,
+ "custom_deps" : {
+ },
+ "safesync_url": "",
+ },
+ { "name" : "src-internal",
+ "url" : "ssh://gerrit-int.chromium.org:29419/" +
+ "chrome/src-internal.git",
+ "deps_file" : ".DEPS.git",
+ },
+]
+"""
+GCLIENT_SPEC = ''.join([l for l in GCLIENT_SPEC.splitlines()])
+
def IsStringFloat(string_to_check):
@@ -1134,6 +1153,86 @@ def DetermineAndCreateSourceControl():
return None
+def CreateAndChangeToSourceDirectory(working_directory):
+ """Creates a directory 'bisect' as a subdirectory of 'working_directory'. If
+ the function is successful, the current working directory will change to that
+ of the new 'bisect' directory.
+
+ Returns:
+ True if the directory was successfully created (or already existed).
+ """
+ cwd = os.getcwd()
+ os.chdir(working_directory)
+ try:
+ os.mkdir('bisect')
+ except OSError, e:
+ if e.errno != errno.EEXIST:
+ return False
+ os.chdir('bisect')
+ return True
+
+
+def RunGClient(params):
+ """Runs gclient with the specified parameters.
+
+ Args:
+ params: A list of parameters to pass to gclient.
+
+ Returns:
+ The return code of the call.
+ """
+ cmd = ['gclient'] + params
+ return subprocess.call(cmd)
+
+
+def RunGClientAndCreateConfig():
+ """Runs gclient and creates a config containing both src and src-internal.
+
+ Returns:
+ The return code of the call.
+ """
+ return_code = RunGClient(
+ ['config', '--spec=%s' % GCLIENT_SPEC, '--git-deps'])
+ return return_code
+
+
+def RunGClientAndSync():
+ """Runs gclient and does a normal sync.
+
+ Returns:
+ The return code of the call.
+ """
+ return RunGClient(['sync'])
+
+
+def SetupGitDepot(output_buildbot_annotations):
+ """Sets up the depot for the bisection. The depot will be located in a
+ subdirectory called 'bisect'.
+
+ Returns:
+ True if gclient successfully created the config file and did a sync, False
+ otherwise.
+ """
+ name = 'Setting up Bisection Depot'
+
+ if output_buildbot_annotations:
Mike Stip (use stip instead) 2013/02/21 02:15:32 probably want to use OutputAnnotationStepStart() h
shatch 2013/02/21 16:58:08 Done.
+ print '@@@SEED_STEP %s@@@' % name
+ print '@@@STEP_CURSOR %s@@@' % name
+ print '@@@STEP_STARTED@@@'
+
+ passed = False
+
+ if not RunGClientAndCreateConfig():
+ if not RunGClientAndSync():
+ passed = True
+
+ if output_buildbot_annotations:
+ print
Mike Stip (use stip instead) 2013/02/21 02:15:32 OutputAnnotationStepClosed()
shatch 2013/02/21 16:58:08 Done.
+ print '@@@STEP_CLOSED@@@'
+
+ return passed
+
+
def main():
usage = ('%prog [options] [-- chromium-options]\n'
@@ -1160,6 +1259,14 @@ def main():
type='str',
help='The desired metric to bisect on. For example ' +
'"vm_rss_final_b/vm_rss_f_b"')
+ parser.add_option('-w', '--working_directory',
+ type='str',
+ help='Path to the working directory where the script will '
+ 'do an initial checkout of the chromium depot. The '
+ 'files will be placed in a subdirectory "bisect" under '
+ 'working_directory and that will be used to perform the '
+ 'bisection. This parameter is optional, if it is not '
+ 'supplied, the script will work from the current depot.')
parser.add_option('--use_goma',
action="store_true",
help='Add a bunch of extra threads for goma.')
@@ -1207,6 +1314,24 @@ def main():
print
return 1
+ metric_values = opts.metric.split('/')
+ if len(metric_values) != 2:
+ print "Invalid metric specified: [%s]" % (opts.metric,)
+ print
+ return 1
+
+ if opts.working_directory:
+ if not CreateAndChangeToSourceDirectory(opts.working_directory):
+ print 'Error: Could not create bisect directory.'
+ print
+ return 1
+
+ if not SetupGitDepot(opts.output_buildbot_annotations):
+ print 'Error: Failed to grab source.'
+ print
+ return 1
+
+ os.chdir(os.path.join(os.getcwd(), 'src'))
# Check what source control method they're using. Only support git workflow
# at the moment.
@@ -1223,13 +1348,6 @@ def main():
print
return 1
- metric_values = opts.metric.split('/')
- if len(metric_values) < 2:
- print "Invalid metric specified: [%s]" % (opts.metric,)
- print
- return 1
-
-
bisect_test = BisectPerformanceMetrics(source_control, opts)
bisect_results = bisect_test.Run(opts.command,
opts.bad_revision,
« no previous file with comments | « tools/PRESUBMIT.py ('k') | tools/run-bisect-perf-regression.cfg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698