| 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 multiprocessing | 9 import multiprocessing |
| 10 import os | 10 import os |
| 11 import random | 11 import random |
| 12 import shutil | 12 import shutil |
| 13 import sys | 13 import sys |
| 14 | 14 |
| 15 import bb_utils | 15 import bb_utils |
| 16 import bb_annotations | 16 import bb_annotations |
| 17 | 17 |
| 18 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 18 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
| 19 import provision_devices | 19 import provision_devices |
| 20 from pylib import android_commands | 20 from pylib import android_commands |
| 21 from pylib import constants | 21 from pylib import constants |
| 22 from pylib.gtest import gtest_config | 22 from pylib.gtest import gtest_config |
| 23 | 23 |
| 24 CHROME_SRC_DIR = bb_utils.CHROME_SRC | |
| 25 CHROME_OUT_DIR = bb_utils.CHROME_OUT_DIR | |
| 26 sys.path.append(os.path.join( | 24 sys.path.append(os.path.join( |
| 27 CHROME_SRC_DIR, 'third_party', 'android_testrunner')) | 25 constants.DIR_SOURCE_ROOT, 'third_party', 'android_testrunner')) |
| 28 import errors | 26 import errors |
| 29 | 27 |
| 30 | 28 |
| 31 SLAVE_SCRIPTS_DIR = os.path.join(bb_utils.BB_BUILD_DIR, 'scripts', 'slave') | 29 CHROME_SRC = constants.DIR_SOURCE_ROOT |
| 32 LOGCAT_DIR = os.path.join(bb_utils.CHROME_OUT_DIR, 'logcat') | 30 LOGCAT_DIR = os.path.join(CHROME_SRC, 'out', 'logcat') |
| 33 | 31 |
| 34 # Describes an instrumation test suite: | 32 # Describes an instrumation test suite: |
| 35 # test: Name of test we're running. | 33 # test: Name of test we're running. |
| 36 # apk: apk to be installed. | 34 # apk: apk to be installed. |
| 37 # apk_package: package for the apk to be installed. | 35 # apk_package: package for the apk to be installed. |
| 38 # test_apk: apk to run tests on. | 36 # test_apk: apk to run tests on. |
| 39 # test_data: data folder in format destination:source. | 37 # test_data: data folder in format destination:source. |
| 40 # host_driven_root: The host-driven test root directory. | 38 # host_driven_root: The host-driven test root directory. |
| 41 # annotation: Annotation of the tests to include. | 39 # annotation: Annotation of the tests to include. |
| 42 # exclude_annotation: The annotation of the tests to exclude. | 40 # exclude_annotation: The annotation of the tests to exclude. |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 """Run layout tests on an actual device.""" | 213 """Run layout tests on an actual device.""" |
| 216 bb_annotations.PrintNamedStep('webkit_tests') | 214 bb_annotations.PrintNamedStep('webkit_tests') |
| 217 cmd_args = [ | 215 cmd_args = [ |
| 218 '--no-show-results', | 216 '--no-show-results', |
| 219 '--no-new-test-results', | 217 '--no-new-test-results', |
| 220 '--full-results-html', | 218 '--full-results-html', |
| 221 '--clobber-old-results', | 219 '--clobber-old-results', |
| 222 '--exit-after-n-failures', '5000', | 220 '--exit-after-n-failures', '5000', |
| 223 '--exit-after-n-crashes-or-timeouts', '100', | 221 '--exit-after-n-crashes-or-timeouts', '100', |
| 224 '--debug-rwt-logging', | 222 '--debug-rwt-logging', |
| 225 '--results-directory', '../layout-test-results', | 223 '--results-directory', '..layout-test-results', |
| 226 '--target', options.target, | 224 '--target', options.target, |
| 227 '--builder-name', options.build_properties.get('buildername', ''), | 225 '--builder-name', options.build_properties.get('buildername', ''), |
| 228 '--build-number', str(options.build_properties.get('buildnumber', '')), | 226 '--build-number', str(options.build_properties.get('buildnumber', '')), |
| 229 '--master-name', options.build_properties.get('mastername', ''), | 227 '--master-name', options.build_properties.get('mastername', ''), |
| 230 '--build-name', options.build_properties.get('buildername', ''), | 228 '--build-name', options.build_properties.get('buildername', ''), |
| 231 '--platform=android'] | 229 '--platform=android'] |
| 232 | 230 |
| 233 for flag in 'test_results_server', 'driver_name', 'additional_drt_flag': | 231 for flag in 'test_results_server', 'driver_name', 'additional_drt_flag': |
| 234 if flag in options.factory_properties: | 232 if flag in options.factory_properties: |
| 235 cmd_args.extend(['--%s' % flag.replace('_', '-'), | 233 cmd_args.extend(['--%s' % flag.replace('_', '-'), |
| 236 options.factory_properties.get(flag)]) | 234 options.factory_properties.get(flag)]) |
| 237 | 235 |
| 238 for f in options.factory_properties.get('additional_expectations', []): | 236 for f in options.factory_properties.get('additional_expectations', []): |
| 239 cmd_args.extend( | 237 cmd_args.extend( |
| 240 ['--additional-expectations=%s' % os.path.join(CHROME_SRC_DIR, *f)]) | 238 ['--additional-expectations=%s' % os.path.join(CHROME_SRC, *f)]) |
| 241 | 239 |
| 242 # TODO(dpranke): Remove this block after | 240 # TODO(dpranke): Remove this block after |
| 243 # https://codereview.chromium.org/12927002/ lands. | 241 # https://codereview.chromium.org/12927002/ lands. |
| 244 for f in options.factory_properties.get('additional_expectations_files', []): | 242 for f in options.factory_properties.get('additional_expectations_files', []): |
| 245 cmd_args.extend( | 243 cmd_args.extend( |
| 246 ['--additional-expectations=%s' % os.path.join(CHROME_SRC_DIR, *f)]) | 244 ['--additional-expectations=%s' % os.path.join(CHROME_SRC, *f)]) |
| 247 | 245 |
| 248 RunCmd(['webkit/tools/layout_tests/run_webkit_tests.py'] + cmd_args) | 246 RunCmd(['webkit/tools/layout_tests/run_webkit_tests.py'] + cmd_args) |
| 249 | 247 |
| 250 if options.factory_properties.get('archive_webkit_results', False): | |
| 251 bb_annotations.PrintNamedStep('archive_webkit_results') | |
| 252 RunCmd([os.path.join(SLAVE_SCRIPTS_DIR, 'archive_layout_test_results.py'), | |
| 253 '--results-dir', '../layout-test-results', | |
| 254 '--target', options.target, | |
| 255 '--build-dir', CHROME_OUT_DIR, | |
| 256 '--build-number', str(options.build_properties.get('buildnumber', '')), | |
| 257 '--builder-name', options.build_properties.get('buildername', '')]) | |
| 258 | |
| 259 | 248 |
| 260 def SpawnLogcatMonitor(): | 249 def SpawnLogcatMonitor(): |
| 261 shutil.rmtree(LOGCAT_DIR, ignore_errors=True) | 250 shutil.rmtree(LOGCAT_DIR, ignore_errors=True) |
| 262 bb_utils.SpawnCmd([ | 251 bb_utils.SpawnCmd([ |
| 263 os.path.join(CHROME_SRC_DIR, 'build', 'android', 'adb_logcat_monitor.py'), | 252 os.path.join(CHROME_SRC, 'build', 'android', 'adb_logcat_monitor.py'), |
| 264 LOGCAT_DIR]) | 253 LOGCAT_DIR]) |
| 265 | 254 |
| 266 # Wait for logcat_monitor to pull existing logcat | 255 # Wait for logcat_monitor to pull existing logcat |
| 267 RunCmd(['sleep', '5']) | 256 RunCmd(['sleep', '5']) |
| 268 | 257 |
| 269 def ProvisionDevices(options): | 258 def ProvisionDevices(options): |
| 270 bb_annotations.PrintNamedStep('provision_devices') | 259 bb_annotations.PrintNamedStep('provision_devices') |
| 271 | 260 |
| 272 if not bb_utils.TESTING: | 261 if not bb_utils.TESTING: |
| 273 # Restart adb to work around bugs, sleep to wait for usb discovery. | 262 # Restart adb to work around bugs, sleep to wait for usb discovery. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 'https://storage.googleapis.com/%s/index.html' % gs_path) | 341 'https://storage.googleapis.com/%s/index.html' % gs_path) |
| 353 | 342 |
| 354 | 343 |
| 355 def GenerateJavaCoverageReport(options): | 344 def GenerateJavaCoverageReport(options): |
| 356 """Generates an HTML coverage report using EMMA and uploads it.""" | 345 """Generates an HTML coverage report using EMMA and uploads it.""" |
| 357 bb_annotations.PrintNamedStep('java_coverage_report') | 346 bb_annotations.PrintNamedStep('java_coverage_report') |
| 358 | 347 |
| 359 coverage_html = os.path.join(options.coverage_dir, 'coverage_html') | 348 coverage_html = os.path.join(options.coverage_dir, 'coverage_html') |
| 360 RunCmd(['build/android/generate_emma_html.py', | 349 RunCmd(['build/android/generate_emma_html.py', |
| 361 '--coverage-dir', options.coverage_dir, | 350 '--coverage-dir', options.coverage_dir, |
| 362 '--metadata-dir', os.path.join(CHROME_OUT_DIR, options.target), | 351 '--metadata-dir', os.path.join(CHROME_SRC, 'out', options.target), |
| 363 '--cleanup', | 352 '--cleanup', |
| 364 '--output', os.path.join(coverage_html, 'index.html')]) | 353 '--output', os.path.join(coverage_html, 'index.html')]) |
| 365 UploadCoverageData(options, coverage_html, 'java') | 354 UploadCoverageData(options, coverage_html, 'java') |
| 366 | 355 |
| 367 | 356 |
| 368 def LogcatDump(options): | 357 def LogcatDump(options): |
| 369 # Print logcat, kill logcat monitor | 358 # Print logcat, kill logcat monitor |
| 370 bb_annotations.PrintNamedStep('logcat_dump') | 359 bb_annotations.PrintNamedStep('logcat_dump') |
| 371 logcat_file = os.path.join(CHROME_OUT_DIR, options.target, 'full_log') | 360 logcat_file = os.path.join(CHROME_SRC, 'out', options.target, 'full_log') |
| 372 with open(logcat_file, 'w') as f: | 361 with open(logcat_file, 'w') as f: |
| 373 RunCmd([ | 362 RunCmd([ |
| 374 os.path.join(CHROME_SRC_DIR, 'build', 'android', | 363 os.path.join(CHROME_SRC, 'build', 'android', 'adb_logcat_printer.py'), |
| 375 'adb_logcat_printer.py'), | |
| 376 LOGCAT_DIR], stdout=f) | 364 LOGCAT_DIR], stdout=f) |
| 377 RunCmd(['cat', logcat_file]) | 365 RunCmd(['cat', logcat_file]) |
| 378 | 366 |
| 379 | 367 |
| 380 def GenerateTestReport(options): | 368 def GenerateTestReport(options): |
| 381 bb_annotations.PrintNamedStep('test_report') | 369 bb_annotations.PrintNamedStep('test_report') |
| 382 for report in glob.glob( | 370 for report in glob.glob( |
| 383 os.path.join(CHROME_OUT_DIR, options.target, 'test_logs', '*.log')): | 371 os.path.join(CHROME_SRC, 'out', options.target, 'test_logs', '*.log')): |
| 384 RunCmd(['cat', report]) | 372 RunCmd(['cat', report]) |
| 385 os.remove(report) | 373 os.remove(report) |
| 386 | 374 |
| 387 | 375 |
| 388 def MainTestWrapper(options): | 376 def MainTestWrapper(options): |
| 389 try: | 377 try: |
| 390 # Spawn logcat monitor | 378 # Spawn logcat monitor |
| 391 SpawnLogcatMonitor() | 379 SpawnLogcatMonitor() |
| 392 | 380 |
| 393 # Run all device setup steps | 381 # Run all device setup steps |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 if args: | 441 if args: |
| 454 return sys.exit('Unused args %s' % args) | 442 return sys.exit('Unused args %s' % args) |
| 455 | 443 |
| 456 unknown_tests = set(options.test_filter) - VALID_TESTS | 444 unknown_tests = set(options.test_filter) - VALID_TESTS |
| 457 if unknown_tests: | 445 if unknown_tests: |
| 458 return sys.exit('Unknown tests %s' % list(unknown_tests)) | 446 return sys.exit('Unknown tests %s' % list(unknown_tests)) |
| 459 | 447 |
| 460 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) | 448 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) |
| 461 if options.coverage_bucket: | 449 if options.coverage_bucket: |
| 462 setattr(options, 'coverage_dir', | 450 setattr(options, 'coverage_dir', |
| 463 os.path.join(CHROME_OUT_DIR, options.target, 'coverage')) | 451 os.path.join(CHROME_SRC, 'out', options.target, 'coverage')) |
| 464 | 452 |
| 465 MainTestWrapper(options) | 453 MainTestWrapper(options) |
| 466 | 454 |
| 467 | 455 |
| 468 if __name__ == '__main__': | 456 if __name__ == '__main__': |
| 469 sys.exit(main(sys.argv)) | 457 sys.exit(main(sys.argv)) |
| OLD | NEW |