Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: build/android/test_runner.py

Issue 2012323002: [Android] Implement perf tests to platform mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [Android] Implement perf tests to platform mode. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2013 The Chromium Authors. All rights reserved. 3 # Copyright 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Runs all types of tests from one unified interface.""" 7 """Runs all types of tests from one unified interface."""
8 8
9 import argparse 9 import argparse
10 import collections 10 import collections
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 '--output-json-list', 562 '--output-json-list',
563 help='Write a simple list of names from --steps into the given file.') 563 help='Write a simple list of names from --steps into the given file.')
564 group.add_argument( 564 group.add_argument(
565 '--collect-chartjson-data', 565 '--collect-chartjson-data',
566 action='store_true', 566 action='store_true',
567 help='Cache the chartjson output from each step for later use.') 567 help='Cache the chartjson output from each step for later use.')
568 group.add_argument( 568 group.add_argument(
569 '--output-chartjson-data', 569 '--output-chartjson-data',
570 default='', 570 default='',
571 help='Write out chartjson into the given file.') 571 help='Write out chartjson into the given file.')
572 # TODO(rnephew): Remove this when everything moves to new option in platform
573 # mode.
572 group.add_argument( 574 group.add_argument(
573 '--get-output-dir-archive', metavar='FILENAME', 575 '--get-output-dir-archive', metavar='FILENAME',
574 help='Write the chached output directory archived by a step into the' 576 help='Write the cached output directory archived by a step into the'
577 ' given ZIP file.')
578 group.add_argument(
579 '--output-dir-archive-path', metavar='FILENAME',
580 help='Write the cached output directory archived by a step into the'
575 ' given ZIP file.') 581 ' given ZIP file.')
576 group.add_argument( 582 group.add_argument(
577 '--flaky-steps', 583 '--flaky-steps',
578 help=('A JSON file containing steps that are flaky ' 584 help=('A JSON file containing steps that are flaky '
579 'and will have its exit code ignored.')) 585 'and will have its exit code ignored.'))
580 group.add_argument( 586 group.add_argument(
581 '--no-timeout', action='store_true', 587 '--no-timeout', action='store_true',
582 help=('Do not impose a timeout. Each perf step is responsible for ' 588 help=('Do not impose a timeout. Each perf step is responsible for '
583 'implementing the timeout logic.')) 589 'implementing the timeout logic.'))
584 group.add_argument( 590 group.add_argument(
585 '-f', '--test-filter', 591 '-f', '--test-filter',
586 help=('Test filter (will match against the names listed in --steps).')) 592 help=('Test filter (will match against the names listed in --steps).'))
587 group.add_argument( 593 group.add_argument(
588 '--dry-run', action='store_true', 594 '--dry-run', action='store_true',
589 help='Just print the steps without executing.') 595 help='Just print the steps without executing.')
590 # Uses 0.1 degrees C because that's what Android does. 596 # Uses 0.1 degrees C because that's what Android does.
591 group.add_argument( 597 group.add_argument(
592 '--max-battery-temp', type=int, 598 '--max-battery-temp', type=int,
593 help='Only start tests when the battery is at or below the given ' 599 help='Only start tests when the battery is at or below the given '
594 'temperature (0.1 C)') 600 'temperature (0.1 C)')
595 group.add_argument('single_step_command', nargs='*', action=SingleStepAction, 601 group.add_argument(
596 help='If --single-step is specified, the command to run.') 602 'single_step_command', nargs='*', action=SingleStepAction,
597 group.add_argument('--min-battery-level', type=int, 603 help='If --single-step is specified, the command to run.')
598 help='Only starts tests when the battery is charged above ' 604 group.add_argument(
599 'given level.') 605 '--min-battery-level', type=int,
606 help='Only starts tests when the battery is charged above '
607 'given level.')
600 group.add_argument('--known-devices-file', help='Path to known device list.') 608 group.add_argument('--known-devices-file', help='Path to known device list.')
609 group.add_argument(
610 '--repeat', dest='repeat', type=int, default=0,
611 help='Number of times to repeat the specified set of tests.')
612 group.add_argument(
613 '--break-on-failure', '--break_on_failure', dest='break_on_failure',
614 action='store_true', help='Whether to break on failure.')
615 group.add_argument(
616 '--write-buildbot-json', action='store_true',
617 help='Whether to output buildbot json.')
601 AddCommonOptions(parser) 618 AddCommonOptions(parser)
602 AddDeviceOptions(parser) 619 AddDeviceOptions(parser)
603 620
604 621
605 def ProcessPerfTestOptions(args): 622 def ProcessPerfTestOptions(args):
606 """Processes all perf test options. 623 """Processes all perf test options.
607 624
608 Args: 625 Args:
609 args: argparse.Namespace object. 626 args: argparse.Namespace object.
610 627
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 'Did not find device %s among attached device. Attached devices: %s' 793 'Did not find device %s among attached device. Attached devices: %s'
777 % (test_device, ', '.join(attached_devices))) 794 % (test_device, ', '.join(attached_devices)))
778 return test_device 795 return test_device
779 796
780 else: 797 else:
781 if not attached_devices: 798 if not attached_devices:
782 raise device_errors.NoDevicesError() 799 raise device_errors.NoDevicesError()
783 return sorted(attached_devices) 800 return sorted(attached_devices)
784 801
785 802
803 # TODO(rnephew): Add perf when ready to switch to platform mode as default.
804 _DEFAULT_PLATFORM_MODE_TESTS = ['gtest', 'instrumentation']
805
806
786 def RunTestsCommand(args): # pylint: disable=too-many-return-statements 807 def RunTestsCommand(args): # pylint: disable=too-many-return-statements
787 """Checks test type and dispatches to the appropriate function. 808 """Checks test type and dispatches to the appropriate function.
788 809
789 Args: 810 Args:
790 args: argparse.Namespace object. 811 args: argparse.Namespace object.
791 812
792 Returns: 813 Returns:
793 Integer indicated exit code. 814 Integer indicated exit code.
794 815
795 Raises: 816 Raises:
796 Exception: Unknown command name passed in, or an exception from an 817 Exception: Unknown command name passed in, or an exception from an
797 individual test runner. 818 individual test runner.
798 """ 819 """
799 command = args.command 820 command = args.command
800 821
801 ProcessCommonOptions(args) 822 ProcessCommonOptions(args)
802 logging.info('command: %s', ' '.join(sys.argv)) 823 logging.info('command: %s', ' '.join(sys.argv))
803 824 if args.enable_platform_mode or command in _DEFAULT_PLATFORM_MODE_TESTS:
804 if args.enable_platform_mode or command in ('gtest', 'instrumentation'):
805 return RunTestsInPlatformMode(args) 825 return RunTestsInPlatformMode(args)
806 826
807 forwarder.Forwarder.RemoveHostLog() 827 forwarder.Forwarder.RemoveHostLog()
808 if not ports.ResetTestServerPortAllocation(): 828 if not ports.ResetTestServerPortAllocation():
809 raise Exception('Failed to reset test server port.') 829 raise Exception('Failed to reset test server port.')
810 830
811 def get_devices(): 831 def get_devices():
812 return _GetAttachedDevices(args.blacklist_file, args.test_device, 832 return _GetAttachedDevices(args.blacklist_file, args.test_device,
813 args.enable_device_cache, args.num_retries) 833 args.enable_device_cache, args.num_retries)
814 834
815 if command == 'linker': 835 if command == 'linker':
816 return _RunLinkerTests(args, get_devices()) 836 return _RunLinkerTests(args, get_devices())
817 elif command == 'junit': 837 elif command == 'junit':
818 return _RunJUnitTests(args) 838 return _RunJUnitTests(args)
819 elif command == 'monkey': 839 elif command == 'monkey':
820 return _RunMonkeyTests(args, get_devices()) 840 return _RunMonkeyTests(args, get_devices())
821 elif command == 'perf': 841 elif command == 'perf':
822 return _RunPerfTests(args, get_devices()) 842 return _RunPerfTests(args, get_devices())
823 elif command == 'python': 843 elif command == 'python':
824 return _RunPythonTests(args) 844 return _RunPythonTests(args)
825 else: 845 else:
826 raise Exception('Unknown test type.') 846 raise Exception('Unknown test type.')
827 847
828 848
829 _SUPPORTED_IN_PLATFORM_MODE = [ 849 _SUPPORTED_IN_PLATFORM_MODE = [
830 # TODO(jbudorick): Add support for more test types. 850 # TODO(jbudorick): Add support for more test types.
831 'gtest', 851 'gtest',
832 'instrumentation', 852 'instrumentation',
853 'perf',
833 'uirobot', 854 'uirobot',
834 ] 855 ]
835 856
836 857
837 def RunTestsInPlatformMode(args): 858 def RunTestsInPlatformMode(args):
838 859
839 def infra_error(message): 860 def infra_error(message):
840 logging.fatal(message) 861 logging.fatal(message)
841 sys.exit(constants.INFRA_EXIT_CODE) 862 sys.exit(constants.INFRA_EXIT_CODE)
842 863
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 if e.is_infra_error: 1002 if e.is_infra_error:
982 return constants.INFRA_EXIT_CODE 1003 return constants.INFRA_EXIT_CODE
983 return constants.ERROR_EXIT_CODE 1004 return constants.ERROR_EXIT_CODE
984 except: # pylint: disable=W0702 1005 except: # pylint: disable=W0702
985 logging.exception('Unrecognized error occurred.') 1006 logging.exception('Unrecognized error occurred.')
986 return constants.ERROR_EXIT_CODE 1007 return constants.ERROR_EXIT_CODE
987 1008
988 1009
989 if __name__ == '__main__': 1010 if __name__ == '__main__':
990 sys.exit(main()) 1011 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698