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.
19 sys
.path
.append(os
.path
.join(os
.path
.dirname(__file__
), '..'))
20 import provision_devices
21 from devil
.android
import device_utils
22 from pylib
import constants
23 from pylib
.gtest
import gtest_config
25 CHROME_SRC_DIR
= bb_utils
.CHROME_SRC
26 DIR_BUILD_ROOT
= os
.path
.dirname(CHROME_SRC_DIR
)
27 CHROME_OUT_DIR
= bb_utils
.CHROME_OUT_DIR
28 BLINK_SCRIPTS_DIR
= 'third_party/WebKit/Tools/Scripts'
30 SLAVE_SCRIPTS_DIR
= os
.path
.join(bb_utils
.BB_BUILD_DIR
, 'scripts', 'slave')
31 LOGCAT_DIR
= os
.path
.join(bb_utils
.CHROME_OUT_DIR
, 'logcat')
32 GS_URL
= 'https://storage.googleapis.com'
33 GS_AUTH_URL
= 'https://storage.cloud.google.com'
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.
44 I_TEST
= collections
.namedtuple('InstrumentationTest', [
45 'name', 'apk', 'apk_package', 'test_apk', 'test_data', 'isolate_file_path',
46 'host_driven_root', 'annotation', 'exclude_annotation', 'extra_flags'])
50 return os
.path
.join(CHROME_SRC_DIR
, *path
)
53 def I(name
, apk
, apk_package
, test_apk
, test_data
, isolate_file_path
=None,
54 host_driven_root
=None, annotation
=None, exclude_annotation
=None,
56 return I_TEST(name
, apk
, apk_package
, test_apk
, test_data
, isolate_file_path
,
57 host_driven_root
, annotation
, exclude_annotation
, extra_flags
)
59 INSTRUMENTATION_TESTS
= dict((suite
.name
, suite
) for suite
in [
62 'org.chromium.content_shell_apk',
64 'content:content/test/data/android/device_files',
65 isolate_file_path
='content/content_shell_test_apk.isolate'),
68 'org.chromium.android_webview.shell',
70 'webview:android_webview/test/data/device_files',
71 isolate_file_path
='android_webview/android_webview_test_apk.isolate'),
73 'ChromeSyncShell.apk',
74 'org.chromium.chrome.browser.sync',
75 'ChromeSyncShellTest',
79 InstallablePackage
= collections
.namedtuple('InstallablePackage', [
80 'name', 'apk', 'apk_package'])
82 INSTALLABLE_PACKAGES
= dict((package
.name
, package
) for package
in (
83 [InstallablePackage(i
.name
, i
.apk
, i
.apk_package
)
84 for i
in INSTRUMENTATION_TESTS
.itervalues()] +
85 [InstallablePackage('ChromeDriverWebViewShell',
86 'ChromeDriverWebViewShell.apk',
87 'org.chromium.chromedriver_webview_shell')]))
92 'components_browsertests',
103 RunCmd
= bb_utils
.RunCmd
106 def _GetRevision(options
):
107 """Get the SVN revision number.
110 options: options object.
115 revision
= options
.build_properties
.get('got_revision')
117 revision
= options
.build_properties
.get('revision', 'testing')
121 def _RunTest(options
, cmd
, suite
):
122 """Run test command with runtest.py.
125 options: options object.
126 cmd: the command to run.
129 property_args
= bb_utils
.EncodeProperties(options
)
130 args
= [os
.path
.join(SLAVE_SCRIPTS_DIR
, 'runtest.py')] + property_args
131 args
+= ['--test-platform', 'android']
132 if options
.factory_properties
.get('generate_gtest_json'):
133 args
.append('--generate-json-file')
134 args
+= ['-o', 'gtest-results/%s' % suite
,
135 '--annotate', 'gtest',
136 '--build-number', str(options
.build_properties
.get('buildnumber',
138 '--builder-name', options
.build_properties
.get('buildername', '')]
139 if options
.target
== 'Release':
140 args
+= ['--target', 'Release']
142 args
+= ['--target', 'Debug']
143 if options
.flakiness_server
:
144 args
+= ['--flakiness-dashboard-server=%s' %
145 options
.flakiness_server
]
147 RunCmd(args
, cwd
=DIR_BUILD_ROOT
)
150 def RunTestSuites(options
, suites
, suites_options
=None):
151 """Manages an invocation of test_runner.py for gtests.
154 options: options object.
155 suites: List of suite names to run.
156 suites_options: Command line options dictionary for particular suites.
158 {'content_browsertests', ['--num_retries=1', '--release']}
159 will add the options only to content_browsertests.
162 if not suites_options
:
166 if options
.target
== 'Release':
167 args
.append('--release')
169 args
.append('--tool=asan')
170 if options
.gtest_filter
:
171 args
.append('--gtest-filter=%s' % options
.gtest_filter
)
174 bb_annotations
.PrintNamedStep(suite
)
176 cmd
+= suites_options
.get(suite
, [])
177 if suite
== 'content_browsertests' or suite
== 'components_browsertests':
178 cmd
.append('--num_retries=1')
179 _RunTest(options
, cmd
, suite
)
182 def RunJunitSuite(suite
):
183 bb_annotations
.PrintNamedStep(suite
)
184 RunCmd(['build/android/test_runner.py', 'junit', '-s', suite
])
187 def RunChromeDriverTests(options
):
188 """Run all the steps for running chromedriver tests."""
189 bb_annotations
.PrintNamedStep('chromedriver_annotation')
190 RunCmd(['chrome/test/chromedriver/run_buildbot_steps.py',
191 '--android-packages=%s,%s,%s' %
194 'chromedriver_webview_shell'),
195 '--revision=%s' % _GetRevision(options
),
199 def InstallApk(options
, test
, print_step
=False):
200 """Install an apk to all phones.
203 options: options object
204 test: An I_TEST namedtuple
205 print_step: Print a buildbot step
208 bb_annotations
.PrintNamedStep('install_%s' % test
.name
.lower())
210 args
= ['--apk_package', test
.apk_package
]
211 if options
.target
== 'Release':
212 args
.append('--release')
213 args
.append(test
.apk
)
215 RunCmd(['build/android/adb_install_apk.py'] + args
, halt_on_failure
=True)
218 def RunInstrumentationSuite(options
, test
, flunk_on_failure
=True,
219 python_only
=False, official_build
=False):
220 """Manages an invocation of test_runner.py for instrumentation tests.
223 options: options object
224 test: An I_TEST namedtuple
225 flunk_on_failure: Flunk the step if tests fail.
226 Python: Run only host driven Python tests.
227 official_build: Run official-build tests.
229 bb_annotations
.PrintNamedStep('%s_instrumentation_tests' % test
.name
.lower())
232 InstallApk(options
, test
)
233 args
= ['--test-apk', test
.test_apk
, '--verbose']
235 args
.extend(['--test_data', test
.test_data
])
236 if options
.target
== 'Release':
237 args
.append('--release')
239 args
.append('--tool=asan')
240 if options
.flakiness_server
:
241 args
.append('--flakiness-dashboard-server=%s' %
242 options
.flakiness_server
)
243 if options
.coverage_bucket
:
244 args
.append('--coverage-dir=%s' % options
.coverage_dir
)
245 if test
.isolate_file_path
:
246 args
.append('--isolate-file-path=%s' % test
.isolate_file_path
)
247 if test
.host_driven_root
:
248 args
.append('--host-driven-root=%s' % test
.host_driven_root
)
250 args
.extend(['-A', test
.annotation
])
251 if test
.exclude_annotation
:
252 args
.extend(['-E', test
.exclude_annotation
])
254 args
.extend(test
.extra_flags
)
258 # The option needs to be assigned 'True' as it does not have an action
259 # associated with it.
260 args
.append('--official-build')
262 RunCmd(['build/android/test_runner.py', 'instrumentation'] + args
,
263 flunk_on_failure
=flunk_on_failure
)
267 """Lint WebKit's TestExpectation files."""
268 bb_annotations
.PrintNamedStep('webkit_lint')
269 RunCmd([SrcPath(os
.path
.join(BLINK_SCRIPTS_DIR
, 'lint-test-expectations'))])
272 def RunWebkitLayoutTests(options
):
273 """Run layout tests on an actual device."""
274 bb_annotations
.PrintNamedStep('webkit_tests')
277 '--no-new-test-results',
278 '--full-results-html',
279 '--clobber-old-results',
280 '--exit-after-n-failures', '5000',
281 '--exit-after-n-crashes-or-timeouts', '100',
282 '--debug-rwt-logging',
283 '--results-directory', '../layout-test-results',
284 '--target', options
.target
,
285 '--builder-name', options
.build_properties
.get('buildername', ''),
286 '--build-number', str(options
.build_properties
.get('buildnumber', '')),
287 '--master-name', 'ChromiumWebkit', # TODO: Get this from the cfg.
288 '--build-name', options
.build_properties
.get('buildername', ''),
289 '--platform=android']
291 for flag
in 'test_results_server', 'driver_name', 'additional_driver_flag':
292 if flag
in options
.factory_properties
:
293 cmd_args
.extend(['--%s' % flag
.replace('_', '-'),
294 options
.factory_properties
.get(flag
)])
296 for f
in options
.factory_properties
.get('additional_expectations', []):
298 ['--additional-expectations=%s' % os
.path
.join(CHROME_SRC_DIR
, *f
)])
300 # TODO(dpranke): Remove this block after
301 # https://codereview.chromium.org/12927002/ lands.
302 for f
in options
.factory_properties
.get('additional_expectations_files', []):
304 ['--additional-expectations=%s' % os
.path
.join(CHROME_SRC_DIR
, *f
)])
307 [SrcPath(os
.path
.join(BLINK_SCRIPTS_DIR
, 'run-webkit-tests'))] + cmd_args
)
308 if exit_code
== 255: # test_run_results.UNEXPECTED_ERROR_EXIT_STATUS
309 bb_annotations
.PrintMsg('?? (crashed or hung)')
310 elif exit_code
== 254: # test_run_results.NO_DEVICES_EXIT_STATUS
311 bb_annotations
.PrintMsg('?? (no devices found)')
312 elif exit_code
== 253: # test_run_results.NO_TESTS_EXIT_STATUS
313 bb_annotations
.PrintMsg('?? (no tests found)')
315 full_results_path
= os
.path
.join('..', 'layout-test-results',
317 if os
.path
.exists(full_results_path
):
318 full_results
= json
.load(open(full_results_path
))
319 unexpected_passes
, unexpected_failures
, unexpected_flakes
= (
320 _ParseLayoutTestResults(full_results
))
321 if unexpected_failures
:
322 _PrintDashboardLink('failed', unexpected_failures
.keys(),
324 elif unexpected_passes
:
325 _PrintDashboardLink('unexpected passes', unexpected_passes
.keys(),
327 if unexpected_flakes
:
328 _PrintDashboardLink('unexpected flakes', unexpected_flakes
.keys(),
331 if exit_code
== 0 and (unexpected_passes
or unexpected_flakes
):
332 # If exit_code != 0, RunCmd() will have already printed an error.
333 bb_annotations
.PrintWarning()
335 bb_annotations
.PrintError()
336 bb_annotations
.PrintMsg('?? (results missing)')
338 if options
.factory_properties
.get('archive_webkit_results', False):
339 bb_annotations
.PrintNamedStep('archive_webkit_results')
340 base
= 'https://storage.googleapis.com/chromium-layout-test-archives'
341 builder_name
= options
.build_properties
.get('buildername', '')
342 build_number
= str(options
.build_properties
.get('buildnumber', ''))
343 results_link
= '%s/%s/%s/layout-test-results/results.html' % (
344 base
, EscapeBuilderName(builder_name
), build_number
)
345 bb_annotations
.PrintLink('results', results_link
)
346 bb_annotations
.PrintLink('(zip)', '%s/%s/%s/layout-test-results.zip' % (
347 base
, EscapeBuilderName(builder_name
), build_number
))
348 gs_bucket
= 'gs://chromium-layout-test-archives'
349 RunCmd([os
.path
.join(SLAVE_SCRIPTS_DIR
, 'chromium',
350 'archive_layout_test_results.py'),
351 '--results-dir', '../../layout-test-results',
352 '--build-number', build_number
,
353 '--builder-name', builder_name
,
354 '--gs-bucket', gs_bucket
],
358 def _ParseLayoutTestResults(results
):
359 """Extract the failures from the test run."""
360 # Cloned from third_party/WebKit/Tools/Scripts/print-json-test-results
361 tests
= _ConvertTrieToFlatPaths(results
['tests'])
365 for (test
, result
) in tests
.iteritems():
366 if result
.get('is_unexpected'):
367 actual_results
= result
['actual'].split()
368 expected_results
= result
['expected'].split()
369 if len(actual_results
) > 1:
370 # We report the first failure type back, even if the second
372 if actual_results
[1] in expected_results
:
373 flakes
[test
] = actual_results
[0]
375 failures
[test
] = actual_results
[0]
376 elif actual_results
[0] == 'PASS':
377 passes
[test
] = result
379 failures
[test
] = actual_results
[0]
381 return (passes
, failures
, flakes
)
384 def _ConvertTrieToFlatPaths(trie
, prefix
=None):
385 """Flatten the trie of failures into a list."""
386 # Cloned from third_party/WebKit/Tools/Scripts/print-json-test-results
388 for name
, data
in trie
.iteritems():
390 name
= prefix
+ '/' + name
392 if len(data
) and 'actual' not in data
and 'expected' not in data
:
393 result
.update(_ConvertTrieToFlatPaths(data
, name
))
400 def _PrintDashboardLink(link_text
, tests
, max_tests
):
401 """Add a link to the flakiness dashboard in the step annotations."""
402 if len(tests
) > max_tests
:
403 test_list_text
= ' '.join(tests
[:max_tests
]) + ' and more'
405 test_list_text
= ' '.join(tests
)
407 dashboard_base
= ('http://test-results.appspot.com'
408 '/dashboards/flakiness_dashboard.html#'
409 'master=ChromiumWebkit&tests=')
411 bb_annotations
.PrintLink('%d %s: %s' %
412 (len(tests
), link_text
, test_list_text
),
413 dashboard_base
+ ','.join(tests
))
416 def EscapeBuilderName(builder_name
):
417 return re
.sub('[ ()]', '_', builder_name
)
420 def SpawnLogcatMonitor():
421 shutil
.rmtree(LOGCAT_DIR
, ignore_errors
=True)
423 os
.path
.join(CHROME_SRC_DIR
, 'build', 'android', 'adb_logcat_monitor.py'),
426 # Wait for logcat_monitor to pull existing logcat
427 RunCmd(['sleep', '5'])
430 def ProvisionDevices(options
):
431 bb_annotations
.PrintNamedStep('provision_devices')
433 if not bb_utils
.TESTING
:
434 # Restart adb to work around bugs, sleep to wait for usb discovery.
435 device_utils
.RestartServer()
436 RunCmd(['sleep', '1'])
437 provision_cmd
= ['build/android/provision_devices.py', '-t', options
.target
]
438 if options
.auto_reconnect
:
439 provision_cmd
.append('--auto-reconnect')
440 if options
.skip_wipe
:
441 provision_cmd
.append('--skip-wipe')
442 if options
.disable_location
:
443 provision_cmd
.append('--disable-location')
444 RunCmd(provision_cmd
, halt_on_failure
=True)
447 def DeviceStatusCheck(options
):
448 bb_annotations
.PrintNamedStep('device_status_check')
449 cmd
= ['build/android/buildbot/bb_device_status_check.py']
450 if options
.restart_usb
:
451 cmd
.append('--restart-usb')
452 RunCmd(cmd
, halt_on_failure
=True)
455 def GetDeviceSetupStepCmds():
457 ('device_status_check', DeviceStatusCheck
),
458 ('provision_devices', ProvisionDevices
),
462 def RunUnitTests(options
):
463 suites
= gtest_config
.STABLE_TEST_SUITES
465 suites
= [s
for s
in suites
466 if s
not in gtest_config
.ASAN_EXCLUDED_TEST_SUITES
]
467 RunTestSuites(options
, suites
)
470 def RunInstrumentationTests(options
):
471 for test
in INSTRUMENTATION_TESTS
.itervalues():
472 RunInstrumentationSuite(options
, test
)
475 def RunWebkitTests(options
):
476 RunTestSuites(options
, ['webkit_unit_tests', 'blink_heap_unittests'])
480 def RunGPUTests(options
):
481 revision
= _GetRevision(options
)
482 builder_name
= options
.build_properties
.get('buildername', 'noname')
484 bb_annotations
.PrintNamedStep('pixel_tests')
485 RunCmd(['content/test/gpu/run_gpu_test.py',
488 'android-content-shell',
491 '--upload-refimg-to-cloud-storage',
492 '--refimg-cloud-storage-bucket',
493 'chromium-gpu-archive/reference-images',
496 '--test-machine-name',
497 EscapeBuilderName(builder_name
)])
499 bb_annotations
.PrintNamedStep('webgl_conformance_tests')
500 RunCmd(['content/test/gpu/run_gpu_test.py', '-v',
501 '--browser=android-content-shell', 'webgl_conformance',
502 '--webgl-conformance-version=1.0.1'])
504 bb_annotations
.PrintNamedStep('android_webview_webgl_conformance_tests')
505 RunCmd(['content/test/gpu/run_gpu_test.py', '-v',
506 '--browser=android-webview-shell', 'webgl_conformance',
507 '--webgl-conformance-version=1.0.1'])
509 bb_annotations
.PrintNamedStep('gpu_rasterization_tests')
510 RunCmd(['content/test/gpu/run_gpu_test.py',
511 'gpu_rasterization', '-v',
513 'android-content-shell',
516 '--test-machine-name',
517 EscapeBuilderName(builder_name
)])
520 def RunPythonUnitTests(_options
):
521 for suite
in constants
.PYTHON_UNIT_TEST_SUITES
:
522 bb_annotations
.PrintNamedStep(suite
)
523 RunCmd(['build/android/test_runner.py', 'python', '-s', suite
])
526 def GetTestStepCmds():
529 lambda _options
: RunJunitSuite('base_junit_tests')),
530 ('chromedriver', RunChromeDriverTests
),
531 ('components_browsertests',
532 lambda options
: RunTestSuites(options
, ['components_browsertests'])),
534 lambda options
: RunTestSuites(options
, ['gfx_unittests'])),
536 lambda options
: RunTestSuites(options
, ['gl_unittests'])),
537 ('gpu', RunGPUTests
),
538 ('python_unittests', RunPythonUnitTests
),
539 ('ui', RunInstrumentationTests
),
540 ('unit', RunUnitTests
),
541 ('webkit', RunWebkitTests
),
542 ('webkit_layout', RunWebkitLayoutTests
),
546 def MakeGSPath(options
, gs_base_dir
):
547 revision
= _GetRevision(options
)
548 bot_id
= options
.build_properties
.get('buildername', 'testing')
549 randhash
= hashlib
.sha1(str(random
.random())).hexdigest()
550 gs_path
= '%s/%s/%s/%s' % (gs_base_dir
, bot_id
, revision
, randhash
)
551 # remove double slashes, happens with blank revisions and confuses gsutil
552 gs_path
= re
.sub('/+', '/', gs_path
)
555 def UploadHTML(options
, gs_base_dir
, dir_to_upload
, link_text
,
556 link_rel_path
='index.html', gs_url
=GS_URL
):
557 """Uploads directory at |dir_to_upload| to Google Storage and output a link.
560 options: Command line options.
561 gs_base_dir: The Google Storage base directory (e.g.
562 'chromium-code-coverage/java')
563 dir_to_upload: Absolute path to the directory to be uploaded.
564 link_text: Link text to be displayed on the step.
565 link_rel_path: Link path relative to |dir_to_upload|.
566 gs_url: Google storage URL.
568 gs_path
= MakeGSPath(options
, gs_base_dir
)
569 RunCmd([bb_utils
.GSUTIL_PATH
, 'cp', '-R', dir_to_upload
, 'gs://%s' % gs_path
])
570 bb_annotations
.PrintLink(link_text
,
571 '%s/%s/%s' % (gs_url
, gs_path
, link_rel_path
))
574 def GenerateJavaCoverageReport(options
):
575 """Generates an HTML coverage report using EMMA and uploads it."""
576 bb_annotations
.PrintNamedStep('java_coverage_report')
578 coverage_html
= os
.path
.join(options
.coverage_dir
, 'coverage_html')
579 RunCmd(['build/android/generate_emma_html.py',
580 '--coverage-dir', options
.coverage_dir
,
581 '--metadata-dir', os
.path
.join(CHROME_OUT_DIR
, options
.target
),
583 '--output', os
.path
.join(coverage_html
, 'index.html')])
587 def LogcatDump(options
):
588 # Print logcat, kill logcat monitor
589 bb_annotations
.PrintNamedStep('logcat_dump')
590 logcat_file
= os
.path
.join(CHROME_OUT_DIR
, options
.target
, 'full_log.txt')
591 RunCmd([SrcPath('build', 'android', 'adb_logcat_printer.py'),
592 '--output-path', logcat_file
, LOGCAT_DIR
])
593 gs_path
= MakeGSPath(options
, 'chromium-android/logcat_dumps')
594 RunCmd([bb_utils
.GSUTIL_PATH
, 'cp', '-z', 'txt', logcat_file
,
595 'gs://%s' % gs_path
])
596 bb_annotations
.PrintLink('logcat dump', '%s/%s' % (GS_AUTH_URL
, gs_path
))
599 def RunStackToolSteps(options
):
600 """Run stack tool steps.
602 Stack tool is run for logcat dump, optionally for ASAN.
604 bb_annotations
.PrintNamedStep('Run stack tool with logcat dump')
605 logcat_file
= os
.path
.join(CHROME_OUT_DIR
, options
.target
, 'full_log.txt')
606 RunCmd([os
.path
.join(CHROME_SRC_DIR
, 'third_party', 'android_platform',
607 'development', 'scripts', 'stack'),
608 '--more-info', logcat_file
])
609 if options
.asan_symbolize
:
610 bb_annotations
.PrintNamedStep('Run stack tool for ASAN')
612 os
.path
.join(CHROME_SRC_DIR
, 'build', 'android', 'asan_symbolize.py'),
616 def GenerateTestReport(options
):
617 bb_annotations
.PrintNamedStep('test_report')
618 for report
in glob
.glob(
619 os
.path
.join(CHROME_OUT_DIR
, options
.target
, 'test_logs', '*.log')):
620 RunCmd(['cat', report
])
624 def MainTestWrapper(options
):
626 # Spawn logcat monitor
629 # Run all device setup steps
630 for _
, cmd
in GetDeviceSetupStepCmds():
634 for i
in options
.install
:
635 install_obj
= INSTALLABLE_PACKAGES
[i
]
636 InstallApk(options
, install_obj
, print_step
=True)
638 if options
.test_filter
:
639 bb_utils
.RunSteps(options
.test_filter
, GetTestStepCmds(), options
)
641 if options
.coverage_bucket
:
642 coverage_html
= GenerateJavaCoverageReport(options
)
643 UploadHTML(options
, '%s/java' % options
.coverage_bucket
, coverage_html
,
645 shutil
.rmtree(coverage_html
, ignore_errors
=True)
647 if options
.experimental
:
648 RunTestSuites(options
, gtest_config
.EXPERIMENTAL_TEST_SUITES
)
651 # Run all post test steps
653 if not options
.disable_stack_tool
:
654 RunStackToolSteps(options
)
655 GenerateTestReport(options
)
656 # KillHostHeartbeat() has logic to check if heartbeat process is running,
657 # and kills only if it finds the process is running on the host.
658 provision_devices
.KillHostHeartbeat()
660 shutil
.rmtree(os
.path
.join(CHROME_OUT_DIR
, options
.target
),
664 def GetDeviceStepsOptParser():
665 parser
= bb_utils
.GetParser()
666 parser
.add_option('--experimental', action
='store_true',
667 help='Run experiemental tests')
668 parser
.add_option('-f', '--test-filter', metavar
='<filter>', default
=[],
670 help=('Run a test suite. Test suites: "%s"' %
671 '", "'.join(VALID_TESTS
)))
672 parser
.add_option('--gtest-filter',
673 help='Filter for running a subset of tests of a gtest test')
674 parser
.add_option('--asan', action
='store_true', help='Run tests with asan.')
675 parser
.add_option('--install', metavar
='<apk name>', action
="append",
676 help='Install an apk by name')
677 parser
.add_option('--no-reboot', action
='store_true',
678 help='Do not reboot devices during provisioning.')
679 parser
.add_option('--coverage-bucket',
680 help=('Bucket name to store coverage results. Coverage is '
681 'only run if this is set.'))
682 parser
.add_option('--restart-usb', action
='store_true',
683 help='Restart usb ports before device status check.')
685 '--flakiness-server',
686 help=('The flakiness dashboard server to which the results should be '
689 '--auto-reconnect', action
='store_true',
690 help='Push script to device which restarts adbd on disconnections.')
691 parser
.add_option('--skip-wipe', action
='store_true',
692 help='Do not wipe devices during provisioning.')
693 parser
.add_option('--disable-location', action
='store_true',
694 help='Disable location settings.')
696 '--logcat-dump-output',
697 help='The logcat dump output will be "tee"-ed into this file')
698 # During processing perf bisects, a seperate working directory created under
699 # which builds are produced. Therefore we should look for relevent output
700 # file under this directory.(/b/build/slave/<slave_name>/build/bisect/src/out)
702 '--chrome-output-dir',
703 help='Chrome output directory to be used while bisecting.')
705 parser
.add_option('--disable-stack-tool', action
='store_true',
706 help='Do not run stack tool.')
707 parser
.add_option('--asan-symbolize', action
='store_true',
708 help='Run stack tool for ASAN')
709 parser
.add_option('--cleanup', action
='store_true',
710 help='Delete out/<target> directory at the end of the run.')
715 parser
= GetDeviceStepsOptParser()
716 options
, args
= parser
.parse_args(argv
[1:])
719 return sys
.exit('Unused args %s' % args
)
721 unknown_tests
= set(options
.test_filter
) - VALID_TESTS
723 return sys
.exit('Unknown tests %s' % list(unknown_tests
))
725 setattr(options
, 'target', options
.factory_properties
.get('target', 'Debug'))
727 # pylint: disable=global-statement
728 if options
.chrome_output_dir
:
729 global CHROME_OUT_DIR
731 CHROME_OUT_DIR
= options
.chrome_output_dir
732 LOGCAT_DIR
= os
.path
.join(CHROME_OUT_DIR
, 'logcat')
734 if options
.coverage_bucket
:
735 setattr(options
, 'coverage_dir',
736 os
.path
.join(CHROME_OUT_DIR
, options
.target
, 'coverage'))
738 MainTestWrapper(options
)
741 if __name__
== '__main__':
742 sys
.exit(main(sys
.argv
))