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

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: do not run as default and rebase 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(
jbudorick 2016/06/28 10:27:33 Why are you adding these three? Are they used by s
rnephew (Reviews Here) 2016/06/29 22:27:20 They are used in the test runner in RunTestsInPlat
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']
jbudorick 2016/06/28 10:27:33 s/' gtest'/'gtest'
rnephew (Reviews Here) 2016/06/29 22:27:20 Done.
786 def RunTestsCommand(args): # pylint: disable=too-many-return-statements 805 def RunTestsCommand(args): # pylint: disable=too-many-return-statements
787 """Checks test type and dispatches to the appropriate function. 806 """Checks test type and dispatches to the appropriate function.
788 807
789 Args: 808 Args:
790 args: argparse.Namespace object. 809 args: argparse.Namespace object.
791 810
792 Returns: 811 Returns:
793 Integer indicated exit code. 812 Integer indicated exit code.
794 813
795 Raises: 814 Raises:
796 Exception: Unknown command name passed in, or an exception from an 815 Exception: Unknown command name passed in, or an exception from an
797 individual test runner. 816 individual test runner.
798 """ 817 """
799 command = args.command 818 command = args.command
800 819
801 ProcessCommonOptions(args) 820 ProcessCommonOptions(args)
802 logging.info('command: %s', ' '.join(sys.argv)) 821 logging.info('command: %s', ' '.join(sys.argv))
803 822 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) 823 return RunTestsInPlatformMode(args)
806 824
807 forwarder.Forwarder.RemoveHostLog() 825 forwarder.Forwarder.RemoveHostLog()
808 if not ports.ResetTestServerPortAllocation(): 826 if not ports.ResetTestServerPortAllocation():
809 raise Exception('Failed to reset test server port.') 827 raise Exception('Failed to reset test server port.')
810 828
811 def get_devices(): 829 def get_devices():
812 return _GetAttachedDevices(args.blacklist_file, args.test_device, 830 return _GetAttachedDevices(args.blacklist_file, args.test_device,
813 args.enable_device_cache, args.num_retries) 831 args.enable_device_cache, args.num_retries)
814 832
815 if command == 'linker': 833 if command == 'linker':
816 return _RunLinkerTests(args, get_devices()) 834 return _RunLinkerTests(args, get_devices())
817 elif command == 'junit': 835 elif command == 'junit':
818 return _RunJUnitTests(args) 836 return _RunJUnitTests(args)
819 elif command == 'monkey': 837 elif command == 'monkey':
820 return _RunMonkeyTests(args, get_devices()) 838 return _RunMonkeyTests(args, get_devices())
821 elif command == 'perf': 839 elif command == 'perf':
822 return _RunPerfTests(args, get_devices()) 840 return _RunPerfTests(args, get_devices())
823 elif command == 'python': 841 elif command == 'python':
824 return _RunPythonTests(args) 842 return _RunPythonTests(args)
825 else: 843 else:
826 raise Exception('Unknown test type.') 844 raise Exception('Unknown test type.')
827 845
828 846
829 _SUPPORTED_IN_PLATFORM_MODE = [ 847 _SUPPORTED_IN_PLATFORM_MODE = [
830 # TODO(jbudorick): Add support for more test types. 848 # TODO(jbudorick): Add support for more test types.
831 'gtest', 849 'gtest',
832 'instrumentation', 850 'instrumentation',
851 'perf',
833 'uirobot', 852 'uirobot',
834 ] 853 ]
835 854
836 855
837 def RunTestsInPlatformMode(args): 856 def RunTestsInPlatformMode(args):
838 857
839 def infra_error(message): 858 def infra_error(message):
840 logging.fatal(message) 859 logging.fatal(message)
841 sys.exit(constants.INFRA_EXIT_CODE) 860 sys.exit(constants.INFRA_EXIT_CODE)
842 861
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 if e.is_infra_error: 1000 if e.is_infra_error:
982 return constants.INFRA_EXIT_CODE 1001 return constants.INFRA_EXIT_CODE
983 return constants.ERROR_EXIT_CODE 1002 return constants.ERROR_EXIT_CODE
984 except: # pylint: disable=W0702 1003 except: # pylint: disable=W0702
985 logging.exception('Unrecognized error occurred.') 1004 logging.exception('Unrecognized error occurred.')
986 return constants.ERROR_EXIT_CODE 1005 return constants.ERROR_EXIT_CODE
987 1006
988 1007
989 if __name__ == '__main__': 1008 if __name__ == '__main__':
990 sys.exit(main()) 1009 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698