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

Side by Side Diff: chrome/test/functional/media/media_test_runner.py

Issue 7074060: Adding more commandline options and CHROME_FLAGS cleanup in media_perf test. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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 """A module to execute a subclass of MediaTastBase class. 6 """A module to execute a subclass of MediaTastBase class.
7 7
8 This executes a media test class (a subclass of MediaTastBase class) with 8 This executes a media test class (a subclass of MediaTastBase class) with
9 different configuration (parameters) which are passed in the form of 9 different configuration (parameters) which are passed in the form of
10 environment variables (e.g., the number of runs). The location of the 10 environment variables (e.g., the number of runs). The location of the
(...skipping 12 matching lines...) Expand all
23 from optparse import OptionParser 23 from optparse import OptionParser
24 import shlex 24 import shlex
25 import sys 25 import sys
26 from subprocess import Popen 26 from subprocess import Popen
27 27
28 from media_test_env_names import MediaTestEnvNames 28 from media_test_env_names import MediaTestEnvNames
29 from media_test_matrix import MediaTestMatrix 29 from media_test_matrix import MediaTestMatrix
30 30
31 31
32 def main(): 32 def main():
33 EXTRA_NICKNAMES = ['nocache', 'cache'] 33 CHROME_FLAGS = {'disable_cache': '--media-cache-size=1',
34 # Disable/enable media_cache. 34 'track': '--enable-video-track'}
35 CHROME_FLAGS = ['--chrome-flags=\'--media-cache-size=1\'', '']
36 # The 't' parameter is passed to player.html to disable/enable the media
37 # cache (refer to data/media/html/player.js).
38 ADD_T_PARAMETERS = [False, True]
39 # Player.html should contain all the HTML and Javascript that is 35 # Player.html should contain all the HTML and Javascript that is
40 # necessary to run these tests. 36 # necessary to run these tests.
41 DEFAULT_PLAYER_HTML_URL = 'DEFAULT' 37 DEFAULT_PLAYER_HTML_URL = 'DEFAULT'
42 DEFAULT_PLAYER_HTML_URL_NICKNAME = 'local' 38 DEFAULT_PLAYER_HTML_URL_NICKNAME = 'local'
43 # Default base url nickname used to display the result in case it is not 39 # Default base url nickname used to display the result in case it is not
44 # specified by the environment variable. 40 # specified by the environment variable.
45 DEFAULT_PLAYER_HTML_URL_NICKNAME = 'local' 41 DEFAULT_PLAYER_HTML_URL_NICKNAME = 'local'
46 REMOVE_FIRST_RESULT = True 42 REMOVE_FIRST_RESULT = True
47 # The number of runs for each test. This is used to compute average values 43 # The number of runs for each test. This is used to compute average values
48 # from among all runs. 44 # from among all runs.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 help='Player.html Nickname [defaults to "%s"]' % 81 help='Player.html Nickname [defaults to "%s"]' %
86 DEFAULT_PLAYER_HTML_URL_NICKNAME) 82 DEFAULT_PLAYER_HTML_URL_NICKNAME)
87 parser.add_option('-n', '--number_of_runs', dest='number_of_runs', 83 parser.add_option('-n', '--number_of_runs', dest='number_of_runs',
88 default=DEFAULT_NUMBER_OF_RUNS, 84 default=DEFAULT_NUMBER_OF_RUNS,
89 help='The number of runs [defaults to "%d"]' % 85 help='The number of runs [defaults to "%d"]' %
90 DEFAULT_NUMBER_OF_RUNS) 86 DEFAULT_NUMBER_OF_RUNS)
91 parser.add_option('-m', '--measure_intervals', dest='measure_intervals', 87 parser.add_option('-m', '--measure_intervals', dest='measure_intervals',
92 default=DEFAULT_MEASURE_INTERVALS, 88 default=DEFAULT_MEASURE_INTERVALS,
93 help='Interval for measurement data [defaults to "%d"]' % 89 help='Interval for measurement data [defaults to "%d"]' %
94 DEFAULT_MEASURE_INTERVALS) 90 DEFAULT_MEASURE_INTERVALS)
95 parser.add_option('-c', '--cache_test', dest='cache_test', 91 parser.add_option('-c', '--disable_media_cache', dest='disable_media_cache',
96 default=False, help='Include cache test', 92 default=False, help='Disable media cache',
97 action='store_true') 93 action='store_true')
98 parser.add_option('-z', '--test-one-video', dest='one_video', 94 parser.add_option('-z', '--test-one-video', dest='one_video',
99 default=False, help='Run only one video', 95 default=False, help='Run only one video',
100 action='store_true') 96 action='store_true')
101 parser.add_option( 97 parser.add_option(
102 '-w', '--test_scenario_input_filename', 98 '-w', '--test_scenario_input_filename',
103 dest='test_scenario_input_filename', 99 dest='test_scenario_input_filename',
104 default='', help='Test scenario file (CSV form)', metavar='FILE') 100 default='', help='Test scenario file (CSV form)', metavar='FILE')
105 parser.add_option( 101 parser.add_option(
106 '-q', '--test_scenario', dest='test_scenario', 102 '-q', '--test_scenario', dest='test_scenario',
107 default='', help='Test scenario (action triples delimited by \'|\')') 103 default='', help='Test scenario (action triples delimited by \'|\')')
108 parser.add_option('-s', '--suite', dest='suite', 104 parser.add_option('-s', '--suite', dest='suite',
109 help='Suite file') 105 help='Suite file')
110 parser.add_option('-e', '--media_file', dest='media_file', 106 parser.add_option('-e', '--media_file', dest='media_file',
111 default='', 107 default='',
112 help=('Media file to be played using player.html. ' 108 help=('Media file to be played using player.html. '
113 'The relative path needs to be specified starting ' 109 'The relative path needs to be specified starting '
114 'from data/html/ directory.')) 110 'from data/html/ directory.'))
115 parser.add_option('-a', '--reference_build', dest='reference_build', 111 parser.add_option('-a', '--reference_build', dest='reference_build',
116 help='Include reference build run', default=False, 112 help='Include reference build run', default=False,
117 action='store_true') 113 action='store_true')
118 parser.add_option('-k', '--reference_build_dir', dest='reference_build_dir', 114 parser.add_option('-k', '--reference_build_dir', dest='reference_build_dir',
119 help=('A absolute path to the directory that contains' 115 help=('A absolute path to the directory that contains'
120 'binaries of reference build.')) 116 'binaries of reference build.'))
121 parser.add_option('-v', '--verbose', dest='verbose', help='Verbose mode.', 117 parser.add_option('-v', '--verbose', dest='verbose', help='Verbose mode.',
122 default=False, action='store_true') 118 default=False, action='store_true')
123 119 parser.add_option('-j', '--track', dest='track',
120 help=('Run track test (binary should be downloaded'
121 ' from http://www.annacavender.com/track/'
122 ' and put into reference_build_dir).'),
123 default=False, action='store_true')
124 options, args = parser.parse_args() 124 options, args = parser.parse_args()
125 if args: 125 if args:
126 parser.print_help() 126 parser.print_help()
127 sys.exit(1) 127 sys.exit(1)
128 128
129 test_data_list = [] 129 test_data_list = []
130 if options.media_file: 130 if options.media_file:
131 test_data_list.append(['video', options.media_file, options.media_file]) 131 test_data_list.append(['video', options.media_file, options.media_file])
132 elif options.input_matrix_filename is None: 132 elif options.input_matrix_filename is None:
133 file = open(options.input_filename, 'rb') 133 file = open(options.input_filename, 'rb')
(...skipping 17 matching lines...) Expand all
151 all_data_list, options.input_matrix_testcase_name) 151 all_data_list, options.input_matrix_testcase_name)
152 if media_info is not None: 152 if media_info is not None:
153 test_data_list.append(media_info) 153 test_data_list.append(media_info)
154 154
155 # Determine whether we need to repeat a test using a reference build. 155 # Determine whether we need to repeat a test using a reference build.
156 # The default is not to include a test using a reference build. 156 # The default is not to include a test using a reference build.
157 if options.reference_build: 157 if options.reference_build:
158 reference_build_list = [False, True] 158 reference_build_list = [False, True]
159 else: 159 else:
160 reference_build_list = [False] 160 reference_build_list = [False]
161 if options.track:
162 # TODO(imasaki@chromium.org): change here after track functionality is
163 # available on Chrome. Currently, track patch is still under development.
164 # So, I need to download the binary from
165 # http://www.annacavender.com/track/ and use it for testing.
166 # I temporary use reference build mechanism.
dennis_jeffrey 2011/06/08 00:44:55 "temporary" --> "temporarily"
imasaki1 2011/06/08 13:25:38 Done.
167 reference_build_list = [True]
161 # This is a loop for iterating through all videos defined above (list 168 # This is a loop for iterating through all videos defined above (list
162 # or matrix). Each video has associated tag and nickname for display 169 # or matrix). Each video has associated tag and nickname for display
163 # purpose. 170 # purpose.
164 for tag, filename, nickname in test_data_list: 171 for tag, filename, nickname in test_data_list:
165 # This inner loop iterates twice. The first iteration of the loop 172 # This inner loop iterates twice. The first iteration of the loop
166 # disables the media cache, and the second iteration enables the media 173 # disables the media cache, and the second iteration enables the media
167 # cache. Other parameters remain the same on both loop iterations. 174 # cache. Other parameters remain the same on both loop iterations.
168 # There are two ways to disable the media cache: setting Chrome option 175 # There are two ways to disable the media cache: setting Chrome option
169 # to --media-cache-size=1 or adding t parameter in query parameter of 176 # to --media-cache-size=1 or adding t parameter in query parameter of
170 # URL in which player.js (data/media/html/player.js) disables the 177 # URL in which player.js (data/media/html/player.js) disables the
171 # media cache). We are doing both here. Please note the length of 178 # media cache).
172 # CHROME_FLAGS and ADD_T_PARAMETERS should be the same. 179 for reference_build in reference_build_list:
173 for j in range(len(CHROME_FLAGS)): 180 parent_envs = copy.deepcopy(os.environ)
174 for reference_build in reference_build_list: 181 if options.input_matrix_filename is None:
175 parent_envs = copy.deepcopy(os.environ) 182 par_filename = os.path.join(os.pardir, filename)
176 if options.input_matrix_filename is None: 183 else:
177 par_filename = os.path.join(os.pardir, filename) 184 par_filename = filename
185 envs = {
186 MediaTestEnvNames.MEDIA_TAG_ENV_NAME: tag,
187 MediaTestEnvNames.MEDIA_FILENAME_ENV_NAME: par_filename,
188 MediaTestEnvNames.MEDIA_FILENAME_NICKNAME_ENV_NAME: nickname,
189 MediaTestEnvNames.PLAYER_HTML_URL_ENV_NAME:
190 options.player_html_url,
191 MediaTestEnvNames.PLAYER_HTML_URL_NICKNAME_ENV_NAME:
192 options.player_html_url_nickname,
193 MediaTestEnvNames.N_RUNS_ENV_NAME: str(options.number_of_runs),
194 MediaTestEnvNames.MEASURE_INTERVAL_ENV_NAME:
195 str(options.measure_intervals),
196 MediaTestEnvNames.TEST_SCENARIO_FILE_ENV_NAME:
197 options.test_scenario_input_filename,
198 MediaTestEnvNames.TEST_SCENARIO_ENV_NAME:
199 options.test_scenario,
200 }
201 # Boolean variables and their related variables.
202 if options.disable_media_cache:
203 # The 't' parameter is passed to player.html to disable/enable
204 # the media cache (refer to data/media/html/player.js).
dennis_jeffrey 2011/06/08 00:44:55 Indent lines 203-204 by 1 more space each.
imasaki1 2011/06/08 13:25:38 Done.
205 envs[MediaTestEnvNames.ADD_T_PARAMETER_ENV_NAME] = str(
206 options.disable_media_cache)
207 if reference_build:
208 envs[MediaTestEnvNames.REFERENCE_BUILD_ENV_NAME] = str(
209 reference_build)
210 if REMOVE_FIRST_RESULT:
211 envs[MediaTestEnvNames.REMOVE_FIRST_RESULT_ENV_NAME] = str(
212 REMOVE_FIRST_RESULT)
213 if options.reference_build_dir:
214 envs[MediaTestEnvNames.REFERENCE_BUILD_DIR_ENV_NAME] = (
215 options.reference_build_dir)
216 envs.update(parent_envs)
217 if options.suite is None and options.test_prog_name is not None:
218 # Suite is not used - run test program directly.
219 test_prog_name = options.test_prog_name
220 suite_string = ''
221 else:
222 # Suite is used.
223 # The test script names are in the PYAUTO_TEST file.
dennis_jeffrey 2011/06/08 00:44:55 Do you mean "PYAUTO_TESTS" instead of "PYAUTO_TEST
imasaki1 2011/06/08 13:25:38 Done.
224 test_prog_name = pyauto_functional_script_name
225 if options.suite is None:
226 suite_name = DEFAULT_SUITE_NAME
178 else: 227 else:
179 par_filename = filename 228 suite_name = options.suite
180 envs = { 229 suite_string = ' --suite=%s' % suite_name
181 MediaTestEnvNames.MEDIA_TAG_ENV_NAME: tag, 230 test_prog_name = sys.executable + ' ' + test_prog_name
182 MediaTestEnvNames.MEDIA_FILENAME_ENV_NAME: par_filename, 231 chrome_flag = ''
183 MediaTestEnvNames.MEDIA_FILENAME_NICKNAME_ENV_NAME: nickname, 232 if options.disable_media_cache:
184 MediaTestEnvNames.PLAYER_HTML_URL_ENV_NAME: 233 chrome_flag += CHROME_FLAGS['disable_cache']
185 options.player_html_url, 234 if options.track:
186 MediaTestEnvNames.PLAYER_HTML_URL_NICKNAME_ENV_NAME: 235 chrome_flag += ' ' + CHROME_FLAGS['track']
dennis_jeffrey 2011/06/08 00:44:55 If the condition at line 232 above is false, and t
imasaki1 2011/06/08 13:25:38 Done.
187 options.player_html_url_nickname, 236 if chrome_flag:
188 MediaTestEnvNames.EXTRA_NICKNAME_ENV_NAME: 237 chrome_flag = '--chrome-flags=\'%s\'' % chrome_flag
189 EXTRA_NICKNAMES[j], 238 cmd = test_prog_name + suite_string + ' ' + chrome_flag
190 # Enables or disables the media cache. 239 if options.verbose:
191 # (refer to data/media/html/player.js) 240 cmd += ' -v'
192 MediaTestEnvNames.N_RUNS_ENV_NAME: str(options.number_of_runs), 241 proc = Popen(cmd, env=envs, shell=True)
193 MediaTestEnvNames.MEASURE_INTERVAL_ENV_NAME: 242 proc.communicate()
194 str(options.measure_intervals), 243
195 MediaTestEnvNames.TEST_SCENARIO_FILE_ENV_NAME:
196 options.test_scenario_input_filename,
197 MediaTestEnvNames.TEST_SCENARIO_ENV_NAME:
198 options.test_scenario,
199 }
200 # Boolean variables and their related variables.
201 if ADD_T_PARAMETERS[j]:
202 envs[MediaTestEnvNames.ADD_T_PARAMETER_ENV_NAME] = str(
203 ADD_T_PARAMETERS[j])
204 if reference_build:
205 envs[MediaTestEnvNames.REFERENCE_BUILD_ENV_NAME] = str(
206 reference_build)
207 if REMOVE_FIRST_RESULT:
208 envs[MediaTestEnvNames.REMOVE_FIRST_RESULT_ENV_NAME] = str(
209 REMOVE_FIRST_RESULT)
210 if options.reference_build_dir:
211 envs[MediaTestEnvNames.REFERENCE_BUILD_DIR_ENV_NAME] = (
212 options.reference_build_dir)
213 envs.update(parent_envs)
214 if options.suite is None and options.test_prog_name is not None:
215 # Suite is not used - run test program directly.
216 test_prog_name = options.test_prog_name
217 suite_string = ''
218 else:
219 # Suite is used.
220 # The test script names are in the PYAUTO_TEST file.
221 test_prog_name = pyauto_functional_script_name
222 if options.suite is None:
223 suite_name = DEFAULT_SUITE_NAME
224 else:
225 suite_name = options.suite
226 suite_string = ' --suite=%s' % suite_name
227 test_prog_name = sys.executable + ' ' + test_prog_name
228 cmd = test_prog_name + suite_string + ' ' + CHROME_FLAGS[j]
229 if options.verbose:
230 cmd += ' -v'
231 proc = Popen(cmd, env=envs, shell=True)
232 proc.communicate()
233 if not options.cache_test:
234 break
235 if options.one_video: 244 if options.one_video:
236 break 245 break
237 246
238 247
239 if __name__ == '__main__': 248 if __name__ == '__main__':
240 main() 249 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698