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

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: Created 6 years, 1 month 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',
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 option_parser.add_option_group(group)
132
133
119 def AddDeviceOptions(option_parser): 134 def AddDeviceOptions(option_parser):
120 group = optparse.OptionGroup(option_parser, 'Device Options') 135 group = optparse.OptionGroup(option_parser, 'Device Options')
121 group.add_option('-c', dest='cleanup_test_files', 136 group.add_option('-c', dest='cleanup_test_files',
122 help='Cleanup test files on the device after run', 137 help='Cleanup test files on the device after run',
123 action='store_true') 138 action='store_true')
124 group.add_option('--tool', 139 group.add_option('--tool',
125 dest='tool', 140 dest='tool',
126 help=('Run the test under a tool ' 141 help=('Run the test under a tool '
127 '(use --tool help to list them)')) 142 '(use --tool help to list them)'))
128 group.add_option('-d', '--device', dest='test_device', 143 group.add_option('-d', '--device', dest='test_device',
(...skipping 28 matching lines...) Expand all
157 type='int', 172 type='int',
158 default=60) 173 default=60)
159 option_parser.add_option('--isolate_file_path', 174 option_parser.add_option('--isolate_file_path',
160 '--isolate-file-path', 175 '--isolate-file-path',
161 dest='isolate_file_path', 176 dest='isolate_file_path',
162 help='.isolate file path to override the default ' 177 help='.isolate file path to override the default '
163 'path') 178 'path')
164 # TODO(gkanwar): Move these to Common Options once we have the plumbing 179 # TODO(gkanwar): Move these to Common Options once we have the plumbing
165 # in our other test types to handle these commands 180 # in our other test types to handle these commands
166 AddCommonOptions(option_parser) 181 AddCommonOptions(option_parser)
167 AddDeviceOptions(option_parser) 182 AddDeviceOptions(option_parser)
jbudorick 2014/11/21 00:17:26 I'm working on results now, but options are next.
183 AddRemoteDeviceOptions(option_parser)
168 184
169 185
170 def AddLinkerTestOptions(option_parser): 186 def AddLinkerTestOptions(option_parser):
171 option_parser.usage = '%prog linker' 187 option_parser.usage = '%prog linker'
172 option_parser.commands_dict = {} 188 option_parser.commands_dict = {}
173 option_parser.example = '%prog linker' 189 option_parser.example = '%prog linker'
174 190
175 option_parser.add_option('-f', '--gtest-filter', dest='test_filter', 191 option_parser.add_option('-f', '--gtest-filter', dest='test_filter',
176 help='googletest-style filter string.') 192 help='googletest-style filter string.')
177 AddCommonOptions(option_parser) 193 AddCommonOptions(option_parser)
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 return monkey_test_options.MonkeyOptions( 529 return monkey_test_options.MonkeyOptions(
514 options.verbose_count, 530 options.verbose_count,
515 options.package, 531 options.package,
516 options.event_count, 532 options.event_count,
517 category, 533 category,
518 options.throttle, 534 options.throttle,
519 options.seed, 535 options.seed,
520 options.extra_args) 536 options.extra_args)
521 537
522 538
539 def AddUirobotTestOptions(option_parser):
540 """Adds uirobot test options to |option_parser|."""
541
542 option_parser.usage = '%prog uirobot [options]'
543 option_parser.commands_dict = {}
544 option_parser.example = (
545 '%prog monkey --minutes=1')
546
547 option_parser.add_option(
548 '--minutes', default=5, type='string',
549 help='Number of minutes to run uirobot test [default: %default].')
550
551 AddCommonOptions(option_parser)
552 AddDeviceOptions(option_parser)
553 AddRemoteDeviceOptions(option_parser)
554
523 def AddPerfTestOptions(option_parser): 555 def AddPerfTestOptions(option_parser):
524 """Adds perf test options to |option_parser|.""" 556 """Adds perf test options to |option_parser|."""
525 557
526 option_parser.usage = '%prog perf [options]' 558 option_parser.usage = '%prog perf [options]'
527 option_parser.commands_dict = {} 559 option_parser.commands_dict = {}
528 option_parser.example = ('%prog perf ' 560 option_parser.example = ('%prog perf '
529 '[--single-step -- command args] or ' 561 '[--single-step -- command args] or '
530 '[--steps perf_steps.json] or ' 562 '[--steps perf_steps.json] or '
531 '[--print-step step]') 563 '[--print-step step]')
532 564
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 elif command == 'perf': 927 elif command == 'perf':
896 return _RunPerfTests(options, args, option_parser.error) 928 return _RunPerfTests(options, args, option_parser.error)
897 elif command == 'python': 929 elif command == 'python':
898 return _RunPythonTests(options, option_parser.error) 930 return _RunPythonTests(options, option_parser.error)
899 else: 931 else:
900 raise Exception('Unknown test type.') 932 raise Exception('Unknown test type.')
901 933
902 934
903 _SUPPORTED_IN_PLATFORM_MODE = [ 935 _SUPPORTED_IN_PLATFORM_MODE = [
904 # TODO(jbudorick): Add support for more test types. 936 # TODO(jbudorick): Add support for more test types.
905 'gtest', 937 'gtest','uirobot',
jbudorick 2014/11/21 00:17:26 nit: space after the first comma
rnephew (Reviews Here) 2014/11/21 18:26:48 Done.
906 ] 938 ]
907 939
908 940
909 def RunTestsInPlatformMode(command, options, option_parser): 941 def RunTestsInPlatformMode(command, options, option_parser):
910 942
911 if command not in _SUPPORTED_IN_PLATFORM_MODE: 943 if command not in _SUPPORTED_IN_PLATFORM_MODE:
912 option_parser.error('%s is not yet supported in platform mode' % command) 944 option_parser.error('%s is not yet supported in platform mode' % command)
913 945
914 with environment_factory.CreateEnvironment( 946 with environment_factory.CreateEnvironment(
915 command, options, option_parser.error) as env: 947 command, options, option_parser.error) as env:
916 with test_instance_factory.CreateTestInstance( 948 with test_instance_factory.CreateTestInstance(
917 command, options, option_parser.error) as test: 949 command, options, option_parser.error) as test:
918 with test_run_factory.CreateTestRun( 950 with test_run_factory.CreateTestRun(
919 options, env, test, option_parser.error) as test_run: 951 options, env, test, option_parser.error) as test_run:
920 results = test_run.RunTests() 952 results = test_run.RunTest()
953
954 if options.environment == 'remote_device':
jbudorick 2014/11/21 00:17:26 wip on my end
955 print results
956 return
921 957
922 report_results.LogFull( 958 report_results.LogFull(
923 results=results, 959 results=results,
924 test_type=test.TestType(), 960 test_type=test.TestType(),
925 test_package=test_run.TestPackage(), 961 test_package=test_run.TestPackage(),
926 annotation=options.annotations, 962 annotation=options.annotations,
927 flakiness_server=options.flakiness_dashboard_server) 963 flakiness_server=options.flakiness_dashboard_server)
928 964
929 return results 965 return results
930 966
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 'junit': CommandFunctionTuple( 1020 'junit': CommandFunctionTuple(
985 AddJUnitTestOptions, RunTestsCommand), 1021 AddJUnitTestOptions, RunTestsCommand),
986 'monkey': CommandFunctionTuple( 1022 'monkey': CommandFunctionTuple(
987 AddMonkeyTestOptions, RunTestsCommand), 1023 AddMonkeyTestOptions, RunTestsCommand),
988 'perf': CommandFunctionTuple( 1024 'perf': CommandFunctionTuple(
989 AddPerfTestOptions, RunTestsCommand), 1025 AddPerfTestOptions, RunTestsCommand),
990 'python': CommandFunctionTuple( 1026 'python': CommandFunctionTuple(
991 AddPythonTestOptions, RunTestsCommand), 1027 AddPythonTestOptions, RunTestsCommand),
992 'linker': CommandFunctionTuple( 1028 'linker': CommandFunctionTuple(
993 AddLinkerTestOptions, RunTestsCommand), 1029 AddLinkerTestOptions, RunTestsCommand),
1030 'uirobot': CommandFunctionTuple(
1031 AddUirobotTestOptions, RunTestsCommand),
994 'help': CommandFunctionTuple(lambda option_parser: None, HelpCommand) 1032 'help': CommandFunctionTuple(lambda option_parser: None, HelpCommand)
995 } 1033 }
996 1034
997 1035
998 def DumpThreadStacks(_signal, _frame): 1036 def DumpThreadStacks(_signal, _frame):
999 for thread in threading.enumerate(): 1037 for thread in threading.enumerate():
1000 reraiser_thread.LogThreadStack(thread) 1038 reraiser_thread.LogThreadStack(thread)
1001 1039
1002 1040
1003 def main(): 1041 def main():
1004 signal.signal(signal.SIGUSR1, DumpThreadStacks) 1042 signal.signal(signal.SIGUSR1, DumpThreadStacks)
1005 option_parser = command_option_parser.CommandOptionParser( 1043 option_parser = command_option_parser.CommandOptionParser(
1006 commands_dict=VALID_COMMANDS) 1044 commands_dict=VALID_COMMANDS)
1007 return command_option_parser.ParseAndExecute(option_parser) 1045 return command_option_parser.ParseAndExecute(option_parser)
1008 1046
1009 1047
1010 if __name__ == '__main__': 1048 if __name__ == '__main__':
1011 sys.exit(main()) 1049 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698