| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Run Manual Test Bisect Tool | 6 """Run Manual Test Bisect Tool |
| 7 | 7 |
| 8 An example usage: | 8 An example usage: |
| 9 tools/run-bisect-manual-test.py -g 201281 -b 201290 | 9 tools/run-bisect-manual-test.py -g 201281 -b 201290 |
| 10 | 10 |
| 11 On Linux platform, follow the instructions in this document | 11 On Linux platform, follow the instructions in this document |
| 12 https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment | 12 https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment |
| 13 to setup the sandbox manually before running the script. Otherwise the script | 13 to setup the sandbox manually before running the script. Otherwise the script |
| 14 fails to launch Chrome and exits with an error. | 14 fails to launch Chrome and exits with an error. |
| 15 | 15 |
| 16 This script serves a similar function to bisect-builds.py, except it uses |
| 17 the bisect-perf-regression.py. This means that that it can actually check out |
| 18 and build revisions of Chromium that are not available in cloud storage. |
| 16 """ | 19 """ |
| 17 | 20 |
| 18 import os | 21 import os |
| 19 import subprocess | 22 import subprocess |
| 20 import sys | 23 import sys |
| 21 | 24 |
| 22 CROS_BOARD_ENV = 'BISECT_CROS_BOARD' | 25 CROS_BOARD_ENV = 'BISECT_CROS_BOARD' |
| 23 CROS_IP_ENV = 'BISECT_CROS_IP' | 26 CROS_IP_ENV = 'BISECT_CROS_IP' |
| 24 _DIR_TOOLS_ROOT = os.path.abspath(os.path.dirname(__file__)) | 27 _DIR_TOOLS_ROOT = os.path.abspath(os.path.dirname(__file__)) |
| 25 | 28 |
| 26 sys.path.append(os.path.join(_DIR_TOOLS_ROOT, 'telemetry')) | 29 sys.path.append(os.path.join(_DIR_TOOLS_ROOT, 'telemetry')) |
| 27 from telemetry.core import browser_options | 30 from telemetry.core import browser_options |
| 28 | 31 |
| 29 | 32 |
| 30 def _RunBisectionScript(options): | 33 def _RunBisectionScript(options): |
| 31 """Attempts to execute src/tools/bisect-perf-regression.py with the parameters | 34 """Attempts to execute src/tools/bisect-perf-regression.py. |
| 32 passed in. | |
| 33 | 35 |
| 34 Args: | 36 Args: |
| 35 options: The configuration options to pass to the bisect script. | 37 options: The configuration options to pass to the bisect script. |
| 36 | 38 |
| 37 Returns: | 39 Returns: |
| 38 0 on success, otherwise 1. | 40 The exit code of bisect-perf-regression.py: 0 on success, otherwise 1. |
| 39 """ | 41 """ |
| 40 test_command = 'python %s --browser=%s --chrome-root=.' %\ | 42 test_command = ('python %s --browser=%s --chrome-root=.' % |
| 41 (os.path.join(_DIR_TOOLS_ROOT, 'bisect-manual-test.py'), | 43 (os.path.join(_DIR_TOOLS_ROOT, 'bisect-manual-test.py'), |
| 42 options.browser_type) | 44 options.browser_type)) |
| 43 | 45 |
| 44 cmd = ['python', os.path.join(_DIR_TOOLS_ROOT, 'bisect-perf-regression.py'), | 46 cmd = ['python', os.path.join(_DIR_TOOLS_ROOT, 'bisect-perf-regression.py'), |
| 45 '-c', test_command, | 47 '-c', test_command, |
| 46 '-g', options.good_revision, | 48 '-g', options.good_revision, |
| 47 '-b', options.bad_revision, | 49 '-b', options.bad_revision, |
| 48 '-m', 'manual_test/manual_test', | 50 '-m', 'manual_test/manual_test', |
| 49 '-r', '1', | 51 '-r', '1', |
| 50 '--working_directory', options.working_directory, | 52 '--working_directory', options.working_directory, |
| 51 '--build_preference', 'ninja', | 53 '--build_preference', 'ninja', |
| 52 '--use_goma', | 54 '--use_goma', |
| 53 '--no_custom_deps'] | 55 '--no_custom_deps'] |
| 54 | 56 |
| 55 if options.extra_src: | 57 if options.extra_src: |
| 56 cmd.extend(['--extra_src', options.extra_src]) | 58 cmd.extend(['--extra_src', options.extra_src]) |
| 57 | 59 |
| 58 if 'cros' in options.browser_type: | 60 if 'cros' in options.browser_type: |
| 59 cmd.extend(['--target_platform', 'cros']) | 61 cmd.extend(['--target_platform', 'cros']) |
| 60 | 62 |
| 61 if os.environ[CROS_BOARD_ENV] and os.environ[CROS_IP_ENV]: | 63 if os.environ[CROS_BOARD_ENV] and os.environ[CROS_IP_ENV]: |
| 62 cmd.extend(['--cros_board', os.environ[CROS_BOARD_ENV]]) | 64 cmd.extend(['--cros_board', os.environ[CROS_BOARD_ENV]]) |
| 63 cmd.extend(['--cros_remote_ip', os.environ[CROS_IP_ENV]]) | 65 cmd.extend(['--cros_remote_ip', os.environ[CROS_IP_ENV]]) |
| 64 else: | 66 else: |
| 65 print 'Error: Cros build selected, but BISECT_CROS_IP or'\ | 67 print ('Error: Cros build selected, but BISECT_CROS_IP or' |
| 66 'BISECT_CROS_BOARD undefined.' | 68 'BISECT_CROS_BOARD undefined.\n') |
| 67 print | |
| 68 return 1 | 69 return 1 |
| 69 elif 'android-chrome' in options.browser_type: | 70 elif 'android-chrome' in options.browser_type: |
| 70 cmd.extend(['--target_platform', 'android-chrome']) | 71 cmd.extend(['--target_platform', 'android-chrome']) |
| 71 elif 'android' in options.browser_type: | 72 elif 'android' in options.browser_type: |
| 72 cmd.extend(['--target_platform', 'android']) | 73 cmd.extend(['--target_platform', 'android']) |
| 73 elif not options.target_build_type: | 74 elif not options.target_build_type: |
| 74 cmd.extend(['--target_build_type', options.browser_type.title()]) | 75 cmd.extend(['--target_build_type', options.browser_type.title()]) |
| 75 | 76 |
| 76 if options.target_build_type: | 77 if options.target_build_type: |
| 77 cmd.extend(['--target_build_type', options.target_build_type]) | 78 cmd.extend(['--target_build_type', options.target_build_type]) |
| 78 | 79 |
| 79 | |
| 80 cmd = [str(c) for c in cmd] | 80 cmd = [str(c) for c in cmd] |
| 81 | 81 |
| 82 return_code = subprocess.call(cmd) | 82 return_code = subprocess.call(cmd) |
| 83 | 83 |
| 84 if return_code: | 84 if return_code: |
| 85 print 'Error: bisect-perf-regression.py returned with error %d' %\ | 85 print ('Error: bisect-perf-regression.py returned with error %d' % |
| 86 return_code | 86 return_code) |
| 87 print | 87 print |
| 88 | 88 |
| 89 return return_code | 89 return return_code |
| 90 | 90 |
| 91 | 91 |
| 92 def main(): | 92 def main(): |
| 93 """Does a bisect based on the command-line arguments passed in. |
| 94 |
| 95 The user will be prompted to classify each revision as good or bad. |
| 96 """ |
| 93 usage = ('%prog [options]\n' | 97 usage = ('%prog [options]\n' |
| 94 'Used to run the bisection script with a manual test.') | 98 'Used to run the bisection script with a manual test.') |
| 95 | 99 |
| 96 options = browser_options.BrowserFinderOptions('release') | 100 options = browser_options.BrowserFinderOptions('release') |
| 97 parser = options.CreateParser(usage) | 101 parser = options.CreateParser(usage) |
| 98 | 102 |
| 99 parser.add_option('-b', '--bad_revision', | 103 parser.add_option('-b', '--bad_revision', |
| 100 type='str', | 104 type='str', |
| 101 help='A bad revision to start bisection. ' + | 105 help='A bad revision to start bisection. ' + |
| 102 'Must be later than good revision. May be either a git' + | 106 'Must be later than good revision. May be either a git' + |
| (...skipping 11 matching lines...) Expand all Loading... |
| 114 'a copy of the chromium depot.') | 118 'a copy of the chromium depot.') |
| 115 parser.add_option('--extra_src', | 119 parser.add_option('--extra_src', |
| 116 type='str', | 120 type='str', |
| 117 help='Path to extra source file. If this is supplied, ' | 121 help='Path to extra source file. If this is supplied, ' |
| 118 'bisect script will use this to override default behavior.') | 122 'bisect script will use this to override default behavior.') |
| 119 parser.add_option('--target_build_type', | 123 parser.add_option('--target_build_type', |
| 120 type='choice', | 124 type='choice', |
| 121 choices=['Release', 'Debug'], | 125 choices=['Release', 'Debug'], |
| 122 help='The target build type. Choices are "Release" ' | 126 help='The target build type. Choices are "Release" ' |
| 123 'or "Debug".') | 127 'or "Debug".') |
| 124 options, args = parser.parse_args() | 128 options, _ = parser.parse_args() |
| 125 error_msg = '' | 129 error_msg = '' |
| 126 if not options.good_revision: | 130 if not options.good_revision: |
| 127 error_msg += 'Error: missing required parameter: --good_revision\n' | 131 error_msg += 'Error: missing required parameter: --good_revision\n' |
| 128 if not options.bad_revision: | 132 if not options.bad_revision: |
| 129 error_msg += 'Error: missing required parameter: --bad_revision\n' | 133 error_msg += 'Error: missing required parameter: --bad_revision\n' |
| 130 | 134 |
| 131 if error_msg: | 135 if error_msg: |
| 132 print error_msg | 136 print error_msg |
| 133 parser.print_help() | 137 parser.print_help() |
| 134 return 1 | 138 return 1 |
| 135 | 139 |
| 136 if 'android' not in options.browser_type and sys.platform.startswith('linux'): | 140 if 'android' not in options.browser_type and sys.platform.startswith('linux'): |
| 137 if not os.environ.get('CHROME_DEVEL_SANDBOX'): | 141 if not os.environ.get('CHROME_DEVEL_SANDBOX'): |
| 138 print 'SUID sandbox has not been setup.'\ | 142 print 'SUID sandbox has not been setup.'\ |
| 139 ' See https://code.google.com/p/chromium/wiki/'\ | 143 ' See https://code.google.com/p/chromium/wiki/'\ |
| 140 'LinuxSUIDSandboxDevelopment for more information.' | 144 'LinuxSUIDSandboxDevelopment for more information.' |
| 141 return 1 | 145 return 1 |
| 142 | 146 |
| 143 return _RunBisectionScript(options) | 147 return _RunBisectionScript(options) |
| 144 | 148 |
| 145 | 149 |
| 146 if __name__ == '__main__': | 150 if __name__ == '__main__': |
| 147 sys.exit(main()) | 151 sys.exit(main()) |
| OLD | NEW |