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 pylib
import android_commands
22 from pylib
import constants
23 from pylib
.device
import device_utils
24 from pylib
.gtest
import gtest_config
26 CHROME_SRC_DIR
= bb_utils
.CHROME_SRC
27 DIR_BUILD_ROOT
= os
.path
.dirname(CHROME_SRC_DIR
)
28 CHROME_OUT_DIR
= bb_utils
.CHROME_OUT_DIR
29 BLINK_SCRIPTS_DIR
= 'third_party/WebKit/Tools/Scripts'
31 SLAVE_SCRIPTS_DIR
= os
.path
.join(bb_utils
.BB_BUILD_DIR
, 'scripts', 'slave')
32 LOGCAT_DIR
= os
.path
.join(bb_utils
.CHROME_OUT_DIR
, 'logcat')
33 GS_URL
= 'https://storage.googleapis.com'
34 GS_AUTH_URL
= 'https://storage.cloud.google.com'
36 # Describes an instrumation test suite:
37 # test: Name of test we're running.
38 # apk: apk to be installed.
39 # apk_package: package for the apk to be installed.
40 # test_apk: apk to run tests on.
41 # test_data: data folder in format destination:source.
42 # host_driven_root: The host-driven test root directory.
43 # annotation: Annotation of the tests to include.
44 # exclude_annotation: The annotation of the tests to exclude.
45 I_TEST
= collections
.namedtuple('InstrumentationTest', [
46 'name', 'apk', 'apk_package', 'test_apk', 'test_data', 'host_driven_root',
47 'annotation', 'exclude_annotation', 'extra_flags'])
51 return os
.path
.join(CHROME_SRC_DIR
, *path
)
54 def I(name
, apk
, apk_package
, test_apk
, test_data
, host_driven_root
=None,
55 annotation
=None, exclude_annotation
=None, extra_flags
=None):
56 return I_TEST(name
, apk
, apk_package
, test_apk
, test_data
, host_driven_root
,
57 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'),
67 'org.chromium.chrome.shell',
69 'chrome:chrome/test/data/android/device_files',
70 constants
.CHROME_SHELL_HOST_DRIVEN_DIR
),
73 'org.chromium.android_webview.shell',
75 'webview:android_webview/test/data/device_files'),
78 VALID_TESTS
= set(['chromedriver', 'chrome_proxy', 'gpu', 'mojo', 'sync',
79 'telemetry_perf_unittests', 'ui', 'unit', 'webkit',
82 RunCmd
= bb_utils
.RunCmd
85 def _GetRevision(options
):
86 """Get the SVN revision number.
89 options: options object.
94 revision
= options
.build_properties
.get('got_revision')
96 revision
= options
.build_properties
.get('revision', 'testing')
100 def _RunTest(options
, cmd
, suite
):
101 """Run test command with runtest.py.
104 options: options object.
105 cmd: the command to run.
108 property_args
= bb_utils
.EncodeProperties(options
)
109 args
= [os
.path
.join(SLAVE_SCRIPTS_DIR
, 'runtest.py')] + property_args
110 args
+= ['--test-platform', 'android']
111 if options
.factory_properties
.get('generate_gtest_json'):
112 args
.append('--generate-json-file')
113 args
+= ['-o', 'gtest-results/%s' % suite
,
114 '--annotate', 'gtest',
115 '--build-number', str(options
.build_properties
.get('buildnumber',
117 '--builder-name', options
.build_properties
.get('buildername', '')]
118 if options
.target
== 'Release':
119 args
+= ['--target', 'Release']
121 args
+= ['--target', 'Debug']
123 RunCmd(args
, cwd
=DIR_BUILD_ROOT
)
126 def RunTestSuites(options
, suites
, suites_options
=None):
127 """Manages an invocation of test_runner.py for gtests.
130 options: options object.
131 suites: List of suite names to run.
132 suites_options: Command line options dictionary for particular suites.
134 {'content_browsertests', ['--num_retries=1', '--release']}
135 will add the options only to content_browsertests.
138 if not suites_options
:
142 if options
.target
== 'Release':
143 args
.append('--release')
145 args
.append('--tool=asan')
146 if options
.gtest_filter
:
147 args
.append('--gtest-filter=%s' % options
.gtest_filter
)
150 bb_annotations
.PrintNamedStep(suite
)
152 cmd
+= suites_options
.get(suite
, [])
153 if suite
== 'content_browsertests':
154 cmd
.append('--num_retries=1')
155 _RunTest(options
, cmd
, suite
)
158 def RunChromeDriverTests(options
):
159 """Run all the steps for running chromedriver tests."""
160 bb_annotations
.PrintNamedStep('chromedriver_annotation')
161 RunCmd(['chrome/test/chromedriver/run_buildbot_steps.py',
162 '--android-packages=%s,%s,%s,%s' %
166 'chromedriver_webview_shell'),
167 '--revision=%s' % _GetRevision(options
),
170 def RunChromeProxyTests(options
):
171 """Run the chrome_proxy tests.
174 options: options object.
176 InstallApk(options
, INSTRUMENTATION_TESTS
['ChromeShell'], False)
177 args
= ['--browser', 'android-chrome-shell']
178 devices
= android_commands
.GetAttachedDevices()
180 args
= args
+ ['--device', devices
[0]]
181 bb_annotations
.PrintNamedStep('chrome_proxy')
182 RunCmd(['tools/chrome_proxy/run_tests'] + args
)
184 def RunChromeSyncShellTests(options
):
185 """Run the chrome sync shell tests"""
186 test
= I('ChromeSyncShell',
187 'ChromeSyncShell.apk',
188 'org.chromium.chrome.browser.sync',
189 'ChromeSyncShellTest.apk',
190 'chrome:chrome/test/data/android/device_files')
191 RunInstrumentationSuite(options
, test
)
193 def RunTelemetryPerfUnitTests(options
):
194 """Runs the telemetry perf unit tests.
197 options: options object.
199 InstallApk(options
, INSTRUMENTATION_TESTS
['ChromeShell'], False)
200 args
= ['--browser', 'android-chrome-shell']
201 devices
= android_commands
.GetAttachedDevices()
203 args
= args
+ ['--device', devices
[0]]
204 bb_annotations
.PrintNamedStep('telemetry_perf_unittests')
205 RunCmd(['tools/perf/run_tests'] + args
)
208 def RunMojoTests(options
):
209 """Runs the mojo unit tests.
212 options: options object.
216 'org.chromium.mojo.tests',
218 'bindings:mojo/public/interfaces/bindings/tests/data')
219 RunInstrumentationSuite(options
, test
)
222 def InstallApk(options
, test
, print_step
=False):
223 """Install an apk to all phones.
226 options: options object
227 test: An I_TEST namedtuple
228 print_step: Print a buildbot step
231 bb_annotations
.PrintNamedStep('install_%s' % test
.name
.lower())
233 args
= ['--apk_package', test
.apk_package
]
234 if options
.target
== 'Release':
235 args
.append('--release')
236 args
.append(test
.apk
)
238 RunCmd(['build/android/adb_install_apk.py'] + args
, halt_on_failure
=True)
241 def RunInstrumentationSuite(options
, test
, flunk_on_failure
=True,
242 python_only
=False, official_build
=False):
243 """Manages an invocation of test_runner.py for instrumentation tests.
246 options: options object
247 test: An I_TEST namedtuple
248 flunk_on_failure: Flunk the step if tests fail.
249 Python: Run only host driven Python tests.
250 official_build: Run official-build tests.
252 bb_annotations
.PrintNamedStep('%s_instrumentation_tests' % test
.name
.lower())
255 InstallApk(options
, test
)
256 args
= ['--test-apk', test
.test_apk
, '--verbose']
258 args
.extend(['--test_data', test
.test_data
])
259 if options
.target
== 'Release':
260 args
.append('--release')
262 args
.append('--tool=asan')
263 if options
.flakiness_server
:
264 args
.append('--flakiness-dashboard-server=%s' %
265 options
.flakiness_server
)
266 if options
.coverage_bucket
:
267 args
.append('--coverage-dir=%s' % options
.coverage_dir
)
268 if test
.host_driven_root
:
269 args
.append('--host-driven-root=%s' % test
.host_driven_root
)
271 args
.extend(['-A', test
.annotation
])
272 if test
.exclude_annotation
:
273 args
.extend(['-E', test
.exclude_annotation
])
275 args
.extend(test
.extra_flags
)
279 # The option needs to be assigned 'True' as it does not have an action
280 # associated with it.
281 args
.append('--official-build')
283 RunCmd(['build/android/test_runner.py', 'instrumentation'] + args
,
284 flunk_on_failure
=flunk_on_failure
)
288 """Lint WebKit's TestExpectation files."""
289 bb_annotations
.PrintNamedStep('webkit_lint')
290 RunCmd([SrcPath(os
.path
.join(BLINK_SCRIPTS_DIR
, 'lint-test-expectations'))])
293 def RunWebkitLayoutTests(options
):
294 """Run layout tests on an actual device."""
295 bb_annotations
.PrintNamedStep('webkit_tests')
298 '--no-new-test-results',
299 '--full-results-html',
300 '--clobber-old-results',
301 '--exit-after-n-failures', '5000',
302 '--exit-after-n-crashes-or-timeouts', '100',
303 '--debug-rwt-logging',
304 '--results-directory', '../layout-test-results',
305 '--target', options
.target
,
306 '--builder-name', options
.build_properties
.get('buildername', ''),
307 '--build-number', str(options
.build_properties
.get('buildnumber', '')),
308 '--master-name', 'ChromiumWebkit', # TODO: Get this from the cfg.
309 '--build-name', options
.build_properties
.get('buildername', ''),
310 '--platform=android']
312 for flag
in 'test_results_server', 'driver_name', 'additional_drt_flag':
313 if flag
in options
.factory_properties
:
314 cmd_args
.extend(['--%s' % flag
.replace('_', '-'),
315 options
.factory_properties
.get(flag
)])
317 for f
in options
.factory_properties
.get('additional_expectations', []):
319 ['--additional-expectations=%s' % os
.path
.join(CHROME_SRC_DIR
, *f
)])
321 # TODO(dpranke): Remove this block after
322 # https://codereview.chromium.org/12927002/ lands.
323 for f
in options
.factory_properties
.get('additional_expectations_files', []):
325 ['--additional-expectations=%s' % os
.path
.join(CHROME_SRC_DIR
, *f
)])
328 [SrcPath(os
.path
.join(BLINK_SCRIPTS_DIR
, 'run-webkit-tests'))] + cmd_args
)
329 if exit_code
== 255: # test_run_results.UNEXPECTED_ERROR_EXIT_STATUS
330 bb_annotations
.PrintMsg('?? (crashed or hung)')
331 elif exit_code
== 254: # test_run_results.NO_DEVICES_EXIT_STATUS
332 bb_annotations
.PrintMsg('?? (no devices found)')
333 elif exit_code
== 253: # test_run_results.NO_TESTS_EXIT_STATUS
334 bb_annotations
.PrintMsg('?? (no tests found)')
336 full_results_path
= os
.path
.join('..', 'layout-test-results',
338 if os
.path
.exists(full_results_path
):
339 full_results
= json
.load(open(full_results_path
))
340 unexpected_passes
, unexpected_failures
, unexpected_flakes
= (
341 _ParseLayoutTestResults(full_results
))
342 if unexpected_failures
:
343 _PrintDashboardLink('failed', unexpected_failures
,
345 elif unexpected_passes
:
346 _PrintDashboardLink('unexpected passes', unexpected_passes
,
348 if unexpected_flakes
:
349 _PrintDashboardLink('unexpected flakes', unexpected_flakes
,
352 if exit_code
== 0 and (unexpected_passes
or unexpected_flakes
):
353 # If exit_code != 0, RunCmd() will have already printed an error.
354 bb_annotations
.PrintWarning()
356 bb_annotations
.PrintError()
357 bb_annotations
.PrintMsg('?? (results missing)')
359 if options
.factory_properties
.get('archive_webkit_results', False):
360 bb_annotations
.PrintNamedStep('archive_webkit_results')
361 base
= 'https://storage.googleapis.com/chromium-layout-test-archives'
362 builder_name
= options
.build_properties
.get('buildername', '')
363 build_number
= str(options
.build_properties
.get('buildnumber', ''))
364 results_link
= '%s/%s/%s/layout-test-results/results.html' % (
365 base
, EscapeBuilderName(builder_name
), build_number
)
366 bb_annotations
.PrintLink('results', results_link
)
367 bb_annotations
.PrintLink('(zip)', '%s/%s/%s/layout-test-results.zip' % (
368 base
, EscapeBuilderName(builder_name
), build_number
))
369 gs_bucket
= 'gs://chromium-layout-test-archives'
370 RunCmd([os
.path
.join(SLAVE_SCRIPTS_DIR
, 'chromium',
371 'archive_layout_test_results.py'),
372 '--results-dir', '../../layout-test-results',
373 '--build-number', build_number
,
374 '--builder-name', builder_name
,
375 '--gs-bucket', gs_bucket
],
379 def _ParseLayoutTestResults(results
):
380 """Extract the failures from the test run."""
381 # Cloned from third_party/WebKit/Tools/Scripts/print-json-test-results
382 tests
= _ConvertTrieToFlatPaths(results
['tests'])
386 for (test
, result
) in tests
.iteritems():
387 if result
.get('is_unexpected'):
388 actual_results
= result
['actual'].split()
389 expected_results
= result
['expected'].split()
390 if len(actual_results
) > 1:
391 # We report the first failure type back, even if the second
393 if actual_results
[1] in expected_results
:
394 flakes
[test
] = actual_results
[0]
396 failures
[test
] = actual_results
[0]
397 elif actual_results
[0] == 'PASS':
398 passes
[test
] = result
400 failures
[test
] = actual_results
[0]
402 return (passes
, failures
, flakes
)
405 def _ConvertTrieToFlatPaths(trie
, prefix
=None):
406 """Flatten the trie of failures into a list."""
407 # Cloned from third_party/WebKit/Tools/Scripts/print-json-test-results
409 for name
, data
in trie
.iteritems():
411 name
= prefix
+ '/' + name
413 if len(data
) and 'actual' not in data
and 'expected' not in data
:
414 result
.update(_ConvertTrieToFlatPaths(data
, name
))
421 def _PrintDashboardLink(link_text
, tests
, max_tests
):
422 """Add a link to the flakiness dashboard in the step annotations."""
423 if len(tests
) > max_tests
:
424 test_list_text
= ' '.join(tests
[:max_tests
]) + ' and more'
426 test_list_text
= ' '.join(tests
)
428 dashboard_base
= ('http://test-results.appspot.com'
429 '/dashboards/flakiness_dashboard.html#'
430 'master=ChromiumWebkit&tests=')
432 bb_annotations
.PrintLink('%d %s: %s' %
433 (len(tests
), link_text
, test_list_text
),
434 dashboard_base
+ ','.join(tests
))
437 def EscapeBuilderName(builder_name
):
438 return re
.sub('[ ()]', '_', builder_name
)
441 def SpawnLogcatMonitor():
442 shutil
.rmtree(LOGCAT_DIR
, ignore_errors
=True)
444 os
.path
.join(CHROME_SRC_DIR
, 'build', 'android', 'adb_logcat_monitor.py'),
447 # Wait for logcat_monitor to pull existing logcat
448 RunCmd(['sleep', '5'])
451 def ProvisionDevices(options
):
452 bb_annotations
.PrintNamedStep('provision_devices')
454 if not bb_utils
.TESTING
:
455 # Restart adb to work around bugs, sleep to wait for usb discovery.
456 device_utils
.RestartServer()
457 RunCmd(['sleep', '1'])
458 provision_cmd
= ['build/android/provision_devices.py', '-t', options
.target
]
459 if options
.auto_reconnect
:
460 provision_cmd
.append('--auto-reconnect')
461 if options
.skip_wipe
:
462 provision_cmd
.append('--skip-wipe')
463 RunCmd(provision_cmd
, halt_on_failure
=True)
466 def DeviceStatusCheck(options
):
467 bb_annotations
.PrintNamedStep('device_status_check')
468 cmd
= ['build/android/buildbot/bb_device_status_check.py']
469 if options
.restart_usb
:
470 cmd
.append('--restart-usb')
471 RunCmd(cmd
, halt_on_failure
=True)
474 def GetDeviceSetupStepCmds():
476 ('device_status_check', DeviceStatusCheck
),
477 ('provision_devices', ProvisionDevices
),
481 def RunUnitTests(options
):
482 suites
= gtest_config
.STABLE_TEST_SUITES
484 suites
= [s
for s
in suites
485 if s
not in gtest_config
.ASAN_EXCLUDED_TEST_SUITES
]
486 RunTestSuites(options
, suites
)
489 def RunInstrumentationTests(options
):
490 for test
in INSTRUMENTATION_TESTS
.itervalues():
491 RunInstrumentationSuite(options
, test
)
494 def RunWebkitTests(options
):
495 RunTestSuites(options
, ['webkit_unit_tests', 'blink_heap_unittests'])
499 def RunGPUTests(options
):
500 revision
= _GetRevision(options
)
501 builder_name
= options
.build_properties
.get('buildername', 'noname')
503 bb_annotations
.PrintNamedStep('pixel_tests')
504 RunCmd(['content/test/gpu/run_gpu_test.py',
507 'android-content-shell',
510 '--upload-refimg-to-cloud-storage',
511 '--refimg-cloud-storage-bucket',
512 'chromium-gpu-archive/reference-images',
515 '--test-machine-name',
516 EscapeBuilderName(builder_name
)])
518 bb_annotations
.PrintNamedStep('webgl_conformance_tests')
519 RunCmd(['content/test/gpu/run_gpu_test.py',
520 '--browser=android-content-shell', 'webgl_conformance',
521 '--webgl-conformance-version=1.0.1'])
523 bb_annotations
.PrintNamedStep('gpu_rasterization_tests')
524 RunCmd(['content/test/gpu/run_gpu_test.py',
527 'android-content-shell',
530 '--test-machine-name',
531 EscapeBuilderName(builder_name
)])
534 def GetTestStepCmds():
536 ('chromedriver', RunChromeDriverTests
),
537 ('chrome_proxy', RunChromeProxyTests
),
538 ('gpu', RunGPUTests
),
539 ('mojo', RunMojoTests
),
540 ('sync', RunChromeSyncShellTests
),
541 ('telemetry_perf_unittests', RunTelemetryPerfUnitTests
),
542 ('ui', RunInstrumentationTests
),
543 ('unit', RunUnitTests
),
544 ('webkit', RunWebkitTests
),
545 ('webkit_layout', RunWebkitLayoutTests
),
549 def MakeGSPath(options
, gs_base_dir
):
550 revision
= _GetRevision(options
)
551 bot_id
= options
.build_properties
.get('buildername', 'testing')
552 randhash
= hashlib
.sha1(str(random
.random())).hexdigest()
553 gs_path
= '%s/%s/%s/%s' % (gs_base_dir
, bot_id
, revision
, randhash
)
554 # remove double slashes, happens with blank revisions and confuses gsutil
555 gs_path
= re
.sub('/+', '/', gs_path
)
558 def UploadHTML(options
, gs_base_dir
, dir_to_upload
, link_text
,
559 link_rel_path
='index.html', gs_url
=GS_URL
):
560 """Uploads directory at |dir_to_upload| to Google Storage and output a link.
563 options: Command line options.
564 gs_base_dir: The Google Storage base directory (e.g.
565 'chromium-code-coverage/java')
566 dir_to_upload: Absolute path to the directory to be uploaded.
567 link_text: Link text to be displayed on the step.
568 link_rel_path: Link path relative to |dir_to_upload|.
569 gs_url: Google storage URL.
571 gs_path
= MakeGSPath(options
, gs_base_dir
)
572 RunCmd([bb_utils
.GSUTIL_PATH
, 'cp', '-R', dir_to_upload
, 'gs://%s' % gs_path
])
573 bb_annotations
.PrintLink(link_text
,
574 '%s/%s/%s' % (gs_url
, gs_path
, link_rel_path
))
577 def GenerateJavaCoverageReport(options
):
578 """Generates an HTML coverage report using EMMA and uploads it."""
579 bb_annotations
.PrintNamedStep('java_coverage_report')
581 coverage_html
= os
.path
.join(options
.coverage_dir
, 'coverage_html')
582 RunCmd(['build/android/generate_emma_html.py',
583 '--coverage-dir', options
.coverage_dir
,
584 '--metadata-dir', os
.path
.join(CHROME_OUT_DIR
, options
.target
),
586 '--output', os
.path
.join(coverage_html
, 'index.html')])
590 def LogcatDump(options
):
591 # Print logcat, kill logcat monitor
592 bb_annotations
.PrintNamedStep('logcat_dump')
593 logcat_file
= os
.path
.join(CHROME_OUT_DIR
, options
.target
, 'full_log.txt')
594 RunCmd([SrcPath('build' , 'android', 'adb_logcat_printer.py'),
595 '--output-path', logcat_file
, LOGCAT_DIR
])
596 gs_path
= MakeGSPath(options
, 'chromium-android/logcat_dumps')
597 RunCmd([bb_utils
.GSUTIL_PATH
, 'cp', '-z', 'txt', logcat_file
,
598 'gs://%s' % gs_path
])
599 bb_annotations
.PrintLink('logcat dump', '%s/%s' % (GS_AUTH_URL
, gs_path
))
602 def RunStackToolSteps(options
):
603 """Run stack tool steps.
605 Stack tool is run for logcat dump, optionally for ASAN.
607 bb_annotations
.PrintNamedStep('Run stack tool with logcat dump')
608 logcat_file
= os
.path
.join(CHROME_OUT_DIR
, options
.target
, 'full_log.txt')
609 RunCmd([os
.path
.join(CHROME_SRC_DIR
, 'third_party', 'android_platform',
610 'development', 'scripts', 'stack'),
611 '--more-info', logcat_file
])
612 if options
.asan_symbolize
:
613 bb_annotations
.PrintNamedStep('Run stack tool for ASAN')
615 os
.path
.join(CHROME_SRC_DIR
, 'build', 'android', 'asan_symbolize.py'),
619 def GenerateTestReport(options
):
620 bb_annotations
.PrintNamedStep('test_report')
621 for report
in glob
.glob(
622 os
.path
.join(CHROME_OUT_DIR
, options
.target
, 'test_logs', '*.log')):
623 RunCmd(['cat', report
])
627 def MainTestWrapper(options
):
629 # Spawn logcat monitor
632 # Run all device setup steps
633 for _
, cmd
in GetDeviceSetupStepCmds():
637 test_obj
= INSTRUMENTATION_TESTS
[options
.install
]
638 InstallApk(options
, test_obj
, print_step
=True)
640 if options
.test_filter
:
641 bb_utils
.RunSteps(options
.test_filter
, GetTestStepCmds(), options
)
643 if options
.coverage_bucket
:
644 coverage_html
= GenerateJavaCoverageReport(options
)
645 UploadHTML(options
, '%s/java' % options
.coverage_bucket
, coverage_html
,
647 shutil
.rmtree(coverage_html
, ignore_errors
=True)
649 if options
.experimental
:
650 RunTestSuites(options
, gtest_config
.EXPERIMENTAL_TEST_SUITES
)
653 # Run all post test steps
655 if not options
.disable_stack_tool
:
656 RunStackToolSteps(options
)
657 GenerateTestReport(options
)
658 # KillHostHeartbeat() has logic to check if heartbeat process is running,
659 # and kills only if it finds the process is running on the host.
660 provision_devices
.KillHostHeartbeat()
662 shutil
.rmtree(os
.path
.join(CHROME_OUT_DIR
, options
.target
),
666 def GetDeviceStepsOptParser():
667 parser
= bb_utils
.GetParser()
668 parser
.add_option('--experimental', action
='store_true',
669 help='Run experiemental tests')
670 parser
.add_option('-f', '--test-filter', metavar
='<filter>', default
=[],
672 help=('Run a test suite. Test suites: "%s"' %
673 '", "'.join(VALID_TESTS
)))
674 parser
.add_option('--gtest-filter',
675 help='Filter for running a subset of tests of a gtest test')
676 parser
.add_option('--asan', action
='store_true', help='Run tests with asan.')
677 parser
.add_option('--install', metavar
='<apk name>',
678 help='Install an apk by name')
679 parser
.add_option('--no-reboot', action
='store_true',
680 help='Do not reboot devices during provisioning.')
681 parser
.add_option('--coverage-bucket',
682 help=('Bucket name to store coverage results. Coverage is '
683 'only run if this is set.'))
684 parser
.add_option('--restart-usb', action
='store_true',
685 help='Restart usb ports before device status check.')
687 '--flakiness-server',
688 help=('The flakiness dashboard server to which the results should be '
691 '--auto-reconnect', action
='store_true',
692 help='Push script to device which restarts adbd on disconnections.')
693 parser
.add_option('--skip-wipe', action
='store_true',
694 help='Do not wipe devices during provisioning.')
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 if options
.chrome_output_dir
:
728 global CHROME_OUT_DIR
730 CHROME_OUT_DIR
= options
.chrome_output_dir
731 LOGCAT_DIR
= os
.path
.join(CHROME_OUT_DIR
, 'logcat')
733 if options
.coverage_bucket
:
734 setattr(options
, 'coverage_dir',
735 os
.path
.join(CHROME_OUT_DIR
, options
.target
, 'coverage'))
737 MainTestWrapper(options
)
740 if __name__
== '__main__':
741 sys
.exit(main(sys
.argv
))