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'),
77 'ChromeSyncShell.apk',
78 'org.chromium.chrome.browser.sync',
79 'ChromeSyncShellTest',
83 InstallablePackage
= collections
.namedtuple('InstallablePackage', [
84 'name', 'apk', 'apk_package'])
86 INSTALLABLE_PACKAGES
= dict((package
.name
, package
) for package
in (
87 [InstallablePackage(i
.name
, i
.apk
, i
.apk_package
)
88 for i
in INSTRUMENTATION_TESTS
.itervalues()] +
89 [InstallablePackage('ChromeDriverWebViewShell',
90 'ChromeDriverWebViewShell.apk',
91 'org.chromium.chromedriver_webview_shell')]))
93 VALID_TESTS
= set(['chromedriver', 'chrome_proxy', 'gpu',
94 'telemetry_unittests', 'telemetry_perf_unittests', 'ui',
95 'unit', 'webkit', 'webkit_layout', 'python_unittests'])
97 RunCmd
= bb_utils
.RunCmd
100 def _GetRevision(options
):
101 """Get the SVN revision number.
104 options: options object.
109 revision
= options
.build_properties
.get('got_revision')
111 revision
= options
.build_properties
.get('revision', 'testing')
115 def _RunTest(options
, cmd
, suite
):
116 """Run test command with runtest.py.
119 options: options object.
120 cmd: the command to run.
123 property_args
= bb_utils
.EncodeProperties(options
)
124 args
= [os
.path
.join(SLAVE_SCRIPTS_DIR
, 'runtest.py')] + property_args
125 args
+= ['--test-platform', 'android']
126 if options
.factory_properties
.get('generate_gtest_json'):
127 args
.append('--generate-json-file')
128 args
+= ['-o', 'gtest-results/%s' % suite
,
129 '--annotate', 'gtest',
130 '--build-number', str(options
.build_properties
.get('buildnumber',
132 '--builder-name', options
.build_properties
.get('buildername', '')]
133 if options
.target
== 'Release':
134 args
+= ['--target', 'Release']
136 args
+= ['--target', 'Debug']
137 if options
.flakiness_server
:
138 args
+= ['--flakiness-dashboard-server=%s' %
139 options
.flakiness_server
]
141 RunCmd(args
, cwd
=DIR_BUILD_ROOT
)
144 def RunTestSuites(options
, suites
, suites_options
=None):
145 """Manages an invocation of test_runner.py for gtests.
148 options: options object.
149 suites: List of suite names to run.
150 suites_options: Command line options dictionary for particular suites.
152 {'content_browsertests', ['--num_retries=1', '--release']}
153 will add the options only to content_browsertests.
156 if not suites_options
:
160 if options
.target
== 'Release':
161 args
.append('--release')
163 args
.append('--tool=asan')
164 if options
.gtest_filter
:
165 args
.append('--gtest-filter=%s' % options
.gtest_filter
)
168 bb_annotations
.PrintNamedStep(suite
)
170 cmd
+= suites_options
.get(suite
, [])
171 if suite
== 'content_browsertests':
172 cmd
.append('--num_retries=1')
173 _RunTest(options
, cmd
, suite
)
176 def RunChromeDriverTests(options
):
177 """Run all the steps for running chromedriver tests."""
178 bb_annotations
.PrintNamedStep('chromedriver_annotation')
179 RunCmd(['chrome/test/chromedriver/run_buildbot_steps.py',
180 '--android-packages=%s,%s,%s,%s' %
184 'chromedriver_webview_shell'),
185 '--revision=%s' % _GetRevision(options
),
188 def RunChromeProxyTests(options
):
189 """Run the chrome_proxy tests.
192 options: options object.
194 InstallApk(options
, INSTRUMENTATION_TESTS
['ChromeShell'], False)
195 args
= ['--browser', 'android-chrome-shell']
196 devices
= android_commands
.GetAttachedDevices()
198 args
= args
+ ['--device', devices
[0]]
199 bb_annotations
.PrintNamedStep('chrome_proxy')
200 RunCmd(['tools/chrome_proxy/run_tests'] + args
)
203 def RunTelemetryTests(options
, step_name
, run_tests_path
):
204 """Runs either telemetry_perf_unittests or telemetry_unittests.
207 options: options object.
208 step_name: either 'telemetry_unittests' or 'telemetry_perf_unittests'
209 run_tests_path: path to run_tests script (tools/perf/run_tests for
210 perf_unittests and tools/telemetry/run_tests for
213 InstallApk(options
, INSTRUMENTATION_TESTS
['ChromeShell'], False)
214 args
= ['--browser', 'android-chrome-shell']
215 devices
= android_commands
.GetAttachedDevices()
217 args
= args
+ ['--device', devices
[0]]
218 bb_annotations
.PrintNamedStep(step_name
)
219 RunCmd([run_tests_path
] + args
)
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 RunTelemetryUnitTests(options
):
490 RunTelemetryTests(options
, 'telemetry_unittests', 'tools/telemetry/run_tests')
493 def RunTelemetryPerfUnitTests(options
):
494 RunTelemetryTests(options
, 'telemetry_perf_unittests', 'tools/perf/run_tests')
497 def RunInstrumentationTests(options
):
498 for test
in INSTRUMENTATION_TESTS
.itervalues():
499 RunInstrumentationSuite(options
, test
)
502 def RunWebkitTests(options
):
503 RunTestSuites(options
, ['webkit_unit_tests', 'blink_heap_unittests'])
507 def RunGPUTests(options
):
508 revision
= _GetRevision(options
)
509 builder_name
= options
.build_properties
.get('buildername', 'noname')
511 bb_annotations
.PrintNamedStep('pixel_tests')
512 RunCmd(['content/test/gpu/run_gpu_test.py',
515 'android-content-shell',
518 '--upload-refimg-to-cloud-storage',
519 '--refimg-cloud-storage-bucket',
520 'chromium-gpu-archive/reference-images',
523 '--test-machine-name',
524 EscapeBuilderName(builder_name
)])
526 bb_annotations
.PrintNamedStep('webgl_conformance_tests')
527 RunCmd(['content/test/gpu/run_gpu_test.py',
528 '--browser=android-content-shell', 'webgl_conformance',
529 '--webgl-conformance-version=1.0.1'])
531 bb_annotations
.PrintNamedStep('gpu_rasterization_tests')
532 RunCmd(['content/test/gpu/run_gpu_test.py',
535 'android-content-shell',
538 '--test-machine-name',
539 EscapeBuilderName(builder_name
)])
542 def RunPythonUnitTests(_options
):
543 for suite
in constants
.PYTHON_UNIT_TEST_SUITES
:
544 bb_annotations
.PrintNamedStep(suite
)
545 RunCmd(['build/android/test_runner.py', 'python', '-s', suite
])
548 def GetTestStepCmds():
550 ('chromedriver', RunChromeDriverTests
),
551 ('chrome_proxy', RunChromeProxyTests
),
552 ('gpu', RunGPUTests
),
553 ('python_unittests', RunPythonUnitTests
),
554 ('telemetry_unittests', RunTelemetryUnitTests
),
555 ('telemetry_perf_unittests', RunTelemetryPerfUnitTests
),
556 ('ui', RunInstrumentationTests
),
557 ('unit', RunUnitTests
),
558 ('webkit', RunWebkitTests
),
559 ('webkit_layout', RunWebkitLayoutTests
),
563 def MakeGSPath(options
, gs_base_dir
):
564 revision
= _GetRevision(options
)
565 bot_id
= options
.build_properties
.get('buildername', 'testing')
566 randhash
= hashlib
.sha1(str(random
.random())).hexdigest()
567 gs_path
= '%s/%s/%s/%s' % (gs_base_dir
, bot_id
, revision
, randhash
)
568 # remove double slashes, happens with blank revisions and confuses gsutil
569 gs_path
= re
.sub('/+', '/', gs_path
)
572 def UploadHTML(options
, gs_base_dir
, dir_to_upload
, link_text
,
573 link_rel_path
='index.html', gs_url
=GS_URL
):
574 """Uploads directory at |dir_to_upload| to Google Storage and output a link.
577 options: Command line options.
578 gs_base_dir: The Google Storage base directory (e.g.
579 'chromium-code-coverage/java')
580 dir_to_upload: Absolute path to the directory to be uploaded.
581 link_text: Link text to be displayed on the step.
582 link_rel_path: Link path relative to |dir_to_upload|.
583 gs_url: Google storage URL.
585 gs_path
= MakeGSPath(options
, gs_base_dir
)
586 RunCmd([bb_utils
.GSUTIL_PATH
, 'cp', '-R', dir_to_upload
, 'gs://%s' % gs_path
])
587 bb_annotations
.PrintLink(link_text
,
588 '%s/%s/%s' % (gs_url
, gs_path
, link_rel_path
))
591 def GenerateJavaCoverageReport(options
):
592 """Generates an HTML coverage report using EMMA and uploads it."""
593 bb_annotations
.PrintNamedStep('java_coverage_report')
595 coverage_html
= os
.path
.join(options
.coverage_dir
, 'coverage_html')
596 RunCmd(['build/android/generate_emma_html.py',
597 '--coverage-dir', options
.coverage_dir
,
598 '--metadata-dir', os
.path
.join(CHROME_OUT_DIR
, options
.target
),
600 '--output', os
.path
.join(coverage_html
, 'index.html')])
604 def LogcatDump(options
):
605 # Print logcat, kill logcat monitor
606 bb_annotations
.PrintNamedStep('logcat_dump')
607 logcat_file
= os
.path
.join(CHROME_OUT_DIR
, options
.target
, 'full_log.txt')
608 RunCmd([SrcPath('build', 'android', 'adb_logcat_printer.py'),
609 '--output-path', logcat_file
, LOGCAT_DIR
])
610 gs_path
= MakeGSPath(options
, 'chromium-android/logcat_dumps')
611 RunCmd([bb_utils
.GSUTIL_PATH
, 'cp', '-z', 'txt', logcat_file
,
612 'gs://%s' % gs_path
])
613 bb_annotations
.PrintLink('logcat dump', '%s/%s' % (GS_AUTH_URL
, gs_path
))
616 def RunStackToolSteps(options
):
617 """Run stack tool steps.
619 Stack tool is run for logcat dump, optionally for ASAN.
621 bb_annotations
.PrintNamedStep('Run stack tool with logcat dump')
622 logcat_file
= os
.path
.join(CHROME_OUT_DIR
, options
.target
, 'full_log.txt')
623 RunCmd([os
.path
.join(CHROME_SRC_DIR
, 'third_party', 'android_platform',
624 'development', 'scripts', 'stack'),
625 '--more-info', logcat_file
])
626 if options
.asan_symbolize
:
627 bb_annotations
.PrintNamedStep('Run stack tool for ASAN')
629 os
.path
.join(CHROME_SRC_DIR
, 'build', 'android', 'asan_symbolize.py'),
633 def GenerateTestReport(options
):
634 bb_annotations
.PrintNamedStep('test_report')
635 for report
in glob
.glob(
636 os
.path
.join(CHROME_OUT_DIR
, options
.target
, 'test_logs', '*.log')):
637 RunCmd(['cat', report
])
641 def MainTestWrapper(options
):
643 # Spawn logcat monitor
646 # Run all device setup steps
647 for _
, cmd
in GetDeviceSetupStepCmds():
651 for i
in options
.install
:
652 install_obj
= INSTALLABLE_PACKAGES
[i
]
653 InstallApk(options
, install_obj
, print_step
=True)
655 if options
.test_filter
:
656 bb_utils
.RunSteps(options
.test_filter
, GetTestStepCmds(), options
)
658 if options
.coverage_bucket
:
659 coverage_html
= GenerateJavaCoverageReport(options
)
660 UploadHTML(options
, '%s/java' % options
.coverage_bucket
, coverage_html
,
662 shutil
.rmtree(coverage_html
, ignore_errors
=True)
664 if options
.experimental
:
665 RunTestSuites(options
, gtest_config
.EXPERIMENTAL_TEST_SUITES
)
668 # Run all post test steps
670 if not options
.disable_stack_tool
:
671 RunStackToolSteps(options
)
672 GenerateTestReport(options
)
673 # KillHostHeartbeat() has logic to check if heartbeat process is running,
674 # and kills only if it finds the process is running on the host.
675 provision_devices
.KillHostHeartbeat()
677 shutil
.rmtree(os
.path
.join(CHROME_OUT_DIR
, options
.target
),
681 def GetDeviceStepsOptParser():
682 parser
= bb_utils
.GetParser()
683 parser
.add_option('--experimental', action
='store_true',
684 help='Run experiemental tests')
685 parser
.add_option('-f', '--test-filter', metavar
='<filter>', default
=[],
687 help=('Run a test suite. Test suites: "%s"' %
688 '", "'.join(VALID_TESTS
)))
689 parser
.add_option('--gtest-filter',
690 help='Filter for running a subset of tests of a gtest test')
691 parser
.add_option('--asan', action
='store_true', help='Run tests with asan.')
692 parser
.add_option('--install', metavar
='<apk name>', action
="append",
693 help='Install an apk by name')
694 parser
.add_option('--no-reboot', action
='store_true',
695 help='Do not reboot devices during provisioning.')
696 parser
.add_option('--coverage-bucket',
697 help=('Bucket name to store coverage results. Coverage is '
698 'only run if this is set.'))
699 parser
.add_option('--restart-usb', action
='store_true',
700 help='Restart usb ports before device status check.')
702 '--flakiness-server',
703 help=('The flakiness dashboard server to which the results should be '
706 '--auto-reconnect', action
='store_true',
707 help='Push script to device which restarts adbd on disconnections.')
708 parser
.add_option('--skip-wipe', action
='store_true',
709 help='Do not wipe devices during provisioning.')
711 '--logcat-dump-output',
712 help='The logcat dump output will be "tee"-ed into this file')
713 # During processing perf bisects, a seperate working directory created under
714 # which builds are produced. Therefore we should look for relevent output
715 # file under this directory.(/b/build/slave/<slave_name>/build/bisect/src/out)
717 '--chrome-output-dir',
718 help='Chrome output directory to be used while bisecting.')
720 parser
.add_option('--disable-stack-tool', action
='store_true',
721 help='Do not run stack tool.')
722 parser
.add_option('--asan-symbolize', action
='store_true',
723 help='Run stack tool for ASAN')
724 parser
.add_option('--cleanup', action
='store_true',
725 help='Delete out/<target> directory at the end of the run.')
730 parser
= GetDeviceStepsOptParser()
731 options
, args
= parser
.parse_args(argv
[1:])
734 return sys
.exit('Unused args %s' % args
)
736 unknown_tests
= set(options
.test_filter
) - VALID_TESTS
738 return sys
.exit('Unknown tests %s' % list(unknown_tests
))
740 setattr(options
, 'target', options
.factory_properties
.get('target', 'Debug'))
742 if options
.chrome_output_dir
:
743 global CHROME_OUT_DIR
745 CHROME_OUT_DIR
= options
.chrome_output_dir
746 LOGCAT_DIR
= os
.path
.join(CHROME_OUT_DIR
, 'logcat')
748 if options
.coverage_bucket
:
749 setattr(options
, 'coverage_dir',
750 os
.path
.join(CHROME_OUT_DIR
, options
.target
, 'coverage'))
752 MainTestWrapper(options
)
755 if __name__
== '__main__':
756 sys
.exit(main(sys
.argv
))