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