bb_device_steps.py revision 46d4c2bc3267f3f028f39e7e311b0f89aba2e4fd
1#!/usr/bin/env python 2# Copyright (c) 2013 The Chromium Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import collections 7import glob 8import hashlib 9import json 10import os 11import random 12import re 13import shutil 14import sys 15 16import bb_utils 17import bb_annotations 18 19sys.path.append(os.path.join(os.path.dirname(__file__), '..')) 20import provision_devices 21from pylib import android_commands 22from pylib import constants 23from pylib.device import device_utils 24from pylib.gtest import gtest_config 25 26CHROME_SRC_DIR = bb_utils.CHROME_SRC 27DIR_BUILD_ROOT = os.path.dirname(CHROME_SRC_DIR) 28CHROME_OUT_DIR = bb_utils.CHROME_OUT_DIR 29 30SLAVE_SCRIPTS_DIR = os.path.join(bb_utils.BB_BUILD_DIR, 'scripts', 'slave') 31LOGCAT_DIR = os.path.join(bb_utils.CHROME_OUT_DIR, 'logcat') 32GS_URL = 'https://storage.googleapis.com' 33GS_AUTH_URL = 'https://storage.cloud.google.com' 34 35# Describes an instrumation test suite: 36# test: Name of test we're running. 37# apk: apk to be installed. 38# apk_package: package for the apk to be installed. 39# test_apk: apk to run tests on. 40# test_data: data folder in format destination:source. 41# host_driven_root: The host-driven test root directory. 42# annotation: Annotation of the tests to include. 43# exclude_annotation: The annotation of the tests to exclude. 44I_TEST = collections.namedtuple('InstrumentationTest', [ 45 'name', 'apk', 'apk_package', 'test_apk', 'test_data', 'host_driven_root', 46 'annotation', 'exclude_annotation', 'extra_flags']) 47 48 49def SrcPath(*path): 50 return os.path.join(CHROME_SRC_DIR, *path) 51 52 53def I(name, apk, apk_package, test_apk, test_data, host_driven_root=None, 54 annotation=None, exclude_annotation=None, extra_flags=None): 55 return I_TEST(name, apk, apk_package, test_apk, test_data, host_driven_root, 56 annotation, exclude_annotation, extra_flags) 57 58INSTRUMENTATION_TESTS = dict((suite.name, suite) for suite in [ 59 I('ContentShell', 60 'ContentShell.apk', 61 'org.chromium.content_shell_apk', 62 'ContentShellTest', 63 'content:content/test/data/android/device_files'), 64 I('ChromeShell', 65 'ChromeShell.apk', 66 'org.chromium.chrome.shell', 67 'ChromeShellTest', 68 'chrome:chrome/test/data/android/device_files', 69 constants.CHROME_SHELL_HOST_DRIVEN_DIR), 70 I('AndroidWebView', 71 'AndroidWebView.apk', 72 'org.chromium.android_webview.shell', 73 'AndroidWebViewTest', 74 'webview:android_webview/test/data/device_files'), 75 ]) 76 77VALID_TESTS = set(['chromedriver', 'gpu', 'mojo', 'telemetry_perf_unittests', 78 'ui', 'unit', 'webkit', 'webkit_layout', 'webrtc_chromium', 79 'webrtc_native']) 80 81RunCmd = bb_utils.RunCmd 82 83 84def _GetRevision(options): 85 """Get the SVN revision number. 86 87 Args: 88 options: options object. 89 90 Returns: 91 The revision number. 92 """ 93 revision = options.build_properties.get('got_revision') 94 if not revision: 95 revision = options.build_properties.get('revision', 'testing') 96 return revision 97 98 99def RunTestSuites(options, suites, suites_options=None): 100 """Manages an invocation of test_runner.py for gtests. 101 102 Args: 103 options: options object. 104 suites: List of suite names to run. 105 suites_options: Command line options dictionary for particular suites. 106 For example, 107 {'content_browsertests', ['--num_retries=1', '--release']} 108 will add the options only to content_browsertests. 109 """ 110 111 if not suites_options: 112 suites_options = {} 113 114 args = ['--verbose'] 115 if options.target == 'Release': 116 args.append('--release') 117 if options.asan: 118 args.append('--tool=asan') 119 if options.gtest_filter: 120 args.append('--gtest-filter=%s' % options.gtest_filter) 121 122 for suite in suites: 123 bb_annotations.PrintNamedStep(suite) 124 cmd = ['build/android/test_runner.py', 'gtest', '-s', suite] + args 125 cmd += suites_options.get(suite, []) 126 if suite == 'content_browsertests': 127 cmd.append('--num_retries=1') 128 RunCmd(cmd) 129 130 131def RunChromeDriverTests(options): 132 """Run all the steps for running chromedriver tests.""" 133 bb_annotations.PrintNamedStep('chromedriver_annotation') 134 RunCmd(['chrome/test/chromedriver/run_buildbot_steps.py', 135 '--android-packages=%s,%s,%s,%s' % 136 ('chrome_shell', 137 'chrome_stable', 138 'chrome_beta', 139 'chromedriver_webview_shell'), 140 '--revision=%s' % _GetRevision(options), 141 '--update-log']) 142 143 144def RunTelemetryPerfUnitTests(options): 145 """Runs the telemetry perf unit tests. 146 147 Args: 148 options: options object. 149 """ 150 InstallApk(options, INSTRUMENTATION_TESTS['ChromeShell'], False) 151 args = ['--browser', 'android-chrome-shell'] 152 devices = android_commands.GetAttachedDevices() 153 if devices: 154 args = args + ['--device', devices[0]] 155 bb_annotations.PrintNamedStep('telemetry_perf_unittests') 156 RunCmd(['tools/perf/run_tests'] + args) 157 158 159def RunMojoTests(options): 160 """Runs the mojo unit tests. 161 162 Args: 163 options: options object. 164 """ 165 test = I('MojoTest', 166 None, 167 'org.chromium.mojo.tests', 168 'MojoTest', 169 None) 170 RunInstrumentationSuite(options, test) 171 172 173def InstallApk(options, test, print_step=False): 174 """Install an apk to all phones. 175 176 Args: 177 options: options object 178 test: An I_TEST namedtuple 179 print_step: Print a buildbot step 180 """ 181 if print_step: 182 bb_annotations.PrintNamedStep('install_%s' % test.name.lower()) 183 184 args = ['--apk', test.apk, '--apk_package', test.apk_package] 185 if options.target == 'Release': 186 args.append('--release') 187 188 RunCmd(['build/android/adb_install_apk.py'] + args, halt_on_failure=True) 189 190 191def RunInstrumentationSuite(options, test, flunk_on_failure=True, 192 python_only=False, official_build=False): 193 """Manages an invocation of test_runner.py for instrumentation tests. 194 195 Args: 196 options: options object 197 test: An I_TEST namedtuple 198 flunk_on_failure: Flunk the step if tests fail. 199 Python: Run only host driven Python tests. 200 official_build: Run official-build tests. 201 """ 202 bb_annotations.PrintNamedStep('%s_instrumentation_tests' % test.name.lower()) 203 204 if test.apk: 205 InstallApk(options, test) 206 args = ['--test-apk', test.test_apk, '--verbose'] 207 if test.test_data: 208 args.extend(['--test_data', test.test_data]) 209 if options.target == 'Release': 210 args.append('--release') 211 if options.asan: 212 args.append('--tool=asan') 213 if options.flakiness_server: 214 args.append('--flakiness-dashboard-server=%s' % 215 options.flakiness_server) 216 if options.coverage_bucket: 217 args.append('--coverage-dir=%s' % options.coverage_dir) 218 if test.host_driven_root: 219 args.append('--host-driven-root=%s' % test.host_driven_root) 220 if test.annotation: 221 args.extend(['-A', test.annotation]) 222 if test.exclude_annotation: 223 args.extend(['-E', test.exclude_annotation]) 224 if test.extra_flags: 225 args.extend(test.extra_flags) 226 if python_only: 227 args.append('-p') 228 if official_build: 229 # The option needs to be assigned 'True' as it does not have an action 230 # associated with it. 231 args.append('--official-build') 232 233 RunCmd(['build/android/test_runner.py', 'instrumentation'] + args, 234 flunk_on_failure=flunk_on_failure) 235 236 237def RunWebkitLint(target): 238 """Lint WebKit's TestExpectation files.""" 239 bb_annotations.PrintNamedStep('webkit_lint') 240 RunCmd([SrcPath('webkit/tools/layout_tests/run_webkit_tests.py'), 241 '--lint-test-files', 242 '--chromium', 243 '--target', target]) 244 245 246def RunWebkitLayoutTests(options): 247 """Run layout tests on an actual device.""" 248 bb_annotations.PrintNamedStep('webkit_tests') 249 cmd_args = [ 250 '--no-show-results', 251 '--no-new-test-results', 252 '--full-results-html', 253 '--clobber-old-results', 254 '--exit-after-n-failures', '5000', 255 '--exit-after-n-crashes-or-timeouts', '100', 256 '--debug-rwt-logging', 257 '--results-directory', '../layout-test-results', 258 '--target', options.target, 259 '--builder-name', options.build_properties.get('buildername', ''), 260 '--build-number', str(options.build_properties.get('buildnumber', '')), 261 '--master-name', 'ChromiumWebkit', # TODO: Get this from the cfg. 262 '--build-name', options.build_properties.get('buildername', ''), 263 '--platform=android'] 264 265 for flag in 'test_results_server', 'driver_name', 'additional_drt_flag': 266 if flag in options.factory_properties: 267 cmd_args.extend(['--%s' % flag.replace('_', '-'), 268 options.factory_properties.get(flag)]) 269 270 for f in options.factory_properties.get('additional_expectations', []): 271 cmd_args.extend( 272 ['--additional-expectations=%s' % os.path.join(CHROME_SRC_DIR, *f)]) 273 274 # TODO(dpranke): Remove this block after 275 # https://codereview.chromium.org/12927002/ lands. 276 for f in options.factory_properties.get('additional_expectations_files', []): 277 cmd_args.extend( 278 ['--additional-expectations=%s' % os.path.join(CHROME_SRC_DIR, *f)]) 279 280 exit_code = RunCmd([SrcPath('webkit/tools/layout_tests/run_webkit_tests.py')] 281 + cmd_args) 282 if exit_code == 255: # test_run_results.UNEXPECTED_ERROR_EXIT_STATUS 283 bb_annotations.PrintMsg('?? (crashed or hung)') 284 elif exit_code == 254: # test_run_results.NO_DEVICES_EXIT_STATUS 285 bb_annotations.PrintMsg('?? (no devices found)') 286 elif exit_code == 253: # test_run_results.NO_TESTS_EXIT_STATUS 287 bb_annotations.PrintMsg('?? (no tests found)') 288 else: 289 full_results_path = os.path.join('..', 'layout-test-results', 290 'full_results.json') 291 if os.path.exists(full_results_path): 292 full_results = json.load(open(full_results_path)) 293 unexpected_passes, unexpected_failures, unexpected_flakes = ( 294 _ParseLayoutTestResults(full_results)) 295 if unexpected_failures: 296 _PrintDashboardLink('failed', unexpected_failures, 297 max_tests=25) 298 elif unexpected_passes: 299 _PrintDashboardLink('unexpected passes', unexpected_passes, 300 max_tests=10) 301 if unexpected_flakes: 302 _PrintDashboardLink('unexpected flakes', unexpected_flakes, 303 max_tests=10) 304 305 if exit_code == 0 and (unexpected_passes or unexpected_flakes): 306 # If exit_code != 0, RunCmd() will have already printed an error. 307 bb_annotations.PrintWarning() 308 else: 309 bb_annotations.PrintError() 310 bb_annotations.PrintMsg('?? (results missing)') 311 312 if options.factory_properties.get('archive_webkit_results', False): 313 bb_annotations.PrintNamedStep('archive_webkit_results') 314 base = 'https://storage.googleapis.com/chromium-layout-test-archives' 315 builder_name = options.build_properties.get('buildername', '') 316 build_number = str(options.build_properties.get('buildnumber', '')) 317 results_link = '%s/%s/%s/layout-test-results/results.html' % ( 318 base, EscapeBuilderName(builder_name), build_number) 319 bb_annotations.PrintLink('results', results_link) 320 bb_annotations.PrintLink('(zip)', '%s/%s/%s/layout-test-results.zip' % ( 321 base, EscapeBuilderName(builder_name), build_number)) 322 gs_bucket = 'gs://chromium-layout-test-archives' 323 RunCmd([os.path.join(SLAVE_SCRIPTS_DIR, 'chromium', 324 'archive_layout_test_results.py'), 325 '--results-dir', '../../layout-test-results', 326 '--build-number', build_number, 327 '--builder-name', builder_name, 328 '--gs-bucket', gs_bucket], 329 cwd=DIR_BUILD_ROOT) 330 331 332def _ParseLayoutTestResults(results): 333 """Extract the failures from the test run.""" 334 # Cloned from third_party/WebKit/Tools/Scripts/print-json-test-results 335 tests = _ConvertTrieToFlatPaths(results['tests']) 336 failures = {} 337 flakes = {} 338 passes = {} 339 for (test, result) in tests.iteritems(): 340 if result.get('is_unexpected'): 341 actual_results = result['actual'].split() 342 expected_results = result['expected'].split() 343 if len(actual_results) > 1: 344 # We report the first failure type back, even if the second 345 # was more severe. 346 if actual_results[1] in expected_results: 347 flakes[test] = actual_results[0] 348 else: 349 failures[test] = actual_results[0] 350 elif actual_results[0] == 'PASS': 351 passes[test] = result 352 else: 353 failures[test] = actual_results[0] 354 355 return (passes, failures, flakes) 356 357 358def _ConvertTrieToFlatPaths(trie, prefix=None): 359 """Flatten the trie of failures into a list.""" 360 # Cloned from third_party/WebKit/Tools/Scripts/print-json-test-results 361 result = {} 362 for name, data in trie.iteritems(): 363 if prefix: 364 name = prefix + '/' + name 365 366 if len(data) and 'actual' not in data and 'expected' not in data: 367 result.update(_ConvertTrieToFlatPaths(data, name)) 368 else: 369 result[name] = data 370 371 return result 372 373 374def _PrintDashboardLink(link_text, tests, max_tests): 375 """Add a link to the flakiness dashboard in the step annotations.""" 376 if len(tests) > max_tests: 377 test_list_text = ' '.join(tests[:max_tests]) + ' and more' 378 else: 379 test_list_text = ' '.join(tests) 380 381 dashboard_base = ('http://test-results.appspot.com' 382 '/dashboards/flakiness_dashboard.html#' 383 'master=ChromiumWebkit&tests=') 384 385 bb_annotations.PrintLink('%d %s: %s' % 386 (len(tests), link_text, test_list_text), 387 dashboard_base + ','.join(tests)) 388 389 390def EscapeBuilderName(builder_name): 391 return re.sub('[ ()]', '_', builder_name) 392 393 394def SpawnLogcatMonitor(): 395 shutil.rmtree(LOGCAT_DIR, ignore_errors=True) 396 bb_utils.SpawnCmd([ 397 os.path.join(CHROME_SRC_DIR, 'build', 'android', 'adb_logcat_monitor.py'), 398 LOGCAT_DIR]) 399 400 # Wait for logcat_monitor to pull existing logcat 401 RunCmd(['sleep', '5']) 402 403 404def ProvisionDevices(options): 405 bb_annotations.PrintNamedStep('provision_devices') 406 407 if not bb_utils.TESTING: 408 # Restart adb to work around bugs, sleep to wait for usb discovery. 409 device_utils.RestartServer() 410 RunCmd(['sleep', '1']) 411 provision_cmd = ['build/android/provision_devices.py', '-t', options.target] 412 if options.auto_reconnect: 413 provision_cmd.append('--auto-reconnect') 414 RunCmd(provision_cmd) 415 416 417def DeviceStatusCheck(options): 418 bb_annotations.PrintNamedStep('device_status_check') 419 cmd = ['build/android/buildbot/bb_device_status_check.py'] 420 if options.restart_usb: 421 cmd.append('--restart-usb') 422 RunCmd(cmd, halt_on_failure=True) 423 424 425def GetDeviceSetupStepCmds(): 426 return [ 427 ('device_status_check', DeviceStatusCheck), 428 ('provision_devices', ProvisionDevices), 429 ] 430 431 432def RunUnitTests(options): 433 suites = gtest_config.STABLE_TEST_SUITES 434 if options.asan: 435 suites = [s for s in suites 436 if s not in gtest_config.ASAN_EXCLUDED_TEST_SUITES] 437 RunTestSuites(options, suites) 438 439 440def RunInstrumentationTests(options): 441 for test in INSTRUMENTATION_TESTS.itervalues(): 442 RunInstrumentationSuite(options, test) 443 444 445def RunWebkitTests(options): 446 RunTestSuites(options, ['webkit_unit_tests', 'blink_heap_unittests']) 447 RunWebkitLint(options.target) 448 449 450def RunWebRTCChromiumTests(options): 451 RunTestSuites(options, gtest_config.WEBRTC_CHROMIUM_TEST_SUITES) 452 453 454def RunWebRTCNativeTests(options): 455 RunTestSuites(options, gtest_config.WEBRTC_NATIVE_TEST_SUITES) 456 457 458def RunGPUTests(options): 459 revision = _GetRevision(options) 460 builder_name = options.build_properties.get('buildername', 'noname') 461 462 bb_annotations.PrintNamedStep('pixel_tests') 463 RunCmd(['content/test/gpu/run_gpu_test.py', 464 'pixel', 465 '--browser', 466 'android-content-shell', 467 '--build-revision', 468 str(revision), 469 '--upload-refimg-to-cloud-storage', 470 '--refimg-cloud-storage-bucket', 471 'chromium-gpu-archive/reference-images', 472 '--os-type', 473 'android', 474 '--test-machine-name', 475 EscapeBuilderName(builder_name)]) 476 477 bb_annotations.PrintNamedStep('webgl_conformance_tests') 478 RunCmd(['content/test/gpu/run_gpu_test.py', 479 '--browser=android-content-shell', 'webgl_conformance', 480 '--webgl-conformance-version=1.0.1']) 481 482 bb_annotations.PrintNamedStep('gpu_rasterization_tests') 483 RunCmd(['content/test/gpu/run_gpu_test.py', 484 'gpu_rasterization', 485 '--browser', 486 'android-content-shell', 487 '--build-revision', 488 str(revision), 489 '--test-machine-name', 490 EscapeBuilderName(builder_name)]) 491 492 493def GetTestStepCmds(): 494 return [ 495 ('chromedriver', RunChromeDriverTests), 496 ('gpu', RunGPUTests), 497 ('mojo', RunMojoTests), 498 ('telemetry_perf_unittests', RunTelemetryPerfUnitTests), 499 ('unit', RunUnitTests), 500 ('ui', RunInstrumentationTests), 501 ('webkit', RunWebkitTests), 502 ('webkit_layout', RunWebkitLayoutTests), 503 ('webrtc_chromium', RunWebRTCChromiumTests), 504 ('webrtc_native', RunWebRTCNativeTests), 505 ] 506 507 508def MakeGSPath(options, gs_base_dir): 509 revision = _GetRevision(options) 510 bot_id = options.build_properties.get('buildername', 'testing') 511 randhash = hashlib.sha1(str(random.random())).hexdigest() 512 gs_path = '%s/%s/%s/%s' % (gs_base_dir, bot_id, revision, randhash) 513 # remove double slashes, happens with blank revisions and confuses gsutil 514 gs_path = re.sub('/+', '/', gs_path) 515 return gs_path 516 517def UploadHTML(options, gs_base_dir, dir_to_upload, link_text, 518 link_rel_path='index.html', gs_url=GS_URL): 519 """Uploads directory at |dir_to_upload| to Google Storage and output a link. 520 521 Args: 522 options: Command line options. 523 gs_base_dir: The Google Storage base directory (e.g. 524 'chromium-code-coverage/java') 525 dir_to_upload: Absolute path to the directory to be uploaded. 526 link_text: Link text to be displayed on the step. 527 link_rel_path: Link path relative to |dir_to_upload|. 528 gs_url: Google storage URL. 529 """ 530 gs_path = MakeGSPath(options, gs_base_dir) 531 RunCmd([bb_utils.GSUTIL_PATH, 'cp', '-R', dir_to_upload, 'gs://%s' % gs_path]) 532 bb_annotations.PrintLink(link_text, 533 '%s/%s/%s' % (gs_url, gs_path, link_rel_path)) 534 535 536def GenerateJavaCoverageReport(options): 537 """Generates an HTML coverage report using EMMA and uploads it.""" 538 bb_annotations.PrintNamedStep('java_coverage_report') 539 540 coverage_html = os.path.join(options.coverage_dir, 'coverage_html') 541 RunCmd(['build/android/generate_emma_html.py', 542 '--coverage-dir', options.coverage_dir, 543 '--metadata-dir', os.path.join(CHROME_OUT_DIR, options.target), 544 '--cleanup', 545 '--output', os.path.join(coverage_html, 'index.html')]) 546 return coverage_html 547 548 549def LogcatDump(options): 550 # Print logcat, kill logcat monitor 551 bb_annotations.PrintNamedStep('logcat_dump') 552 logcat_file = os.path.join(CHROME_OUT_DIR, options.target, 'full_log.txt') 553 RunCmd([SrcPath('build' , 'android', 'adb_logcat_printer.py'), 554 '--output-path', logcat_file, LOGCAT_DIR]) 555 gs_path = MakeGSPath(options, 'chromium-android/logcat_dumps') 556 RunCmd([bb_utils.GSUTIL_PATH, 'cp', '-z', 'txt', logcat_file, 557 'gs://%s' % gs_path]) 558 bb_annotations.PrintLink('logcat dump', '%s/%s' % (GS_AUTH_URL, gs_path)) 559 560 561def RunStackToolSteps(options): 562 """Run stack tool steps. 563 564 Stack tool is run for logcat dump, optionally for ASAN. 565 """ 566 bb_annotations.PrintNamedStep('Run stack tool with logcat dump') 567 logcat_file = os.path.join(CHROME_OUT_DIR, options.target, 'full_log.txt') 568 RunCmd([os.path.join(CHROME_SRC_DIR, 'third_party', 'android_platform', 569 'development', 'scripts', 'stack'), 570 '--more-info', logcat_file]) 571 if options.asan_symbolize: 572 bb_annotations.PrintNamedStep('Run stack tool for ASAN') 573 RunCmd([ 574 os.path.join(CHROME_SRC_DIR, 'build', 'android', 'asan_symbolize.py'), 575 '-l', logcat_file]) 576 577 578def GenerateTestReport(options): 579 bb_annotations.PrintNamedStep('test_report') 580 for report in glob.glob( 581 os.path.join(CHROME_OUT_DIR, options.target, 'test_logs', '*.log')): 582 RunCmd(['cat', report]) 583 os.remove(report) 584 585 586def MainTestWrapper(options): 587 try: 588 # Spawn logcat monitor 589 SpawnLogcatMonitor() 590 591 # Run all device setup steps 592 for _, cmd in GetDeviceSetupStepCmds(): 593 cmd(options) 594 595 if options.install: 596 test_obj = INSTRUMENTATION_TESTS[options.install] 597 InstallApk(options, test_obj, print_step=True) 598 599 if options.test_filter: 600 bb_utils.RunSteps(options.test_filter, GetTestStepCmds(), options) 601 602 if options.coverage_bucket: 603 coverage_html = GenerateJavaCoverageReport(options) 604 UploadHTML(options, '%s/java' % options.coverage_bucket, coverage_html, 605 'Coverage Report') 606 shutil.rmtree(coverage_html, ignore_errors=True) 607 608 if options.experimental: 609 RunTestSuites(options, gtest_config.EXPERIMENTAL_TEST_SUITES) 610 611 finally: 612 # Run all post test steps 613 LogcatDump(options) 614 if not options.disable_stack_tool: 615 RunStackToolSteps(options) 616 GenerateTestReport(options) 617 # KillHostHeartbeat() has logic to check if heartbeat process is running, 618 # and kills only if it finds the process is running on the host. 619 provision_devices.KillHostHeartbeat() 620 621 622def GetDeviceStepsOptParser(): 623 parser = bb_utils.GetParser() 624 parser.add_option('--experimental', action='store_true', 625 help='Run experiemental tests') 626 parser.add_option('-f', '--test-filter', metavar='<filter>', default=[], 627 action='append', 628 help=('Run a test suite. Test suites: "%s"' % 629 '", "'.join(VALID_TESTS))) 630 parser.add_option('--gtest-filter', 631 help='Filter for running a subset of tests of a gtest test') 632 parser.add_option('--asan', action='store_true', help='Run tests with asan.') 633 parser.add_option('--install', metavar='<apk name>', 634 help='Install an apk by name') 635 parser.add_option('--no-reboot', action='store_true', 636 help='Do not reboot devices during provisioning.') 637 parser.add_option('--coverage-bucket', 638 help=('Bucket name to store coverage results. Coverage is ' 639 'only run if this is set.')) 640 parser.add_option('--restart-usb', action='store_true', 641 help='Restart usb ports before device status check.') 642 parser.add_option( 643 '--flakiness-server', 644 help=('The flakiness dashboard server to which the results should be ' 645 'uploaded.')) 646 parser.add_option( 647 '--auto-reconnect', action='store_true', 648 help='Push script to device which restarts adbd on disconnections.') 649 parser.add_option( 650 '--logcat-dump-output', 651 help='The logcat dump output will be "tee"-ed into this file') 652 # During processing perf bisects, a seperate working directory created under 653 # which builds are produced. Therefore we should look for relevent output 654 # file under this directory.(/b/build/slave/<slave_name>/build/bisect/src/out) 655 parser.add_option( 656 '--chrome-output-dir', 657 help='Chrome output directory to be used while bisecting.') 658 659 parser.add_option('--disable-stack-tool', action='store_true', 660 help='Do not run stack tool.') 661 parser.add_option('--asan-symbolize', action='store_true', 662 help='Run stack tool for ASAN') 663 return parser 664 665 666def main(argv): 667 parser = GetDeviceStepsOptParser() 668 options, args = parser.parse_args(argv[1:]) 669 670 if args: 671 return sys.exit('Unused args %s' % args) 672 673 unknown_tests = set(options.test_filter) - VALID_TESTS 674 if unknown_tests: 675 return sys.exit('Unknown tests %s' % list(unknown_tests)) 676 677 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) 678 679 if options.chrome_output_dir: 680 global CHROME_OUT_DIR 681 global LOGCAT_DIR 682 CHROME_OUT_DIR = options.chrome_output_dir 683 LOGCAT_DIR = os.path.join(CHROME_OUT_DIR, 'logcat') 684 685 if options.coverage_bucket: 686 setattr(options, 'coverage_dir', 687 os.path.join(CHROME_OUT_DIR, options.target, 'coverage')) 688 689 MainTestWrapper(options) 690 691 692if __name__ == '__main__': 693 sys.exit(main(sys.argv)) 694