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 |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 | 523 |
524 def LogcatDump(options): | 524 def LogcatDump(options): |
525 # Print logcat, kill logcat monitor | 525 # Print logcat, kill logcat monitor |
526 bb_annotations.PrintNamedStep('logcat_dump') | 526 bb_annotations.PrintNamedStep('logcat_dump') |
527 logcat_file = os.path.join(CHROME_OUT_DIR, options.target, 'full_log') | 527 logcat_file = os.path.join(CHROME_OUT_DIR, options.target, 'full_log') |
528 RunCmd([SrcPath('build' , 'android', 'adb_logcat_printer.py'), | 528 RunCmd([SrcPath('build' , 'android', 'adb_logcat_printer.py'), |
529 '--output-path', logcat_file, LOGCAT_DIR]) | 529 '--output-path', logcat_file, LOGCAT_DIR]) |
530 RunCmd(['cat', logcat_file]) | 530 RunCmd(['cat', logcat_file]) |
531 | 531 |
532 | 532 |
533 def RunStackToolSteps(options): | |
534 """Run stack tool steps. | |
535 | |
536 Stack tool is run for logcat dump, optionally for ASAN. | |
537 """ | |
538 bb_annotations.PrintNamedStep('Run stack tool with logcat dump') | |
539 logcat_file = os.path.join(CHROME_OUT_DIR, options.target, 'full_log') | |
540 RunCmd([os.path.join(CHROME_SRC_DIR, 'third_party', 'android_platform', | |
541 'development', 'scripts', 'stack'), | |
542 '--more-info', logcat_file]) | |
543 if options.asan_symbolize: | |
544 bb_annotations.PrintNamedStep('Run stack tool for ASAN') | |
545 RunCmd([ | |
546 os.path.join(CHROME_SRC_DIR, 'build', 'android', 'asan_symbolize.py'), | |
547 '-l', logcat_file]) | |
548 | |
549 | |
550 def GenerateTestReport(options): | 533 def GenerateTestReport(options): |
551 bb_annotations.PrintNamedStep('test_report') | 534 bb_annotations.PrintNamedStep('test_report') |
552 for report in glob.glob( | 535 for report in glob.glob( |
553 os.path.join(CHROME_OUT_DIR, options.target, 'test_logs', '*.log')): | 536 os.path.join(CHROME_OUT_DIR, options.target, 'test_logs', '*.log')): |
554 RunCmd(['cat', report]) | 537 RunCmd(['cat', report]) |
555 os.remove(report) | 538 os.remove(report) |
556 | 539 |
557 | 540 |
558 def MainTestWrapper(options): | 541 def MainTestWrapper(options): |
559 try: | 542 try: |
(...skipping 16 matching lines...) Expand all Loading... |
576 UploadHTML(options, '%s/java' % options.coverage_bucket, coverage_html, | 559 UploadHTML(options, '%s/java' % options.coverage_bucket, coverage_html, |
577 'Coverage Report') | 560 'Coverage Report') |
578 shutil.rmtree(coverage_html, ignore_errors=True) | 561 shutil.rmtree(coverage_html, ignore_errors=True) |
579 | 562 |
580 if options.experimental: | 563 if options.experimental: |
581 RunTestSuites(options, gtest_config.EXPERIMENTAL_TEST_SUITES) | 564 RunTestSuites(options, gtest_config.EXPERIMENTAL_TEST_SUITES) |
582 | 565 |
583 finally: | 566 finally: |
584 # Run all post test steps | 567 # Run all post test steps |
585 LogcatDump(options) | 568 LogcatDump(options) |
586 if not options.disable_stack_tool: | |
587 RunStackToolSteps(options) | |
588 GenerateTestReport(options) | 569 GenerateTestReport(options) |
589 # KillHostHeartbeat() has logic to check if heartbeat process is running, | 570 # KillHostHeartbeat() has logic to check if heartbeat process is running, |
590 # and kills only if it finds the process is running on the host. | 571 # and kills only if it finds the process is running on the host. |
591 provision_devices.KillHostHeartbeat() | 572 provision_devices.KillHostHeartbeat() |
592 | 573 |
593 | 574 |
594 def GetDeviceStepsOptParser(): | 575 def GetDeviceStepsOptParser(): |
595 parser = bb_utils.GetParser() | 576 parser = bb_utils.GetParser() |
596 parser.add_option('--experimental', action='store_true', | 577 parser.add_option('--experimental', action='store_true', |
597 help='Run experiemental tests') | 578 help='Run experiemental tests') |
(...skipping 16 matching lines...) Expand all Loading... |
614 parser.add_option( | 595 parser.add_option( |
615 '--flakiness-server', | 596 '--flakiness-server', |
616 help=('The flakiness dashboard server to which the results should be ' | 597 help=('The flakiness dashboard server to which the results should be ' |
617 'uploaded.')) | 598 'uploaded.')) |
618 parser.add_option( | 599 parser.add_option( |
619 '--auto-reconnect', action='store_true', | 600 '--auto-reconnect', action='store_true', |
620 help='Push script to device which restarts adbd on disconnections.') | 601 help='Push script to device which restarts adbd on disconnections.') |
621 parser.add_option( | 602 parser.add_option( |
622 '--logcat-dump-output', | 603 '--logcat-dump-output', |
623 help='The logcat dump output will be "tee"-ed into this file') | 604 help='The logcat dump output will be "tee"-ed into this file') |
624 parser.add_option('--disable-stack-tool', action='store_true', | 605 |
625 help='Do not run stack tool.') | |
626 parser.add_option('--asan-symbolize', action='store_true', | |
627 help='Run stack tool for ASAN') | |
628 return parser | 606 return parser |
629 | 607 |
630 | 608 |
631 def main(argv): | 609 def main(argv): |
632 parser = GetDeviceStepsOptParser() | 610 parser = GetDeviceStepsOptParser() |
633 options, args = parser.parse_args(argv[1:]) | 611 options, args = parser.parse_args(argv[1:]) |
634 | 612 |
635 if args: | 613 if args: |
636 return sys.exit('Unused args %s' % args) | 614 return sys.exit('Unused args %s' % args) |
637 | 615 |
638 unknown_tests = set(options.test_filter) - VALID_TESTS | 616 unknown_tests = set(options.test_filter) - VALID_TESTS |
639 if unknown_tests: | 617 if unknown_tests: |
640 return sys.exit('Unknown tests %s' % list(unknown_tests)) | 618 return sys.exit('Unknown tests %s' % list(unknown_tests)) |
641 | 619 |
642 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) | 620 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) |
643 if options.coverage_bucket: | 621 if options.coverage_bucket: |
644 setattr(options, 'coverage_dir', | 622 setattr(options, 'coverage_dir', |
645 os.path.join(CHROME_OUT_DIR, options.target, 'coverage')) | 623 os.path.join(CHROME_OUT_DIR, options.target, 'coverage')) |
646 | 624 |
647 MainTestWrapper(options) | 625 MainTestWrapper(options) |
648 | 626 |
649 | 627 |
650 if __name__ == '__main__': | 628 if __name__ == '__main__': |
651 sys.exit(main(sys.argv)) | 629 sys.exit(main(sys.argv)) |
OLD | NEW |