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

Side by Side Diff: scripts/slave/telemetry.py

Issue 28933002: Android: do not run telemetry directly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 #! /usr/bin/env python 1 #! /usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 """Set up and invoke telemetry tests.""" 6 """Set up and invoke telemetry tests."""
7 7
8 import json 8 import json
9 import optparse 9 import optparse
10 import os 10 import os
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 def _GenerateTelemetryCommandSequence(options): 55 def _GenerateTelemetryCommandSequence(options):
56 """Given a test name, page set, and target, generate a telemetry test seq.""" 56 """Given a test name, page set, and target, generate a telemetry test seq."""
57 fp = options.factory_properties 57 fp = options.factory_properties
58 test_name = fp.get('test_name') 58 test_name = fp.get('test_name')
59 extra_args = fp.get('extra_args') 59 extra_args = fp.get('extra_args')
60 target = fp.get('target') 60 target = fp.get('target')
61 target_os = fp.get('target_os') 61 target_os = fp.get('target_os')
62 target_platform = fp.get('target_platform') 62 target_platform = fp.get('target_platform')
63 build_dir = fp.get('build_dir') 63 build_dir = fp.get('build_dir')
64 64
65 script = os.path.join('src', 'tools', 'perf', 'run_benchmark')
66
67 test_specification = [test_name] 65 test_specification = [test_name]
68 66
69 env = os.environ 67 commands = []
70
71 # List of command line arguments common to all test platforms. 68 # List of command line arguments common to all test platforms.
72 common_args = ['-v', '--output-format=buildbot'] 69 common_args = ['-v', '--output-format=buildbot']
73 if extra_args: 70 if extra_args:
74 common_args.extend(extra_args) 71 common_args.extend(extra_args)
75 72
76 # On android, telemetry needs to use the adb command and needs to be in
77 # root mode. Run it in bash since envsetup.sh doesn't work in sh.
78 if target_os == 'android':
79 env['PATH'] = os.pathsep.join(['/b/build_internal/scripts/slave/android',
80 env['PATH']])
81 commands = [['adb', 'root'], ['adb', 'wait-for-device']]
82 else:
83 commands = []
84
85 # Run the test against the target chrome build. 73 # Run the test against the target chrome build.
86 browser = target.lower() 74 browser = target.lower()
87 if target_os == 'android': 75 if target_os == 'android':
88 browser = options.target_android_browser 76 script = os.path.join('src', 'build', 'android', 'test_runner.py')
89 test_args = list(common_args) 77 test_args = ['perf', '--print', test_name]
90 test_args.append('--browser=%s' % browser) 78 else:
91 test_args.extend(test_specification) 79 script = os.path.join('src', 'tools', 'perf', 'run_benchmark')
80 test_args = list(common_args)
81 test_args.append('--browser=%s' % browser)
82 test_args.extend(test_specification)
92 test_cmd = _GetPythonTestCommand(script, target, build_dir, test_args, fp=fp) 83 test_cmd = _GetPythonTestCommand(script, target, build_dir, test_args, fp=fp)
93 commands.append(test_cmd) 84 commands.append(test_cmd)
94 85
95 # Run the test against the target chrome build for different user profiles on 86 # Run the test against the target chrome build for different user profiles on
96 # certain page cyclers. 87 # certain page cyclers.
97 if target_os != 'android': 88 if target_os != 'android':
98 if test_name in ('page_cycler_moz', 'page_cycler_morejs'): 89 if test_name in ('page_cycler_moz', 'page_cycler_morejs'):
99 test_args = list(common_args) 90 test_args = list(common_args)
100 test_args.extend(['--profile-type=typical_user', 91 test_args.extend(['--profile-type=typical_user',
101 '--output-trace-tag=_extcs1', '--browser=%s' % browser]) 92 '--output-trace-tag=_extcs1', '--browser=%s' % browser])
(...skipping 14 matching lines...) Expand all
116 ref_build = _GetReferenceBuildPath(target_os, target_platform) 107 ref_build = _GetReferenceBuildPath(target_os, target_platform)
117 if ref_build and fp.get('run_reference_build', True): 108 if ref_build and fp.get('run_reference_build', True):
118 ref_args = list(common_args) 109 ref_args = list(common_args)
119 ref_args.extend(['--browser=exact', 110 ref_args.extend(['--browser=exact',
120 '--browser-executable=%s' % ref_build, 111 '--browser-executable=%s' % ref_build,
121 '--output-trace-tag=_ref']) 112 '--output-trace-tag=_ref'])
122 ref_args.extend(test_specification) 113 ref_args.extend(test_specification)
123 ref_cmd = _GetPythonTestCommand(script, target, build_dir, ref_args, fp=fp) 114 ref_cmd = _GetPythonTestCommand(script, target, build_dir, ref_args, fp=fp)
124 commands.append(ref_cmd) 115 commands.append(ref_cmd)
125 116
126 return commands, env 117 return commands
127 118
128 119
129 def main(argv): 120 def main(argv):
130 prog_desc = 'Invoke telemetry performance tests.' 121 prog_desc = 'Invoke telemetry performance tests.'
131 parser = optparse.OptionParser(usage=('%prog [options]' + '\n\n' + prog_desc)) 122 parser = optparse.OptionParser(usage=('%prog [options]' + '\n\n' + prog_desc))
132 parser.add_option('--print-cmd', action='store_true', 123 parser.add_option('--print-cmd', action='store_true',
133 help='only print command instead of running it') 124 help='only print command instead of running it')
134 parser.add_option('--target-android-browser', 125 parser.add_option('--target-android-browser',
135 default='android-chromium-testshell', 126 default='android-chromium-testshell',
136 help='target browser used on Android') 127 help='target browser used on Android')
137 parser.add_option('--factory-properties', action='callback', 128 parser.add_option('--factory-properties', action='callback',
138 callback=chromium_utils.convert_json, type='string', 129 callback=chromium_utils.convert_json, type='string',
139 nargs=1, default={}, 130 nargs=1, default={},
140 help='factory properties in JSON format') 131 help='factory properties in JSON format')
141 132
142 options, _ = parser.parse_args(argv[1:]) 133 options, _ = parser.parse_args(argv[1:])
143 if not options.factory_properties: 134 if not options.factory_properties:
144 print 'This program requires a factory properties to run.' 135 print 'This program requires a factory properties to run.'
145 return 1 136 return 1
146 137
147 commands, env = _GenerateTelemetryCommandSequence(options) 138 commands = _GenerateTelemetryCommandSequence(options)
148 139
149 retval = 0 140 retval = 0
150 for command in commands: 141 for command in commands:
151 if options.print_cmd: 142 if options.print_cmd:
152 print ' '.join("'%s'" % c for c in command) 143 print ' '.join("'%s'" % c for c in command)
153 continue 144 continue
154 145
155 retval = chromium_utils.RunCommand(command, env=env) 146 retval = chromium_utils.RunCommand(command)
156 if retval != 0: 147 if retval != 0:
157 break 148 break
158 return retval 149 return retval
159 150
160 151
161 if '__main__' == __name__: 152 if '__main__' == __name__:
162 sys.exit(main(sys.argv)) 153 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698