| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import collections | 6 import collections |
| 7 import glob | 7 import glob |
| 8 import hashlib | 8 import hashlib |
| 9 import json | 9 import json |
| 10 import multiprocessing | 10 import multiprocessing |
| 11 import os | 11 import os |
| 12 import random | 12 import random |
| 13 import re | 13 import re |
| 14 import shutil | 14 import shutil |
| 15 import sys | 15 import sys |
| 16 | 16 |
| 17 import bb_utils | 17 import bb_utils |
| 18 import bb_annotations | 18 import bb_annotations |
| 19 | 19 |
| 20 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 20 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
| 21 import provision_devices | 21 import provision_devices |
| 22 from pylib import android_commands | 22 from pylib import android_commands |
| 23 from pylib import constants | 23 from pylib import constants |
| 24 from pylib.gtest import gtest_config | 24 from pylib.gtest import gtest_config |
| 25 | 25 |
| 26 CHROME_SRC_DIR = bb_utils.CHROME_SRC | 26 CHROME_SRC_DIR = bb_utils.CHROME_SRC |
| 27 DIR_BUILD_ROOT = os.path.dirname(CHROME_SRC_DIR) |
| 27 CHROME_OUT_DIR = bb_utils.CHROME_OUT_DIR | 28 CHROME_OUT_DIR = bb_utils.CHROME_OUT_DIR |
| 28 sys.path.append(os.path.join( | 29 sys.path.append(os.path.join( |
| 29 CHROME_SRC_DIR, 'third_party', 'android_testrunner')) | 30 CHROME_SRC_DIR, 'third_party', 'android_testrunner')) |
| 30 import errors | 31 import errors |
| 31 | 32 |
| 32 | 33 |
| 33 SLAVE_SCRIPTS_DIR = os.path.join(bb_utils.BB_BUILD_DIR, 'scripts', 'slave') | 34 SLAVE_SCRIPTS_DIR = os.path.join(bb_utils.BB_BUILD_DIR, 'scripts', 'slave') |
| 34 LOGCAT_DIR = os.path.join(bb_utils.CHROME_OUT_DIR, 'logcat') | 35 LOGCAT_DIR = os.path.join(bb_utils.CHROME_OUT_DIR, 'logcat') |
| 35 GS_URL = 'https://storage.googleapis.com' | 36 GS_URL = 'https://storage.googleapis.com' |
| 36 | 37 |
| 37 # Describes an instrumation test suite: | 38 # Describes an instrumation test suite: |
| 38 # test: Name of test we're running. | 39 # test: Name of test we're running. |
| 39 # apk: apk to be installed. | 40 # apk: apk to be installed. |
| 40 # apk_package: package for the apk to be installed. | 41 # apk_package: package for the apk to be installed. |
| 41 # test_apk: apk to run tests on. | 42 # test_apk: apk to run tests on. |
| 42 # test_data: data folder in format destination:source. | 43 # test_data: data folder in format destination:source. |
| 43 # host_driven_root: The host-driven test root directory. | 44 # host_driven_root: The host-driven test root directory. |
| 44 # annotation: Annotation of the tests to include. | 45 # annotation: Annotation of the tests to include. |
| 45 # exclude_annotation: The annotation of the tests to exclude. | 46 # exclude_annotation: The annotation of the tests to exclude. |
| 46 I_TEST = collections.namedtuple('InstrumentationTest', [ | 47 I_TEST = collections.namedtuple('InstrumentationTest', [ |
| 47 'name', 'apk', 'apk_package', 'test_apk', 'test_data', 'host_driven_root', | 48 'name', 'apk', 'apk_package', 'test_apk', 'test_data', 'host_driven_root', |
| 48 'annotation', 'exclude_annotation', 'extra_flags']) | 49 'annotation', 'exclude_annotation', 'extra_flags']) |
| 49 | 50 |
| 50 | 51 |
| 52 def SrcPath(*path): |
| 53 return os.path.join(CHROME_SRC_DIR, *path) |
| 54 |
| 55 |
| 51 def I(name, apk, apk_package, test_apk, test_data, host_driven_root=None, | 56 def I(name, apk, apk_package, test_apk, test_data, host_driven_root=None, |
| 52 annotation=None, exclude_annotation=None, extra_flags=None): | 57 annotation=None, exclude_annotation=None, extra_flags=None): |
| 53 return I_TEST(name, apk, apk_package, test_apk, test_data, host_driven_root, | 58 return I_TEST(name, apk, apk_package, test_apk, test_data, host_driven_root, |
| 54 annotation, exclude_annotation, extra_flags) | 59 annotation, exclude_annotation, extra_flags) |
| 55 | 60 |
| 56 INSTRUMENTATION_TESTS = dict((suite.name, suite) for suite in [ | 61 INSTRUMENTATION_TESTS = dict((suite.name, suite) for suite in [ |
| 57 I('ContentShell', | 62 I('ContentShell', |
| 58 'ContentShell.apk', | 63 'ContentShell.apk', |
| 59 'org.chromium.content_shell_apk', | 64 'org.chromium.content_shell_apk', |
| 60 'ContentShellTest', | 65 'ContentShellTest', |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 # associated with it. | 219 # associated with it. |
| 215 args.append('--official-build') | 220 args.append('--official-build') |
| 216 | 221 |
| 217 RunCmd(['build/android/test_runner.py', 'instrumentation'] + args, | 222 RunCmd(['build/android/test_runner.py', 'instrumentation'] + args, |
| 218 flunk_on_failure=flunk_on_failure) | 223 flunk_on_failure=flunk_on_failure) |
| 219 | 224 |
| 220 | 225 |
| 221 def RunWebkitLint(target): | 226 def RunWebkitLint(target): |
| 222 """Lint WebKit's TestExpectation files.""" | 227 """Lint WebKit's TestExpectation files.""" |
| 223 bb_annotations.PrintNamedStep('webkit_lint') | 228 bb_annotations.PrintNamedStep('webkit_lint') |
| 224 RunCmd(['webkit/tools/layout_tests/run_webkit_tests.py', | 229 RunCmd([SrcPath('webkit/tools/layout_tests/run_webkit_tests.py'), |
| 225 '--lint-test-files', | 230 '--lint-test-files', |
| 226 '--chromium', | 231 '--chromium', |
| 227 '--target', target]) | 232 '--target', target]) |
| 228 | 233 |
| 229 | 234 |
| 230 def RunWebkitLayoutTests(options): | 235 def RunWebkitLayoutTests(options): |
| 231 """Run layout tests on an actual device.""" | 236 """Run layout tests on an actual device.""" |
| 232 bb_annotations.PrintNamedStep('webkit_tests') | 237 bb_annotations.PrintNamedStep('webkit_tests') |
| 233 cmd_args = [ | 238 cmd_args = [ |
| 234 '--no-show-results', | 239 '--no-show-results', |
| (...skipping 19 matching lines...) Expand all Loading... |
| 254 for f in options.factory_properties.get('additional_expectations', []): | 259 for f in options.factory_properties.get('additional_expectations', []): |
| 255 cmd_args.extend( | 260 cmd_args.extend( |
| 256 ['--additional-expectations=%s' % os.path.join(CHROME_SRC_DIR, *f)]) | 261 ['--additional-expectations=%s' % os.path.join(CHROME_SRC_DIR, *f)]) |
| 257 | 262 |
| 258 # TODO(dpranke): Remove this block after | 263 # TODO(dpranke): Remove this block after |
| 259 # https://codereview.chromium.org/12927002/ lands. | 264 # https://codereview.chromium.org/12927002/ lands. |
| 260 for f in options.factory_properties.get('additional_expectations_files', []): | 265 for f in options.factory_properties.get('additional_expectations_files', []): |
| 261 cmd_args.extend( | 266 cmd_args.extend( |
| 262 ['--additional-expectations=%s' % os.path.join(CHROME_SRC_DIR, *f)]) | 267 ['--additional-expectations=%s' % os.path.join(CHROME_SRC_DIR, *f)]) |
| 263 | 268 |
| 264 exit_code = RunCmd(['webkit/tools/layout_tests/run_webkit_tests.py'] + | 269 exit_code = RunCmd([SrcPath('webkit/tools/layout_tests/run_webkit_tests.py')] |
| 265 cmd_args) | 270 + cmd_args) |
| 266 if exit_code == 255: # test_run_results.UNEXPECTED_ERROR_EXIT_STATUS | 271 if exit_code == 255: # test_run_results.UNEXPECTED_ERROR_EXIT_STATUS |
| 267 bb_annotations.PrintMsg('?? (crashed or hung)') | 272 bb_annotations.PrintMsg('?? (crashed or hung)') |
| 268 elif exit_code == 254: # test_run_results.NO_DEVICES_EXIT_STATUS | 273 elif exit_code == 254: # test_run_results.NO_DEVICES_EXIT_STATUS |
| 269 bb_annotations.PrintMsg('?? (no devices found)') | 274 bb_annotations.PrintMsg('?? (no devices found)') |
| 270 elif exit_code == 253: # test_run_results.NO_TESTS_EXIT_STATUS | 275 elif exit_code == 253: # test_run_results.NO_TESTS_EXIT_STATUS |
| 271 bb_annotations.PrintMsg('?? (no tests found)') | 276 bb_annotations.PrintMsg('?? (no tests found)') |
| 272 else: | 277 else: |
| 273 full_results_path = os.path.join('..', 'layout-test-results', | 278 full_results_path = os.path.join('..', 'layout-test-results', |
| 274 'full_results.json') | 279 'full_results.json') |
| 275 if os.path.exists(full_results_path): | 280 if os.path.exists(full_results_path): |
| (...skipping 27 matching lines...) Expand all Loading... |
| 303 bb_annotations.PrintLink('results', results_link) | 308 bb_annotations.PrintLink('results', results_link) |
| 304 bb_annotations.PrintLink('(zip)', '%s/%s/%s/layout-test-results.zip' % ( | 309 bb_annotations.PrintLink('(zip)', '%s/%s/%s/layout-test-results.zip' % ( |
| 305 base, EscapeBuilderName(builder_name), build_number)) | 310 base, EscapeBuilderName(builder_name), build_number)) |
| 306 gs_bucket = 'gs://chromium-layout-test-archives' | 311 gs_bucket = 'gs://chromium-layout-test-archives' |
| 307 RunCmd([os.path.join(SLAVE_SCRIPTS_DIR, 'chromium', | 312 RunCmd([os.path.join(SLAVE_SCRIPTS_DIR, 'chromium', |
| 308 'archive_layout_test_results.py'), | 313 'archive_layout_test_results.py'), |
| 309 '--results-dir', '../../layout-test-results', | 314 '--results-dir', '../../layout-test-results', |
| 310 '--build-dir', CHROME_OUT_DIR, | 315 '--build-dir', CHROME_OUT_DIR, |
| 311 '--build-number', build_number, | 316 '--build-number', build_number, |
| 312 '--builder-name', builder_name, | 317 '--builder-name', builder_name, |
| 313 '--gs-bucket', gs_bucket]) | 318 '--gs-bucket', gs_bucket], |
| 319 cwd=DIR_BUILD_ROOT) |
| 314 | 320 |
| 315 | 321 |
| 316 def _ParseLayoutTestResults(results): | 322 def _ParseLayoutTestResults(results): |
| 317 """Extract the failures from the test run.""" | 323 """Extract the failures from the test run.""" |
| 318 # Cloned from third_party/WebKit/Tools/Scripts/print-json-test-results | 324 # Cloned from third_party/WebKit/Tools/Scripts/print-json-test-results |
| 319 tests = _ConvertTrieToFlatPaths(results['tests']) | 325 tests = _ConvertTrieToFlatPaths(results['tests']) |
| 320 failures = {} | 326 failures = {} |
| 321 flakes = {} | 327 flakes = {} |
| 322 passes = {} | 328 passes = {} |
| 323 for (test, result) in tests.iteritems(): | 329 for (test, result) in tests.iteritems(): |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) | 605 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) |
| 600 if options.coverage_bucket: | 606 if options.coverage_bucket: |
| 601 setattr(options, 'coverage_dir', | 607 setattr(options, 'coverage_dir', |
| 602 os.path.join(CHROME_OUT_DIR, options.target, 'coverage')) | 608 os.path.join(CHROME_OUT_DIR, options.target, 'coverage')) |
| 603 | 609 |
| 604 MainTestWrapper(options) | 610 MainTestWrapper(options) |
| 605 | 611 |
| 606 | 612 |
| 607 if __name__ == '__main__': | 613 if __name__ == '__main__': |
| 608 sys.exit(main(sys.argv)) | 614 sys.exit(main(sys.argv)) |
| OLD | NEW |