[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 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 | |
| 6 | import collections |
| 7 | import glob |
[email protected] | 485fb23 | 2013-08-22 19:56:33 | [diff] [blame] | 8 | import hashlib |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 9 | import json |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 10 | import os |
[email protected] | 485fb23 | 2013-08-22 19:56:33 | [diff] [blame] | 11 | import random |
[email protected] | e2107bd | 2013-09-18 05:13:10 | [diff] [blame] | 12 | import re |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 13 | import shutil |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 14 | import sys |
| 15 | |
[email protected] | c528275 | 2013-06-07 23:14:39 | [diff] [blame] | 16 | import bb_utils |
[email protected] | b387389 | 2013-07-10 04:57:10 | [diff] [blame] | 17 | import bb_annotations |
[email protected] | c528275 | 2013-06-07 23:14:39 | [diff] [blame] | 18 | |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 19 | sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
[email protected] | 7849a33 | 2013-07-12 01:40:09 | [diff] [blame] | 20 | import provision_devices |
[email protected] | 78af871 | 2013-01-14 10:37:12 | [diff] [blame] | 21 | from pylib import android_commands |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 22 | from pylib import constants |
[email protected] | 044d79b | 2014-04-10 19:37:30 | [diff] [blame] | 23 | from pylib.device import device_utils |
[email protected] | a8fea93f | 2013-01-10 04:00:07 | [diff] [blame] | 24 | from pylib.gtest import gtest_config |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 25 | |
[email protected] | dc8ec3f | 2013-09-07 07:18:14 | [diff] [blame] | 26 | CHROME_SRC_DIR = bb_utils.CHROME_SRC |
[email protected] | ae41072 | 2013-10-24 15:57:36 | [diff] [blame] | 27 | DIR_BUILD_ROOT = os.path.dirname(CHROME_SRC_DIR) |
[email protected] | dc8ec3f | 2013-09-07 07:18:14 | [diff] [blame] | 28 | CHROME_OUT_DIR = bb_utils.CHROME_OUT_DIR |
dpranke | ec3eb0a | 2014-09-26 21:42:56 | [diff] [blame] | 29 | BLINK_SCRIPTS_DIR = 'third_party/WebKit/Tools/Scripts' |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 30 | |
[email protected] | dc8ec3f | 2013-09-07 07:18:14 | [diff] [blame] | 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') |
[email protected] | 4e622cee | 2013-09-17 18:32:12 | [diff] [blame] | 33 | GS_URL = 'https://storage.googleapis.com' |
[email protected] | c79bc8a | 2014-04-24 03:39:52 | [diff] [blame] | 34 | GS_AUTH_URL = 'https://storage.cloud.google.com' |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 35 | |
| 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. |
[email protected] | 37ee0c79 | 2013-08-06 19:10:13 | [diff] [blame] | 42 | # host_driven_root: The host-driven test root directory. |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 43 | # annotation: Annotation of the tests to include. |
| 44 | # exclude_annotation: The annotation of the tests to exclude. |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 45 | I_TEST = collections.namedtuple('InstrumentationTest', [ |
jbudorick | e4bb2b8 | 2015-02-09 18:35:00 | [diff] [blame] | 46 | 'name', 'apk', 'apk_package', 'test_apk', 'test_data', 'isolate_file_path', |
| 47 | 'host_driven_root', 'annotation', 'exclude_annotation', 'extra_flags']) |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 48 | |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 49 | |
[email protected] | ae41072 | 2013-10-24 15:57:36 | [diff] [blame] | 50 | def SrcPath(*path): |
| 51 | return os.path.join(CHROME_SRC_DIR, *path) |
| 52 | |
jbudorick | 3490213 | 2014-12-09 14:24:56 | [diff] [blame] | 53 | |
jbudorick | e4bb2b8 | 2015-02-09 18:35:00 | [diff] [blame] | 54 | def I(name, apk, apk_package, test_apk, test_data, isolate_file_path=None, |
| 55 | host_driven_root=None, annotation=None, exclude_annotation=None, |
| 56 | extra_flags=None): |
| 57 | return I_TEST(name, apk, apk_package, test_apk, test_data, isolate_file_path, |
| 58 | host_driven_root, annotation, exclude_annotation, extra_flags) |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 59 | |
| 60 | INSTRUMENTATION_TESTS = dict((suite.name, suite) for suite in [ |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 61 | I('ContentShell', |
| 62 | 'ContentShell.apk', |
| 63 | 'org.chromium.content_shell_apk', |
jbudorick | 3490213 | 2014-12-09 14:24:56 | [diff] [blame] | 64 | 'ContentShellTest', |
jbudorick | e4bb2b8 | 2015-02-09 18:35:00 | [diff] [blame] | 65 | 'content:content/test/data/android/device_files', |
| 66 | isolate_file_path='content/content_shell_test_apk.isolate'), |
[email protected] | efeb59e | 2014-03-12 01:31:26 | [diff] [blame] | 67 | I('ChromeShell', |
| 68 | 'ChromeShell.apk', |
[email protected] | 34460fc | 2014-03-04 07:18:00 | [diff] [blame] | 69 | 'org.chromium.chrome.shell', |
[email protected] | efeb59e | 2014-03-12 01:31:26 | [diff] [blame] | 70 | 'ChromeShellTest', |
jbudorick | 3490213 | 2014-12-09 14:24:56 | [diff] [blame] | 71 | 'chrome:chrome/test/data/android/device_files', |
jbudorick | e4bb2b8 | 2015-02-09 18:35:00 | [diff] [blame] | 72 | isolate_file_path='chrome/chrome_shell_test_apk.isolate', |
| 73 | host_driven_root=constants.CHROME_SHELL_HOST_DRIVEN_DIR), |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 74 | I('AndroidWebView', |
| 75 | 'AndroidWebView.apk', |
| 76 | 'org.chromium.android_webview.shell', |
jbudorick | 3490213 | 2014-12-09 14:24:56 | [diff] [blame] | 77 | 'AndroidWebViewTest', |
jbudorick | e4bb2b8 | 2015-02-09 18:35:00 | [diff] [blame] | 78 | 'webview:android_webview/test/data/device_files', |
| 79 | isolate_file_path='android_webview/android_webview_test_apk.isolate'), |
mikecase | 94c8f1ad3b | 2014-10-27 23:09:36 | [diff] [blame] | 80 | I('ChromeSyncShell', |
| 81 | 'ChromeSyncShell.apk', |
| 82 | 'org.chromium.chrome.browser.sync', |
jbudorick | 3490213 | 2014-12-09 14:24:56 | [diff] [blame] | 83 | 'ChromeSyncShellTest', |
| 84 | None), |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 85 | ]) |
| 86 | |
jbudorick | c574b1b | 2014-12-04 18:21:28 | [diff] [blame] | 87 | InstallablePackage = collections.namedtuple('InstallablePackage', [ |
| 88 | 'name', 'apk', 'apk_package']) |
| 89 | |
| 90 | INSTALLABLE_PACKAGES = dict((package.name, package) for package in ( |
| 91 | [InstallablePackage(i.name, i.apk, i.apk_package) |
| 92 | for i in INSTRUMENTATION_TESTS.itervalues()] + |
| 93 | [InstallablePackage('ChromeDriverWebViewShell', |
| 94 | 'ChromeDriverWebViewShell.apk', |
| 95 | 'org.chromium.chromedriver_webview_shell')])) |
| 96 | |
jbudorick | 71a2498 | 2015-05-11 19:12:56 | [diff] [blame^] | 97 | VALID_TESTS = set([ |
| 98 | 'base_junit_tests', |
| 99 | 'chromedriver', |
| 100 | 'chrome_proxy', |
| 101 | 'components_browsertests', |
| 102 | 'gfx_unittests', |
| 103 | 'gpu', |
| 104 | 'python_unittests', |
| 105 | 'telemetry_unittests', |
| 106 | 'telemetry_perf_unittests', |
| 107 | 'ui', |
| 108 | 'unit', |
| 109 | 'webkit', |
| 110 | 'webkit_layout' |
| 111 | ]) |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 112 | |
[email protected] | c528275 | 2013-06-07 23:14:39 | [diff] [blame] | 113 | RunCmd = bb_utils.RunCmd |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 114 | |
| 115 | |
[email protected] | e7bd341 | 2013-09-20 17:15:28 | [diff] [blame] | 116 | def _GetRevision(options): |
| 117 | """Get the SVN revision number. |
| 118 | |
| 119 | Args: |
| 120 | options: options object. |
| 121 | |
| 122 | Returns: |
| 123 | The revision number. |
| 124 | """ |
| 125 | revision = options.build_properties.get('got_revision') |
| 126 | if not revision: |
| 127 | revision = options.build_properties.get('revision', 'testing') |
| 128 | return revision |
| 129 | |
| 130 | |
[email protected] | f762c120 | 2014-08-13 09:36:34 | [diff] [blame] | 131 | def _RunTest(options, cmd, suite): |
| 132 | """Run test command with runtest.py. |
| 133 | |
| 134 | Args: |
| 135 | options: options object. |
| 136 | cmd: the command to run. |
| 137 | suite: test name. |
| 138 | """ |
| 139 | property_args = bb_utils.EncodeProperties(options) |
| 140 | args = [os.path.join(SLAVE_SCRIPTS_DIR, 'runtest.py')] + property_args |
| 141 | args += ['--test-platform', 'android'] |
| 142 | if options.factory_properties.get('generate_gtest_json'): |
| 143 | args.append('--generate-json-file') |
| 144 | args += ['-o', 'gtest-results/%s' % suite, |
| 145 | '--annotate', 'gtest', |
| 146 | '--build-number', str(options.build_properties.get('buildnumber', |
| 147 | '')), |
| 148 | '--builder-name', options.build_properties.get('buildername', '')] |
| 149 | if options.target == 'Release': |
| 150 | args += ['--target', 'Release'] |
| 151 | else: |
| 152 | args += ['--target', 'Debug'] |
mikecase | 97d50b6 | 2014-11-14 18:33:52 | [diff] [blame] | 153 | if options.flakiness_server: |
| 154 | args += ['--flakiness-dashboard-server=%s' % |
| 155 | options.flakiness_server] |
[email protected] | f762c120 | 2014-08-13 09:36:34 | [diff] [blame] | 156 | args += cmd |
| 157 | RunCmd(args, cwd=DIR_BUILD_ROOT) |
| 158 | |
| 159 | |
[email protected] | 0ceb1499 | 2014-05-24 00:37:26 | [diff] [blame] | 160 | def RunTestSuites(options, suites, suites_options=None): |
[email protected] | fbe2932 | 2013-07-09 09:03:26 | [diff] [blame] | 161 | """Manages an invocation of test_runner.py for gtests. |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 162 | |
| 163 | Args: |
| 164 | options: options object. |
[email protected] | 9e68925 | 2013-07-30 20:14:36 | [diff] [blame] | 165 | suites: List of suite names to run. |
[email protected] | 0ceb1499 | 2014-05-24 00:37:26 | [diff] [blame] | 166 | suites_options: Command line options dictionary for particular suites. |
| 167 | For example, |
| 168 | {'content_browsertests', ['--num_retries=1', '--release']} |
| 169 | will add the options only to content_browsertests. |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 170 | """ |
[email protected] | 0ceb1499 | 2014-05-24 00:37:26 | [diff] [blame] | 171 | |
| 172 | if not suites_options: |
| 173 | suites_options = {} |
| 174 | |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 175 | args = ['--verbose'] |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 176 | if options.target == 'Release': |
| 177 | args.append('--release') |
| 178 | if options.asan: |
| 179 | args.append('--tool=asan') |
[email protected] | 18d59b8 | 2013-11-12 09:21:41 | [diff] [blame] | 180 | if options.gtest_filter: |
| 181 | args.append('--gtest-filter=%s' % options.gtest_filter) |
[email protected] | 0ceb1499 | 2014-05-24 00:37:26 | [diff] [blame] | 182 | |
[email protected] | a8fea93f | 2013-01-10 04:00:07 | [diff] [blame] | 183 | for suite in suites: |
[email protected] | 9e68925 | 2013-07-30 20:14:36 | [diff] [blame] | 184 | bb_annotations.PrintNamedStep(suite) |
[email protected] | f762c120 | 2014-08-13 09:36:34 | [diff] [blame] | 185 | cmd = [suite] + args |
[email protected] | 0ceb1499 | 2014-05-24 00:37:26 | [diff] [blame] | 186 | cmd += suites_options.get(suite, []) |
jbudorick | c4b6b651 | 2015-04-23 21:30:28 | [diff] [blame] | 187 | if suite == 'content_browsertests' or suite == 'components_browsertests': |
[email protected] | 9e68925 | 2013-07-30 20:14:36 | [diff] [blame] | 188 | cmd.append('--num_retries=1') |
[email protected] | f762c120 | 2014-08-13 09:36:34 | [diff] [blame] | 189 | _RunTest(options, cmd, suite) |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 190 | |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 191 | |
jbudorick | 8548f23e | 2015-05-11 14:08:14 | [diff] [blame] | 192 | def RunJunitSuite(suite): |
| 193 | RunCmd(['build/android/test_runner.py', 'junit', '-s', suite]) |
| 194 | |
| 195 | |
[email protected] | e7bd341 | 2013-09-20 17:15:28 | [diff] [blame] | 196 | def RunChromeDriverTests(options): |
[email protected] | d8897f6c | 2013-03-05 00:27:16 | [diff] [blame] | 197 | """Run all the steps for running chromedriver tests.""" |
[email protected] | b387389 | 2013-07-10 04:57:10 | [diff] [blame] | 198 | bb_annotations.PrintNamedStep('chromedriver_annotation') |
[email protected] | d8897f6c | 2013-03-05 00:27:16 | [diff] [blame] | 199 | RunCmd(['chrome/test/chromedriver/run_buildbot_steps.py', |
[email protected] | b1010d26 | 2013-11-27 22:01:28 | [diff] [blame] | 200 | '--android-packages=%s,%s,%s,%s' % |
[email protected] | efeb59e | 2014-03-12 01:31:26 | [diff] [blame] | 201 | ('chrome_shell', |
[email protected] | 4418f02 | 2013-11-11 19:21:03 | [diff] [blame] | 202 | 'chrome_stable', |
[email protected] | b1010d26 | 2013-11-27 22:01:28 | [diff] [blame] | 203 | 'chrome_beta', |
| 204 | 'chromedriver_webview_shell'), |
[email protected] | e7bd341 | 2013-09-20 17:15:28 | [diff] [blame] | 205 | '--revision=%s' % _GetRevision(options), |
[email protected] | fde0700 | 2013-09-20 21:02:39 | [diff] [blame] | 206 | '--update-log']) |
[email protected] | d8897f6c | 2013-03-05 00:27:16 | [diff] [blame] | 207 | |
[email protected] | 0377909 | 2014-07-24 11:44:27 | [diff] [blame] | 208 | def RunChromeProxyTests(options): |
| 209 | """Run the chrome_proxy tests. |
| 210 | |
| 211 | Args: |
| 212 | options: options object. |
| 213 | """ |
| 214 | InstallApk(options, INSTRUMENTATION_TESTS['ChromeShell'], False) |
| 215 | args = ['--browser', 'android-chrome-shell'] |
| 216 | devices = android_commands.GetAttachedDevices() |
| 217 | if devices: |
| 218 | args = args + ['--device', devices[0]] |
| 219 | bb_annotations.PrintNamedStep('chrome_proxy') |
| 220 | RunCmd(['tools/chrome_proxy/run_tests'] + args) |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 221 | |
mikecase | 0178d48 | 2014-08-27 21:58:18 | [diff] [blame] | 222 | |
navabi | 4167dc6 | 2014-11-21 01:25:08 | [diff] [blame] | 223 | def RunTelemetryTests(options, step_name, run_tests_path): |
navabi | 40c05fc | 2014-11-20 18:09:45 | [diff] [blame] | 224 | """Runs either telemetry_perf_unittests or telemetry_unittests. |
[email protected] | 29f7e7c | 2014-04-24 00:55:22 | [diff] [blame] | 225 | |
| 226 | Args: |
| 227 | options: options object. |
navabi | 4167dc6 | 2014-11-21 01:25:08 | [diff] [blame] | 228 | step_name: either 'telemetry_unittests' or 'telemetry_perf_unittests' |
navabi | 40c05fc | 2014-11-20 18:09:45 | [diff] [blame] | 229 | run_tests_path: path to run_tests script (tools/perf/run_tests for |
| 230 | perf_unittests and tools/telemetry/run_tests for |
| 231 | telemetry_unittests) |
[email protected] | 29f7e7c | 2014-04-24 00:55:22 | [diff] [blame] | 232 | """ |
| 233 | InstallApk(options, INSTRUMENTATION_TESTS['ChromeShell'], False) |
[email protected] | 5af43ef | 2014-06-04 17:40:06 | [diff] [blame] | 234 | args = ['--browser', 'android-chrome-shell'] |
[email protected] | 29f7e7c | 2014-04-24 00:55:22 | [diff] [blame] | 235 | devices = android_commands.GetAttachedDevices() |
| 236 | if devices: |
zhenw | 937b6c98 | 2015-03-03 23:05:57 | [diff] [blame] | 237 | args = args + ['--device', 'android'] |
navabi | 4167dc6 | 2014-11-21 01:25:08 | [diff] [blame] | 238 | bb_annotations.PrintNamedStep(step_name) |
navabi | 40c05fc | 2014-11-20 18:09:45 | [diff] [blame] | 239 | RunCmd([run_tests_path] + args) |
[email protected] | 29f7e7c | 2014-04-24 00:55:22 | [diff] [blame] | 240 | |
| 241 | |
[email protected] | a2a72524 | 2013-01-09 21:52:57 | [diff] [blame] | 242 | def InstallApk(options, test, print_step=False): |
| 243 | """Install an apk to all phones. |
| 244 | |
| 245 | Args: |
| 246 | options: options object |
| 247 | test: An I_TEST namedtuple |
| 248 | print_step: Print a buildbot step |
| 249 | """ |
| 250 | if print_step: |
[email protected] | b387389 | 2013-07-10 04:57:10 | [diff] [blame] | 251 | bb_annotations.PrintNamedStep('install_%s' % test.name.lower()) |
[email protected] | 6ca5751 | 2013-08-23 21:42:04 | [diff] [blame] | 252 | |
[email protected] | 068b9cb4 | 2014-06-08 20:11:16 | [diff] [blame] | 253 | args = ['--apk_package', test.apk_package] |
[email protected] | a2a72524 | 2013-01-09 21:52:57 | [diff] [blame] | 254 | if options.target == 'Release': |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 255 | args.append('--release') |
[email protected] | 068b9cb4 | 2014-06-08 20:11:16 | [diff] [blame] | 256 | args.append(test.apk) |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 257 | |
[email protected] | 800673bf | 2013-05-14 17:15:30 | [diff] [blame] | 258 | RunCmd(['build/android/adb_install_apk.py'] + args, halt_on_failure=True) |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 259 | |
| 260 | |
[email protected] | acfaf4c | 2013-07-25 00:23:56 | [diff] [blame] | 261 | def RunInstrumentationSuite(options, test, flunk_on_failure=True, |
[email protected] | 54c2d53 | 2013-08-24 01:36:24 | [diff] [blame] | 262 | python_only=False, official_build=False): |
[email protected] | fbe2932 | 2013-07-09 09:03:26 | [diff] [blame] | 263 | """Manages an invocation of test_runner.py for instrumentation tests. |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 264 | |
| 265 | Args: |
| 266 | options: options object |
| 267 | test: An I_TEST namedtuple |
[email protected] | acfaf4c | 2013-07-25 00:23:56 | [diff] [blame] | 268 | flunk_on_failure: Flunk the step if tests fail. |
| 269 | Python: Run only host driven Python tests. |
[email protected] | 54c2d53 | 2013-08-24 01:36:24 | [diff] [blame] | 270 | official_build: Run official-build tests. |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 271 | """ |
[email protected] | b387389 | 2013-07-10 04:57:10 | [diff] [blame] | 272 | bb_annotations.PrintNamedStep('%s_instrumentation_tests' % test.name.lower()) |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 273 | |
[email protected] | 10955d3 | 2014-04-30 11:22:41 | [diff] [blame] | 274 | if test.apk: |
| 275 | InstallApk(options, test) |
| 276 | args = ['--test-apk', test.test_apk, '--verbose'] |
| 277 | if test.test_data: |
| 278 | args.extend(['--test_data', test.test_data]) |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 279 | if options.target == 'Release': |
| 280 | args.append('--release') |
| 281 | if options.asan: |
| 282 | args.append('--tool=asan') |
[email protected] | 14f139f4 | 2013-07-24 18:41:58 | [diff] [blame] | 283 | if options.flakiness_server: |
[email protected] | b796a77 | 2013-01-19 03:55:22 | [diff] [blame] | 284 | args.append('--flakiness-dashboard-server=%s' % |
[email protected] | 14f139f4 | 2013-07-24 18:41:58 | [diff] [blame] | 285 | options.flakiness_server) |
[email protected] | 485fb23 | 2013-08-22 19:56:33 | [diff] [blame] | 286 | if options.coverage_bucket: |
| 287 | args.append('--coverage-dir=%s' % options.coverage_dir) |
jbudorick | e4bb2b8 | 2015-02-09 18:35:00 | [diff] [blame] | 288 | if test.isolate_file_path: |
| 289 | args.append('--isolate-file-path=%s' % test.isolate_file_path) |
[email protected] | 8d8ca04 | 2013-02-14 19:29:17 | [diff] [blame] | 290 | if test.host_driven_root: |
[email protected] | 67954f82 | 2013-08-14 18:09:08 | [diff] [blame] | 291 | args.append('--host-driven-root=%s' % test.host_driven_root) |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 292 | if test.annotation: |
| 293 | args.extend(['-A', test.annotation]) |
| 294 | if test.exclude_annotation: |
| 295 | args.extend(['-E', test.exclude_annotation]) |
| 296 | if test.extra_flags: |
| 297 | args.extend(test.extra_flags) |
[email protected] | acfaf4c | 2013-07-25 00:23:56 | [diff] [blame] | 298 | if python_only: |
| 299 | args.append('-p') |
[email protected] | 54c2d53 | 2013-08-24 01:36:24 | [diff] [blame] | 300 | if official_build: |
| 301 | # The option needs to be assigned 'True' as it does not have an action |
| 302 | # associated with it. |
| 303 | args.append('--official-build') |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 304 | |
[email protected] | bdd22ff | 2013-07-17 17:21:12 | [diff] [blame] | 305 | RunCmd(['build/android/test_runner.py', 'instrumentation'] + args, |
| 306 | flunk_on_failure=flunk_on_failure) |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 307 | |
| 308 | |
fdegans | 7b06b61 | 2014-09-26 09:50:53 | [diff] [blame] | 309 | def RunWebkitLint(): |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 310 | """Lint WebKit's TestExpectation files.""" |
[email protected] | b387389 | 2013-07-10 04:57:10 | [diff] [blame] | 311 | bb_annotations.PrintNamedStep('webkit_lint') |
dpranke | ec3eb0a | 2014-09-26 21:42:56 | [diff] [blame] | 312 | RunCmd([SrcPath(os.path.join(BLINK_SCRIPTS_DIR, 'lint-test-expectations'))]) |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 313 | |
| 314 | |
| 315 | def RunWebkitLayoutTests(options): |
| 316 | """Run layout tests on an actual device.""" |
[email protected] | b387389 | 2013-07-10 04:57:10 | [diff] [blame] | 317 | bb_annotations.PrintNamedStep('webkit_tests') |
[email protected] | 22ee700 | 2013-01-23 20:58:04 | [diff] [blame] | 318 | cmd_args = [ |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 319 | '--no-show-results', |
| 320 | '--no-new-test-results', |
| 321 | '--full-results-html', |
| 322 | '--clobber-old-results', |
| 323 | '--exit-after-n-failures', '5000', |
| 324 | '--exit-after-n-crashes-or-timeouts', '100', |
| 325 | '--debug-rwt-logging', |
| 326 | '--results-directory', '../layout-test-results', |
| 327 | '--target', options.target, |
| 328 | '--builder-name', options.build_properties.get('buildername', ''), |
| 329 | '--build-number', str(options.build_properties.get('buildnumber', '')), |
| 330 | '--master-name', 'ChromiumWebkit', # TODO: Get this from the cfg. |
| 331 | '--build-name', options.build_properties.get('buildername', ''), |
| 332 | '--platform=android'] |
[email protected] | 22ee700 | 2013-01-23 20:58:04 | [diff] [blame] | 333 | |
hendrikw | 1904804a | 2015-04-17 18:44:51 | [diff] [blame] | 334 | for flag in 'test_results_server', 'driver_name', 'additional_driver_flag': |
[email protected] | 22ee700 | 2013-01-23 20:58:04 | [diff] [blame] | 335 | if flag in options.factory_properties: |
| 336 | cmd_args.extend(['--%s' % flag.replace('_', '-'), |
| 337 | options.factory_properties.get(flag)]) |
| 338 | |
[email protected] | 2c39b29 | 2013-03-20 09:34:10 | [diff] [blame] | 339 | for f in options.factory_properties.get('additional_expectations', []): |
| 340 | cmd_args.extend( |
[email protected] | dc8ec3f | 2013-09-07 07:18:14 | [diff] [blame] | 341 | ['--additional-expectations=%s' % os.path.join(CHROME_SRC_DIR, *f)]) |
[email protected] | 2c39b29 | 2013-03-20 09:34:10 | [diff] [blame] | 342 | |
| 343 | # TODO(dpranke): Remove this block after |
| 344 | # https://codereview.chromium.org/12927002/ lands. |
[email protected] | 22ee700 | 2013-01-23 20:58:04 | [diff] [blame] | 345 | for f in options.factory_properties.get('additional_expectations_files', []): |
[email protected] | 62c5b98 | 2013-01-26 08:23:16 | [diff] [blame] | 346 | cmd_args.extend( |
[email protected] | dc8ec3f | 2013-09-07 07:18:14 | [diff] [blame] | 347 | ['--additional-expectations=%s' % os.path.join(CHROME_SRC_DIR, *f)]) |
[email protected] | 22ee700 | 2013-01-23 20:58:04 | [diff] [blame] | 348 | |
ager | 158f284 | 2014-09-26 06:07:24 | [diff] [blame] | 349 | exit_code = RunCmd( |
dpranke | ec3eb0a | 2014-09-26 21:42:56 | [diff] [blame] | 350 | [SrcPath(os.path.join(BLINK_SCRIPTS_DIR, 'run-webkit-tests'))] + cmd_args) |
[email protected] | 1782ef4 | 2013-10-18 21:07:33 | [diff] [blame] | 351 | if exit_code == 255: # test_run_results.UNEXPECTED_ERROR_EXIT_STATUS |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 352 | bb_annotations.PrintMsg('?? (crashed or hung)') |
[email protected] | 1782ef4 | 2013-10-18 21:07:33 | [diff] [blame] | 353 | elif exit_code == 254: # test_run_results.NO_DEVICES_EXIT_STATUS |
[email protected] | 361229ac | 2013-10-17 18:57:15 | [diff] [blame] | 354 | bb_annotations.PrintMsg('?? (no devices found)') |
[email protected] | 1782ef4 | 2013-10-18 21:07:33 | [diff] [blame] | 355 | elif exit_code == 253: # test_run_results.NO_TESTS_EXIT_STATUS |
[email protected] | 361229ac | 2013-10-17 18:57:15 | [diff] [blame] | 356 | bb_annotations.PrintMsg('?? (no tests found)') |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 357 | else: |
| 358 | full_results_path = os.path.join('..', 'layout-test-results', |
| 359 | 'full_results.json') |
| 360 | if os.path.exists(full_results_path): |
| 361 | full_results = json.load(open(full_results_path)) |
[email protected] | e2782b8 | 2013-10-14 19:43:45 | [diff] [blame] | 362 | unexpected_passes, unexpected_failures, unexpected_flakes = ( |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 363 | _ParseLayoutTestResults(full_results)) |
| 364 | if unexpected_failures: |
dpranke | d7cae31 | 2015-02-08 02:40:54 | [diff] [blame] | 365 | _PrintDashboardLink('failed', unexpected_failures.keys(), |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 366 | max_tests=25) |
| 367 | elif unexpected_passes: |
dpranke | d7cae31 | 2015-02-08 02:40:54 | [diff] [blame] | 368 | _PrintDashboardLink('unexpected passes', unexpected_passes.keys(), |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 369 | max_tests=10) |
| 370 | if unexpected_flakes: |
dpranke | d7cae31 | 2015-02-08 02:40:54 | [diff] [blame] | 371 | _PrintDashboardLink('unexpected flakes', unexpected_flakes.keys(), |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 372 | max_tests=10) |
[email protected] | bc14cb1 | 2013-10-10 18:47:14 | [diff] [blame] | 373 | |
| 374 | if exit_code == 0 and (unexpected_passes or unexpected_flakes): |
| 375 | # If exit_code != 0, RunCmd() will have already printed an error. |
| 376 | bb_annotations.PrintWarning() |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 377 | else: |
[email protected] | bc14cb1 | 2013-10-10 18:47:14 | [diff] [blame] | 378 | bb_annotations.PrintError() |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 379 | bb_annotations.PrintMsg('?? (results missing)') |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 380 | |
[email protected] | dc8ec3f | 2013-09-07 07:18:14 | [diff] [blame] | 381 | if options.factory_properties.get('archive_webkit_results', False): |
| 382 | bb_annotations.PrintNamedStep('archive_webkit_results') |
[email protected] | 613e5a3 | 2013-09-18 01:46:32 | [diff] [blame] | 383 | base = 'https://storage.googleapis.com/chromium-layout-test-archives' |
| 384 | builder_name = options.build_properties.get('buildername', '') |
| 385 | build_number = str(options.build_properties.get('buildnumber', '')) |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 386 | results_link = '%s/%s/%s/layout-test-results/results.html' % ( |
| 387 | base, EscapeBuilderName(builder_name), build_number) |
| 388 | bb_annotations.PrintLink('results', results_link) |
[email protected] | e2107bd | 2013-09-18 05:13:10 | [diff] [blame] | 389 | bb_annotations.PrintLink('(zip)', '%s/%s/%s/layout-test-results.zip' % ( |
| 390 | base, EscapeBuilderName(builder_name), build_number)) |
[email protected] | 85db7daf3 | 2013-09-09 21:21:25 | [diff] [blame] | 391 | gs_bucket = 'gs://chromium-layout-test-archives' |
[email protected] | dc8ec3f | 2013-09-07 07:18:14 | [diff] [blame] | 392 | RunCmd([os.path.join(SLAVE_SCRIPTS_DIR, 'chromium', |
| 393 | 'archive_layout_test_results.py'), |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 394 | '--results-dir', '../../layout-test-results', |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 395 | '--build-number', build_number, |
| 396 | '--builder-name', builder_name, |
[email protected] | ae41072 | 2013-10-24 15:57:36 | [diff] [blame] | 397 | '--gs-bucket', gs_bucket], |
| 398 | cwd=DIR_BUILD_ROOT) |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 399 | |
| 400 | |
| 401 | def _ParseLayoutTestResults(results): |
| 402 | """Extract the failures from the test run.""" |
| 403 | # Cloned from third_party/WebKit/Tools/Scripts/print-json-test-results |
| 404 | tests = _ConvertTrieToFlatPaths(results['tests']) |
| 405 | failures = {} |
| 406 | flakes = {} |
| 407 | passes = {} |
| 408 | for (test, result) in tests.iteritems(): |
| 409 | if result.get('is_unexpected'): |
[email protected] | ff81fe11 | 2013-10-22 21:13:16 | [diff] [blame] | 410 | actual_results = result['actual'].split() |
| 411 | expected_results = result['expected'].split() |
| 412 | if len(actual_results) > 1: |
| 413 | # We report the first failure type back, even if the second |
| 414 | # was more severe. |
| 415 | if actual_results[1] in expected_results: |
| 416 | flakes[test] = actual_results[0] |
| 417 | else: |
| 418 | failures[test] = actual_results[0] |
| 419 | elif actual_results[0] == 'PASS': |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 420 | passes[test] = result |
| 421 | else: |
[email protected] | ff81fe11 | 2013-10-22 21:13:16 | [diff] [blame] | 422 | failures[test] = actual_results[0] |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 423 | |
| 424 | return (passes, failures, flakes) |
| 425 | |
| 426 | |
| 427 | def _ConvertTrieToFlatPaths(trie, prefix=None): |
| 428 | """Flatten the trie of failures into a list.""" |
| 429 | # Cloned from third_party/WebKit/Tools/Scripts/print-json-test-results |
| 430 | result = {} |
| 431 | for name, data in trie.iteritems(): |
| 432 | if prefix: |
| 433 | name = prefix + '/' + name |
| 434 | |
| 435 | if len(data) and 'actual' not in data and 'expected' not in data: |
| 436 | result.update(_ConvertTrieToFlatPaths(data, name)) |
| 437 | else: |
| 438 | result[name] = data |
| 439 | |
| 440 | return result |
| 441 | |
| 442 | |
| 443 | def _PrintDashboardLink(link_text, tests, max_tests): |
| 444 | """Add a link to the flakiness dashboard in the step annotations.""" |
| 445 | if len(tests) > max_tests: |
| 446 | test_list_text = ' '.join(tests[:max_tests]) + ' and more' |
| 447 | else: |
| 448 | test_list_text = ' '.join(tests) |
| 449 | |
| 450 | dashboard_base = ('http://test-results.appspot.com' |
| 451 | '/dashboards/flakiness_dashboard.html#' |
| 452 | 'master=ChromiumWebkit&tests=') |
| 453 | |
| 454 | bb_annotations.PrintLink('%d %s: %s' % |
| 455 | (len(tests), link_text, test_list_text), |
| 456 | dashboard_base + ','.join(tests)) |
[email protected] | dc8ec3f | 2013-09-07 07:18:14 | [diff] [blame] | 457 | |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 458 | |
[email protected] | e2107bd | 2013-09-18 05:13:10 | [diff] [blame] | 459 | def EscapeBuilderName(builder_name): |
| 460 | return re.sub('[ ()]', '_', builder_name) |
| 461 | |
| 462 | |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 463 | def SpawnLogcatMonitor(): |
| 464 | shutil.rmtree(LOGCAT_DIR, ignore_errors=True) |
[email protected] | 97d1032 | 2013-10-04 20:53:04 | [diff] [blame] | 465 | bb_utils.SpawnCmd([ |
[email protected] | dc8ec3f | 2013-09-07 07:18:14 | [diff] [blame] | 466 | os.path.join(CHROME_SRC_DIR, 'build', 'android', 'adb_logcat_monitor.py'), |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 467 | LOGCAT_DIR]) |
| 468 | |
| 469 | # Wait for logcat_monitor to pull existing logcat |
| 470 | RunCmd(['sleep', '5']) |
| 471 | |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 472 | |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 473 | def ProvisionDevices(options): |
[email protected] | b387389 | 2013-07-10 04:57:10 | [diff] [blame] | 474 | bb_annotations.PrintNamedStep('provision_devices') |
[email protected] | abfec37 | 2013-08-16 07:22:16 | [diff] [blame] | 475 | |
| 476 | if not bb_utils.TESTING: |
| 477 | # Restart adb to work around bugs, sleep to wait for usb discovery. |
[email protected] | 781c58a | 2014-05-14 05:32:16 | [diff] [blame] | 478 | device_utils.RestartServer() |
[email protected] | abfec37 | 2013-08-16 07:22:16 | [diff] [blame] | 479 | RunCmd(['sleep', '1']) |
[email protected] | 7849a33 | 2013-07-12 01:40:09 | [diff] [blame] | 480 | provision_cmd = ['build/android/provision_devices.py', '-t', options.target] |
| 481 | if options.auto_reconnect: |
| 482 | provision_cmd.append('--auto-reconnect') |
[email protected] | 3356038b | 2014-06-17 02:40:13 | [diff] [blame] | 483 | if options.skip_wipe: |
| 484 | provision_cmd.append('--skip-wipe') |
jbudorick | 9669e5b | 2015-03-09 16:29:07 | [diff] [blame] | 485 | if options.disable_location: |
| 486 | provision_cmd.append('--disable-location') |
[email protected] | 7b54a872 | 2014-07-17 21:51:21 | [diff] [blame] | 487 | RunCmd(provision_cmd, halt_on_failure=True) |
[email protected] | 78af871 | 2013-01-14 10:37:12 | [diff] [blame] | 488 | |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 489 | |
[email protected] | e5d85a7 | 2013-10-19 13:44:02 | [diff] [blame] | 490 | def DeviceStatusCheck(options): |
[email protected] | b387389 | 2013-07-10 04:57:10 | [diff] [blame] | 491 | bb_annotations.PrintNamedStep('device_status_check') |
[email protected] | e5d85a7 | 2013-10-19 13:44:02 | [diff] [blame] | 492 | cmd = ['build/android/buildbot/bb_device_status_check.py'] |
| 493 | if options.restart_usb: |
| 494 | cmd.append('--restart-usb') |
| 495 | RunCmd(cmd, halt_on_failure=True) |
[email protected] | 693c54d | 2013-01-09 19:41:25 | [diff] [blame] | 496 | |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 497 | |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 498 | def GetDeviceSetupStepCmds(): |
| 499 | return [ |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 500 | ('device_status_check', DeviceStatusCheck), |
[email protected] | 917cd320b | 2013-12-03 16:13:35 | [diff] [blame] | 501 | ('provision_devices', ProvisionDevices), |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 502 | ] |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 503 | |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 504 | |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 505 | def RunUnitTests(options): |
[email protected] | 502362c7 | 2014-02-26 07:06:44 | [diff] [blame] | 506 | suites = gtest_config.STABLE_TEST_SUITES |
| 507 | if options.asan: |
| 508 | suites = [s for s in suites |
| 509 | if s not in gtest_config.ASAN_EXCLUDED_TEST_SUITES] |
| 510 | RunTestSuites(options, suites) |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 511 | |
| 512 | |
klundberg | b07e8ed9 | 2014-11-19 16:53:11 | [diff] [blame] | 513 | def RunTelemetryUnitTests(options): |
navabi | 4167dc6 | 2014-11-21 01:25:08 | [diff] [blame] | 514 | RunTelemetryTests(options, 'telemetry_unittests', 'tools/telemetry/run_tests') |
klundberg | b07e8ed9 | 2014-11-19 16:53:11 | [diff] [blame] | 515 | |
| 516 | |
navabi | 40c05fc | 2014-11-20 18:09:45 | [diff] [blame] | 517 | def RunTelemetryPerfUnitTests(options): |
navabi | 4167dc6 | 2014-11-21 01:25:08 | [diff] [blame] | 518 | RunTelemetryTests(options, 'telemetry_perf_unittests', 'tools/perf/run_tests') |
| 519 | |
navabi | 40c05fc | 2014-11-20 18:09:45 | [diff] [blame] | 520 | |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 521 | def RunInstrumentationTests(options): |
| 522 | for test in INSTRUMENTATION_TESTS.itervalues(): |
| 523 | RunInstrumentationSuite(options, test) |
| 524 | |
| 525 | |
| 526 | def RunWebkitTests(options): |
[email protected] | 130d0b57 | 2014-02-03 18:09:01 | [diff] [blame] | 527 | RunTestSuites(options, ['webkit_unit_tests', 'blink_heap_unittests']) |
fdegans | 7b06b61 | 2014-09-26 09:50:53 | [diff] [blame] | 528 | RunWebkitLint() |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 529 | |
| 530 | |
[email protected] | a4b1ec97 | 2013-09-14 05:36:25 | [diff] [blame] | 531 | def RunGPUTests(options): |
[email protected] | 9047cd18 | 2014-05-29 01:04:06 | [diff] [blame] | 532 | revision = _GetRevision(options) |
[email protected] | 5117f5d | 2014-05-29 16:59:16 | [diff] [blame] | 533 | builder_name = options.build_properties.get('buildername', 'noname') |
| 534 | |
| 535 | bb_annotations.PrintNamedStep('pixel_tests') |
[email protected] | 389234f | 2014-02-25 03:31:12 | [diff] [blame] | 536 | RunCmd(['content/test/gpu/run_gpu_test.py', |
[email protected] | e66b592 | 2014-01-07 20:10:04 | [diff] [blame] | 537 | 'pixel', |
| 538 | '--browser', |
| 539 | 'android-content-shell', |
| 540 | '--build-revision', |
| 541 | str(revision), |
| 542 | '--upload-refimg-to-cloud-storage', |
| 543 | '--refimg-cloud-storage-bucket', |
| 544 | 'chromium-gpu-archive/reference-images', |
| 545 | '--os-type', |
| 546 | 'android', |
| 547 | '--test-machine-name', |
[email protected] | 5117f5d | 2014-05-29 16:59:16 | [diff] [blame] | 548 | EscapeBuilderName(builder_name)]) |
[email protected] | fb9cd4bb | 2013-10-16 21:59:53 | [diff] [blame] | 549 | |
[email protected] | cce70f0 | 2013-10-15 12:53:19 | [diff] [blame] | 550 | bb_annotations.PrintNamedStep('webgl_conformance_tests') |
[email protected] | 389234f | 2014-02-25 03:31:12 | [diff] [blame] | 551 | RunCmd(['content/test/gpu/run_gpu_test.py', |
[email protected] | cce70f0 | 2013-10-15 12:53:19 | [diff] [blame] | 552 | '--browser=android-content-shell', 'webgl_conformance', |
| 553 | '--webgl-conformance-version=1.0.1']) |
[email protected] | bb508f8 | 2013-09-06 06:42:24 | [diff] [blame] | 554 | |
sievers | b44610f | 2015-05-05 23:06:17 | [diff] [blame] | 555 | bb_annotations.PrintNamedStep('android_webview_webgl_conformance_tests') |
| 556 | RunCmd(['content/test/gpu/run_gpu_test.py', |
| 557 | '--browser=android-webview-shell', 'webgl_conformance', |
| 558 | '--webgl-conformance-version=1.0.1']) |
| 559 | |
[email protected] | 876cb60 | 2014-05-31 04:49:15 | [diff] [blame] | 560 | bb_annotations.PrintNamedStep('gpu_rasterization_tests') |
| 561 | RunCmd(['content/test/gpu/run_gpu_test.py', |
| 562 | 'gpu_rasterization', |
| 563 | '--browser', |
| 564 | 'android-content-shell', |
| 565 | '--build-revision', |
| 566 | str(revision), |
| 567 | '--test-machine-name', |
| 568 | EscapeBuilderName(builder_name)]) |
| 569 | |
[email protected] | bb508f8 | 2013-09-06 06:42:24 | [diff] [blame] | 570 | |
jbudorick | 256fd53 | 2014-10-24 01:50:13 | [diff] [blame] | 571 | def RunPythonUnitTests(_options): |
| 572 | for suite in constants.PYTHON_UNIT_TEST_SUITES: |
| 573 | bb_annotations.PrintNamedStep(suite) |
| 574 | RunCmd(['build/android/test_runner.py', 'python', '-s', suite]) |
| 575 | |
| 576 | |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 577 | def GetTestStepCmds(): |
| 578 | return [ |
jbudorick | 8548f23e | 2015-05-11 14:08:14 | [diff] [blame] | 579 | ('base_junit_tests', |
| 580 | lambda _options: RunJunitSuite('base_junit_tests')), |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 581 | ('chromedriver', RunChromeDriverTests), |
[email protected] | 0377909 | 2014-07-24 11:44:27 | [diff] [blame] | 582 | ('chrome_proxy', RunChromeProxyTests), |
jbudorick | c4b6b651 | 2015-04-23 21:30:28 | [diff] [blame] | 583 | ('components_browsertests', |
| 584 | lambda options: RunTestSuites(options, ['components_browsertests'])), |
tfarina | 43d9353 | 2015-05-11 18:04:07 | [diff] [blame] | 585 | ('gfx_unittests', |
| 586 | lambda options: RunTestSuites(options, ['gfx_unittests'])), |
[email protected] | bb508f8 | 2013-09-06 06:42:24 | [diff] [blame] | 587 | ('gpu', RunGPUTests), |
jbudorick | 256fd53 | 2014-10-24 01:50:13 | [diff] [blame] | 588 | ('python_unittests', RunPythonUnitTests), |
klundberg | b07e8ed9 | 2014-11-19 16:53:11 | [diff] [blame] | 589 | ('telemetry_unittests', RunTelemetryUnitTests), |
[email protected] | 29f7e7c | 2014-04-24 00:55:22 | [diff] [blame] | 590 | ('telemetry_perf_unittests', RunTelemetryPerfUnitTests), |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 591 | ('ui', RunInstrumentationTests), |
mikecase | 0178d48 | 2014-08-27 21:58:18 | [diff] [blame] | 592 | ('unit', RunUnitTests), |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 593 | ('webkit', RunWebkitTests), |
[email protected] | 02bfada | 2013-08-12 05:00:52 | [diff] [blame] | 594 | ('webkit_layout', RunWebkitLayoutTests), |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 595 | ] |
| 596 | |
| 597 | |
[email protected] | c11a468 | 2014-04-22 23:04:13 | [diff] [blame] | 598 | def MakeGSPath(options, gs_base_dir): |
| 599 | revision = _GetRevision(options) |
| 600 | bot_id = options.build_properties.get('buildername', 'testing') |
| 601 | randhash = hashlib.sha1(str(random.random())).hexdigest() |
| 602 | gs_path = '%s/%s/%s/%s' % (gs_base_dir, bot_id, revision, randhash) |
[email protected] | c79bc8a | 2014-04-24 03:39:52 | [diff] [blame] | 603 | # remove double slashes, happens with blank revisions and confuses gsutil |
| 604 | gs_path = re.sub('/+', '/', gs_path) |
[email protected] | c11a468 | 2014-04-22 23:04:13 | [diff] [blame] | 605 | return gs_path |
| 606 | |
[email protected] | 4e622cee | 2013-09-17 18:32:12 | [diff] [blame] | 607 | def UploadHTML(options, gs_base_dir, dir_to_upload, link_text, |
| 608 | link_rel_path='index.html', gs_url=GS_URL): |
| 609 | """Uploads directory at |dir_to_upload| to Google Storage and output a link. |
[email protected] | 485fb23 | 2013-08-22 19:56:33 | [diff] [blame] | 610 | |
| 611 | Args: |
| 612 | options: Command line options. |
[email protected] | 4e622cee | 2013-09-17 18:32:12 | [diff] [blame] | 613 | gs_base_dir: The Google Storage base directory (e.g. |
| 614 | 'chromium-code-coverage/java') |
| 615 | dir_to_upload: Absolute path to the directory to be uploaded. |
| 616 | link_text: Link text to be displayed on the step. |
| 617 | link_rel_path: Link path relative to |dir_to_upload|. |
| 618 | gs_url: Google storage URL. |
[email protected] | 485fb23 | 2013-08-22 19:56:33 | [diff] [blame] | 619 | """ |
[email protected] | c11a468 | 2014-04-22 23:04:13 | [diff] [blame] | 620 | gs_path = MakeGSPath(options, gs_base_dir) |
[email protected] | 4e622cee | 2013-09-17 18:32:12 | [diff] [blame] | 621 | RunCmd([bb_utils.GSUTIL_PATH, 'cp', '-R', dir_to_upload, 'gs://%s' % gs_path]) |
| 622 | bb_annotations.PrintLink(link_text, |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 623 | '%s/%s/%s' % (gs_url, gs_path, link_rel_path)) |
[email protected] | 485fb23 | 2013-08-22 19:56:33 | [diff] [blame] | 624 | |
| 625 | |
| 626 | def GenerateJavaCoverageReport(options): |
| 627 | """Generates an HTML coverage report using EMMA and uploads it.""" |
| 628 | bb_annotations.PrintNamedStep('java_coverage_report') |
| 629 | |
| 630 | coverage_html = os.path.join(options.coverage_dir, 'coverage_html') |
| 631 | RunCmd(['build/android/generate_emma_html.py', |
| 632 | '--coverage-dir', options.coverage_dir, |
[email protected] | dc8ec3f | 2013-09-07 07:18:14 | [diff] [blame] | 633 | '--metadata-dir', os.path.join(CHROME_OUT_DIR, options.target), |
[email protected] | a1f1abfe | 2013-08-27 22:02:43 | [diff] [blame] | 634 | '--cleanup', |
[email protected] | 485fb23 | 2013-08-22 19:56:33 | [diff] [blame] | 635 | '--output', os.path.join(coverage_html, 'index.html')]) |
[email protected] | 4e622cee | 2013-09-17 18:32:12 | [diff] [blame] | 636 | return coverage_html |
[email protected] | 485fb23 | 2013-08-22 19:56:33 | [diff] [blame] | 637 | |
| 638 | |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 639 | def LogcatDump(options): |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 640 | # Print logcat, kill logcat monitor |
[email protected] | b387389 | 2013-07-10 04:57:10 | [diff] [blame] | 641 | bb_annotations.PrintNamedStep('logcat_dump') |
[email protected] | 6fe4d06 | 2014-05-03 00:07:30 | [diff] [blame] | 642 | logcat_file = os.path.join(CHROME_OUT_DIR, options.target, 'full_log.txt') |
jbudorick | 0f77e96 | 2014-11-19 15:41:29 | [diff] [blame] | 643 | RunCmd([SrcPath('build', 'android', 'adb_logcat_printer.py'), |
[email protected] | 46e095c | 2013-11-21 13:48:58 | [diff] [blame] | 644 | '--output-path', logcat_file, LOGCAT_DIR]) |
[email protected] | c11a468 | 2014-04-22 23:04:13 | [diff] [blame] | 645 | gs_path = MakeGSPath(options, 'chromium-android/logcat_dumps') |
[email protected] | 6fe4d06 | 2014-05-03 00:07:30 | [diff] [blame] | 646 | RunCmd([bb_utils.GSUTIL_PATH, 'cp', '-z', 'txt', logcat_file, |
| 647 | 'gs://%s' % gs_path]) |
[email protected] | c79bc8a | 2014-04-24 03:39:52 | [diff] [blame] | 648 | bb_annotations.PrintLink('logcat dump', '%s/%s' % (GS_AUTH_URL, gs_path)) |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 649 | |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 650 | |
[email protected] | 79d3d8d8 | 2014-02-05 13:47:04 | [diff] [blame] | 651 | def RunStackToolSteps(options): |
| 652 | """Run stack tool steps. |
| 653 | |
| 654 | Stack tool is run for logcat dump, optionally for ASAN. |
| 655 | """ |
| 656 | bb_annotations.PrintNamedStep('Run stack tool with logcat dump') |
[email protected] | 6fe4d06 | 2014-05-03 00:07:30 | [diff] [blame] | 657 | logcat_file = os.path.join(CHROME_OUT_DIR, options.target, 'full_log.txt') |
[email protected] | 79d3d8d8 | 2014-02-05 13:47:04 | [diff] [blame] | 658 | RunCmd([os.path.join(CHROME_SRC_DIR, 'third_party', 'android_platform', |
| 659 | 'development', 'scripts', 'stack'), |
| 660 | '--more-info', logcat_file]) |
| 661 | if options.asan_symbolize: |
| 662 | bb_annotations.PrintNamedStep('Run stack tool for ASAN') |
| 663 | RunCmd([ |
| 664 | os.path.join(CHROME_SRC_DIR, 'build', 'android', 'asan_symbolize.py'), |
| 665 | '-l', logcat_file]) |
| 666 | |
| 667 | |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 668 | def GenerateTestReport(options): |
[email protected] | b387389 | 2013-07-10 04:57:10 | [diff] [blame] | 669 | bb_annotations.PrintNamedStep('test_report') |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 670 | for report in glob.glob( |
[email protected] | dc8ec3f | 2013-09-07 07:18:14 | [diff] [blame] | 671 | os.path.join(CHROME_OUT_DIR, options.target, 'test_logs', '*.log')): |
[email protected] | 78af871 | 2013-01-14 10:37:12 | [diff] [blame] | 672 | RunCmd(['cat', report]) |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 673 | os.remove(report) |
| 674 | |
| 675 | |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 676 | def MainTestWrapper(options): |
[email protected] | 4cf098c | 2013-08-02 21:08:06 | [diff] [blame] | 677 | try: |
| 678 | # Spawn logcat monitor |
| 679 | SpawnLogcatMonitor() |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 680 | |
[email protected] | 4cf098c | 2013-08-02 21:08:06 | [diff] [blame] | 681 | # Run all device setup steps |
| 682 | for _, cmd in GetDeviceSetupStepCmds(): |
| 683 | cmd(options) |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 684 | |
[email protected] | 4cf098c | 2013-08-02 21:08:06 | [diff] [blame] | 685 | if options.install: |
jbudorick | 7da88de6 | 2014-12-03 21:46:03 | [diff] [blame] | 686 | for i in options.install: |
jbudorick | c574b1b | 2014-12-04 18:21:28 | [diff] [blame] | 687 | install_obj = INSTALLABLE_PACKAGES[i] |
| 688 | InstallApk(options, install_obj, print_step=True) |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 689 | |
[email protected] | 4cf098c | 2013-08-02 21:08:06 | [diff] [blame] | 690 | if options.test_filter: |
| 691 | bb_utils.RunSteps(options.test_filter, GetTestStepCmds(), options) |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 692 | |
[email protected] | 485fb23 | 2013-08-22 19:56:33 | [diff] [blame] | 693 | if options.coverage_bucket: |
[email protected] | 4e622cee | 2013-09-17 18:32:12 | [diff] [blame] | 694 | coverage_html = GenerateJavaCoverageReport(options) |
| 695 | UploadHTML(options, '%s/java' % options.coverage_bucket, coverage_html, |
| 696 | 'Coverage Report') |
[email protected] | ec7b222 | 2014-01-16 02:49:15 | [diff] [blame] | 697 | shutil.rmtree(coverage_html, ignore_errors=True) |
[email protected] | 485fb23 | 2013-08-22 19:56:33 | [diff] [blame] | 698 | |
[email protected] | 4cf098c | 2013-08-02 21:08:06 | [diff] [blame] | 699 | if options.experimental: |
| 700 | RunTestSuites(options, gtest_config.EXPERIMENTAL_TEST_SUITES) |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 701 | |
[email protected] | 4cf098c | 2013-08-02 21:08:06 | [diff] [blame] | 702 | finally: |
| 703 | # Run all post test steps |
| 704 | LogcatDump(options) |
[email protected] | 79d3d8d8 | 2014-02-05 13:47:04 | [diff] [blame] | 705 | if not options.disable_stack_tool: |
| 706 | RunStackToolSteps(options) |
[email protected] | 4cf098c | 2013-08-02 21:08:06 | [diff] [blame] | 707 | GenerateTestReport(options) |
| 708 | # KillHostHeartbeat() has logic to check if heartbeat process is running, |
| 709 | # and kills only if it finds the process is running on the host. |
| 710 | provision_devices.KillHostHeartbeat() |
[email protected] | 773c4f0 | 2014-08-12 19:05:22 | [diff] [blame] | 711 | if options.cleanup: |
| 712 | shutil.rmtree(os.path.join(CHROME_OUT_DIR, options.target), |
| 713 | ignore_errors=True) |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 714 | |
| 715 | |
| 716 | def GetDeviceStepsOptParser(): |
[email protected] | c528275 | 2013-06-07 23:14:39 | [diff] [blame] | 717 | parser = bb_utils.GetParser() |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 718 | parser.add_option('--experimental', action='store_true', |
| 719 | help='Run experiemental tests') |
| 720 | parser.add_option('-f', '--test-filter', metavar='<filter>', default=[], |
| 721 | action='append', |
| 722 | help=('Run a test suite. Test suites: "%s"' % |
| 723 | '", "'.join(VALID_TESTS))) |
[email protected] | 18d59b8 | 2013-11-12 09:21:41 | [diff] [blame] | 724 | parser.add_option('--gtest-filter', |
| 725 | help='Filter for running a subset of tests of a gtest test') |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 726 | parser.add_option('--asan', action='store_true', help='Run tests with asan.') |
jbudorick | 7da88de6 | 2014-12-03 21:46:03 | [diff] [blame] | 727 | parser.add_option('--install', metavar='<apk name>', action="append", |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 728 | help='Install an apk by name') |
[email protected] | 4a3375d | 2014-01-08 12:56:50 | [diff] [blame] | 729 | parser.add_option('--no-reboot', action='store_true', |
| 730 | help='Do not reboot devices during provisioning.') |
[email protected] | 485fb23 | 2013-08-22 19:56:33 | [diff] [blame] | 731 | parser.add_option('--coverage-bucket', |
| 732 | help=('Bucket name to store coverage results. Coverage is ' |
| 733 | 'only run if this is set.')) |
[email protected] | e5d85a7 | 2013-10-19 13:44:02 | [diff] [blame] | 734 | parser.add_option('--restart-usb', action='store_true', |
| 735 | help='Restart usb ports before device status check.') |
[email protected] | 14f139f4 | 2013-07-24 18:41:58 | [diff] [blame] | 736 | parser.add_option( |
| 737 | '--flakiness-server', |
[email protected] | f049a19 | 2013-10-10 01:11:26 | [diff] [blame] | 738 | help=('The flakiness dashboard server to which the results should be ' |
| 739 | 'uploaded.')) |
[email protected] | 12f36c8 | 2013-03-29 06:21:13 | [diff] [blame] | 740 | parser.add_option( |
| 741 | '--auto-reconnect', action='store_true', |
| 742 | help='Push script to device which restarts adbd on disconnections.') |
[email protected] | 3356038b | 2014-06-17 02:40:13 | [diff] [blame] | 743 | parser.add_option('--skip-wipe', action='store_true', |
| 744 | help='Do not wipe devices during provisioning.') |
jbudorick | 9669e5b | 2015-03-09 16:29:07 | [diff] [blame] | 745 | parser.add_option('--disable-location', action='store_true', |
| 746 | help='Disable location settings.') |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 747 | parser.add_option( |
| 748 | '--logcat-dump-output', |
| 749 | help='The logcat dump output will be "tee"-ed into this file') |
[email protected] | 2982604 | 2014-06-06 19:00:05 | [diff] [blame] | 750 | # During processing perf bisects, a seperate working directory created under |
| 751 | # which builds are produced. Therefore we should look for relevent output |
| 752 | # file under this directory.(/b/build/slave/<slave_name>/build/bisect/src/out) |
| 753 | parser.add_option( |
| 754 | '--chrome-output-dir', |
| 755 | help='Chrome output directory to be used while bisecting.') |
| 756 | |
jbudorick | 0f77e96 | 2014-11-19 15:41:29 | [diff] [blame] | 757 | parser.add_option('--disable-stack-tool', action='store_true', |
[email protected] | 79d3d8d8 | 2014-02-05 13:47:04 | [diff] [blame] | 758 | help='Do not run stack tool.') |
jbudorick | 0f77e96 | 2014-11-19 15:41:29 | [diff] [blame] | 759 | parser.add_option('--asan-symbolize', action='store_true', |
[email protected] | 79d3d8d8 | 2014-02-05 13:47:04 | [diff] [blame] | 760 | help='Run stack tool for ASAN') |
[email protected] | 773c4f0 | 2014-08-12 19:05:22 | [diff] [blame] | 761 | parser.add_option('--cleanup', action='store_true', |
| 762 | help='Delete out/<target> directory at the end of the run.') |
[email protected] | 7405027 | 2013-07-02 14:02:15 | [diff] [blame] | 763 | return parser |
| 764 | |
| 765 | |
| 766 | def main(argv): |
| 767 | parser = GetDeviceStepsOptParser() |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 768 | options, args = parser.parse_args(argv[1:]) |
| 769 | |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 770 | if args: |
[email protected] | c528275 | 2013-06-07 23:14:39 | [diff] [blame] | 771 | return sys.exit('Unused args %s' % args) |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 772 | |
| 773 | unknown_tests = set(options.test_filter) - VALID_TESTS |
| 774 | if unknown_tests: |
[email protected] | c528275 | 2013-06-07 23:14:39 | [diff] [blame] | 775 | return sys.exit('Unknown tests %s' % list(unknown_tests)) |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 776 | |
| 777 | setattr(options, 'target', options.factory_properties.get('target', 'Debug')) |
[email protected] | 2982604 | 2014-06-06 19:00:05 | [diff] [blame] | 778 | |
| 779 | if options.chrome_output_dir: |
| 780 | global CHROME_OUT_DIR |
| 781 | global LOGCAT_DIR |
| 782 | CHROME_OUT_DIR = options.chrome_output_dir |
| 783 | LOGCAT_DIR = os.path.join(CHROME_OUT_DIR, 'logcat') |
| 784 | |
[email protected] | 485fb23 | 2013-08-22 19:56:33 | [diff] [blame] | 785 | if options.coverage_bucket: |
| 786 | setattr(options, 'coverage_dir', |
[email protected] | dc8ec3f | 2013-09-07 07:18:14 | [diff] [blame] | 787 | os.path.join(CHROME_OUT_DIR, options.target, 'coverage')) |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 788 | |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 789 | MainTestWrapper(options) |
[email protected] | e185b7e8 | 2013-01-09 03:49:57 | [diff] [blame] | 790 | |
| 791 | |
| 792 | if __name__ == '__main__': |
| 793 | sys.exit(main(sys.argv)) |