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

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

Issue 745793002: Add AMP support to test runner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get rid of old/done TODOs Created 6 years 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 collections 9 import collections
10 import logging 10 import logging
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 constants.SetAdbPath(options.adb_path) 109 constants.SetAdbPath(options.adb_path)
110 # Some things such as Forwarder require ADB to be in the environment path. 110 # Some things such as Forwarder require ADB to be in the environment path.
111 adb_dir = os.path.dirname(constants.GetAdbPath()) 111 adb_dir = os.path.dirname(constants.GetAdbPath())
112 if adb_dir and adb_dir not in os.environ['PATH'].split(os.pathsep): 112 if adb_dir and adb_dir not in os.environ['PATH'].split(os.pathsep):
113 os.environ['PATH'] = adb_dir + os.pathsep + os.environ['PATH'] 113 os.environ['PATH'] = adb_dir + os.pathsep + os.environ['PATH']
114 if options.environment not in constants.VALID_ENVIRONMENTS: 114 if options.environment not in constants.VALID_ENVIRONMENTS:
115 error_func('--environment must be one of: %s' % 115 error_func('--environment must be one of: %s' %
116 ', '.join(constants.VALID_ENVIRONMENTS)) 116 ', '.join(constants.VALID_ENVIRONMENTS))
117 117
118 118
119 def AddRemoteDeviceOptions(option_parser):
120 group = optparse.OptionGroup(option_parser, 'Remote Device Options')
121 group.add_option('--remote-device', default='Nexus 5', type='string',
122 help=('Device type to run test on.'))
123 group.add_option('--remote-device-os', default='4.4.2', type='string',
124 help=('OS to have on the device.'))
125 group.add_option('--api-key', default='', type='string',
jbudorick 2014/12/01 17:38:40 We may want --api-key and --api-secret to have cor
rnephew (Reviews Here) 2014/12/02 19:47:49 Done.
126 help=('API key for remote devices.'))
127 group.add_option('--api-secret', default='', type='string',
128 help=('API secret for remote devices.'))
129 group.add_option('--results-path', default='', type='string',
130 help=('File path to download results to.'))
131 group.add_option('--api-protocol', default='http', type='string',
132 help=('HTTP protocol to use. (http or https)'))
133 group.add_option('--api-address', default='172.22.21.180', type='string',
134 help=('Address to send HTTP requests.'))
135 group.add_option('--runner-type', default='', type='string',
136 help=('Type of test to run as.'))
137 group.add_option('--runner-package', default='', type='string',
138 help=('Package name of test.'))
139 option_parser.add_option_group(group)
140
141
119 def AddDeviceOptions(option_parser): 142 def AddDeviceOptions(option_parser):
120 group = optparse.OptionGroup(option_parser, 'Device Options') 143 group = optparse.OptionGroup(option_parser, 'Device Options')
121 group.add_option('-c', dest='cleanup_test_files', 144 group.add_option('-c', dest='cleanup_test_files',
122 help='Cleanup test files on the device after run', 145 help='Cleanup test files on the device after run',
123 action='store_true') 146 action='store_true')
124 group.add_option('--tool', 147 group.add_option('--tool',
125 dest='tool', 148 dest='tool',
126 help=('Run the test under a tool ' 149 help=('Run the test under a tool '
127 '(use --tool help to list them)')) 150 '(use --tool help to list them)'))
128 group.add_option('-d', '--device', dest='test_device', 151 group.add_option('-d', '--device', dest='test_device',
(...skipping 29 matching lines...) Expand all
158 default=60) 181 default=60)
159 option_parser.add_option('--isolate_file_path', 182 option_parser.add_option('--isolate_file_path',
160 '--isolate-file-path', 183 '--isolate-file-path',
161 dest='isolate_file_path', 184 dest='isolate_file_path',
162 help='.isolate file path to override the default ' 185 help='.isolate file path to override the default '
163 'path') 186 'path')
164 # TODO(gkanwar): Move these to Common Options once we have the plumbing 187 # TODO(gkanwar): Move these to Common Options once we have the plumbing
165 # in our other test types to handle these commands 188 # in our other test types to handle these commands
166 AddCommonOptions(option_parser) 189 AddCommonOptions(option_parser)
167 AddDeviceOptions(option_parser) 190 AddDeviceOptions(option_parser)
191 AddRemoteDeviceOptions(option_parser)
168 192
169 193
170 def AddLinkerTestOptions(option_parser): 194 def AddLinkerTestOptions(option_parser):
171 option_parser.usage = '%prog linker' 195 option_parser.usage = '%prog linker'
172 option_parser.commands_dict = {} 196 option_parser.commands_dict = {}
173 option_parser.example = '%prog linker' 197 option_parser.example = '%prog linker'
174 198
175 option_parser.add_option('-f', '--gtest-filter', dest='test_filter', 199 option_parser.add_option('-f', '--gtest-filter', dest='test_filter',
176 help='googletest-style filter string.') 200 help='googletest-style filter string.')
177 AddCommonOptions(option_parser) 201 AddCommonOptions(option_parser)
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 return monkey_test_options.MonkeyOptions( 537 return monkey_test_options.MonkeyOptions(
514 options.verbose_count, 538 options.verbose_count,
515 options.package, 539 options.package,
516 options.event_count, 540 options.event_count,
517 category, 541 category,
518 options.throttle, 542 options.throttle,
519 options.seed, 543 options.seed,
520 options.extra_args) 544 options.extra_args)
521 545
522 546
547 def AddUirobotTestOptions(option_parser):
548 """Adds uirobot test options to |option_parser|."""
549
550 option_parser.usage = '%prog uirobot [options]'
551 option_parser.commands_dict = {}
552 option_parser.example = (
553 '%prog monkey --minutes=1')
554
555 option_parser.add_option(
556 '--minutes', default=5, type='string',
557 help='Number of minutes to run uirobot test [default: %default].')
558
559 AddCommonOptions(option_parser)
560 AddDeviceOptions(option_parser)
561 AddRemoteDeviceOptions(option_parser)
562
523 def AddPerfTestOptions(option_parser): 563 def AddPerfTestOptions(option_parser):
524 """Adds perf test options to |option_parser|.""" 564 """Adds perf test options to |option_parser|."""
525 565
526 option_parser.usage = '%prog perf [options]' 566 option_parser.usage = '%prog perf [options]'
527 option_parser.commands_dict = {} 567 option_parser.commands_dict = {}
528 option_parser.example = ('%prog perf ' 568 option_parser.example = ('%prog perf '
529 '[--single-step -- command args] or ' 569 '[--single-step -- command args] or '
530 '[--steps perf_steps.json] or ' 570 '[--steps perf_steps.json] or '
531 '[--print-step step]') 571 '[--print-step step]')
532 572
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 elif command == 'perf': 935 elif command == 'perf':
896 return _RunPerfTests(options, args, option_parser.error) 936 return _RunPerfTests(options, args, option_parser.error)
897 elif command == 'python': 937 elif command == 'python':
898 return _RunPythonTests(options, option_parser.error) 938 return _RunPythonTests(options, option_parser.error)
899 else: 939 else:
900 raise Exception('Unknown test type.') 940 raise Exception('Unknown test type.')
901 941
902 942
903 _SUPPORTED_IN_PLATFORM_MODE = [ 943 _SUPPORTED_IN_PLATFORM_MODE = [
904 # TODO(jbudorick): Add support for more test types. 944 # TODO(jbudorick): Add support for more test types.
905 'gtest', 945 'gtest', 'uirobot',
906 ] 946 ]
907 947
908 948
909 def RunTestsInPlatformMode(command, options, option_parser): 949 def RunTestsInPlatformMode(command, options, option_parser):
910 950
911 if command not in _SUPPORTED_IN_PLATFORM_MODE: 951 if command not in _SUPPORTED_IN_PLATFORM_MODE:
912 option_parser.error('%s is not yet supported in platform mode' % command) 952 option_parser.error('%s is not yet supported in platform mode' % command)
913 953
914 with environment_factory.CreateEnvironment( 954 with environment_factory.CreateEnvironment(
915 command, options, option_parser.error) as env: 955 command, options, option_parser.error) as env:
916 with test_instance_factory.CreateTestInstance( 956 with test_instance_factory.CreateTestInstance(
917 command, options, option_parser.error) as test: 957 command, options, option_parser.error) as test:
918 with test_run_factory.CreateTestRun( 958 with test_run_factory.CreateTestRun(
919 options, env, test, option_parser.error) as test_run: 959 options, env, test, option_parser.error) as test_run:
920 results = test_run.RunTests() 960 results = test_run.RunTest()
961
962 # TODO(rnephew): Get rid of this when results handling
jbudorick 2014/11/30 22:57:02 For now, let's stick with returning instances of B
rnephew (Reviews Here) 2014/12/02 19:47:49 Got rid of this code, but the appurify stuff doesn
963 # for remote devics is ready.
964 if options.environment == 'remote_device':
965 print results
966 return
921 967
922 report_results.LogFull( 968 report_results.LogFull(
923 results=results, 969 results=results,
924 test_type=test.TestType(), 970 test_type=test.TestType(),
925 test_package=test_run.TestPackage(), 971 test_package=test_run.TestPackage(),
926 annotation=options.annotations, 972 annotation=options.annotations,
927 flakiness_server=options.flakiness_dashboard_server) 973 flakiness_server=options.flakiness_dashboard_server)
928 974
929 return results 975 return results
930 976
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 'junit': CommandFunctionTuple( 1030 'junit': CommandFunctionTuple(
985 AddJUnitTestOptions, RunTestsCommand), 1031 AddJUnitTestOptions, RunTestsCommand),
986 'monkey': CommandFunctionTuple( 1032 'monkey': CommandFunctionTuple(
987 AddMonkeyTestOptions, RunTestsCommand), 1033 AddMonkeyTestOptions, RunTestsCommand),
988 'perf': CommandFunctionTuple( 1034 'perf': CommandFunctionTuple(
989 AddPerfTestOptions, RunTestsCommand), 1035 AddPerfTestOptions, RunTestsCommand),
990 'python': CommandFunctionTuple( 1036 'python': CommandFunctionTuple(
991 AddPythonTestOptions, RunTestsCommand), 1037 AddPythonTestOptions, RunTestsCommand),
992 'linker': CommandFunctionTuple( 1038 'linker': CommandFunctionTuple(
993 AddLinkerTestOptions, RunTestsCommand), 1039 AddLinkerTestOptions, RunTestsCommand),
1040 'uirobot': CommandFunctionTuple(
1041 AddUirobotTestOptions, RunTestsCommand),
994 'help': CommandFunctionTuple(lambda option_parser: None, HelpCommand) 1042 'help': CommandFunctionTuple(lambda option_parser: None, HelpCommand)
995 } 1043 }
996 1044
997 1045
998 def DumpThreadStacks(_signal, _frame): 1046 def DumpThreadStacks(_signal, _frame):
999 for thread in threading.enumerate(): 1047 for thread in threading.enumerate():
1000 reraiser_thread.LogThreadStack(thread) 1048 reraiser_thread.LogThreadStack(thread)
1001 1049
1002 1050
1003 def main(): 1051 def main():
1004 signal.signal(signal.SIGUSR1, DumpThreadStacks) 1052 signal.signal(signal.SIGUSR1, DumpThreadStacks)
1005 option_parser = command_option_parser.CommandOptionParser( 1053 option_parser = command_option_parser.CommandOptionParser(
1006 commands_dict=VALID_COMMANDS) 1054 commands_dict=VALID_COMMANDS)
1007 return command_option_parser.ParseAndExecute(option_parser) 1055 return command_option_parser.ParseAndExecute(option_parser)
1008 1056
1009 1057
1010 if __name__ == '__main__': 1058 if __name__ == '__main__':
1011 sys.exit(main()) 1059 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698