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

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

Issue 7031020: Change for preparation for reference-build on perfbot (media) (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add a space. Created 9 years, 7 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/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2011 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 """A module to execute a subclass of MediaTastBase class. 7 """A module to execute a subclass of MediaTastBase class.
8 8
9 This executes a media test class (a subclass of MediaTastBase class) with 9 This executes a media test class (a subclass of MediaTastBase class) with
10 different configuration (parameters) which are passed in the form of 10 different configuration (parameters) which are passed in the form of
(...skipping 18 matching lines...) Expand all
29 from media_test_env_names import MediaTestEnvNames 29 from media_test_env_names import MediaTestEnvNames
30 from media_test_matrix import MediaTestMatrix 30 from media_test_matrix import MediaTestMatrix
31 31
32 32
33 def main(): 33 def main():
34 EXTRA_NICKNAMES = ['nocache', 'cache'] 34 EXTRA_NICKNAMES = ['nocache', 'cache']
35 # Disable/enable media_cache. 35 # Disable/enable media_cache.
36 CHROME_FLAGS = ['--chrome-flags=\'--media-cache-size=1\'', ''] 36 CHROME_FLAGS = ['--chrome-flags=\'--media-cache-size=1\'', '']
37 # The 't' parameter is passed to player.html to disable/enable the media 37 # The 't' parameter is passed to player.html to disable/enable the media
38 # cache (refer to data/media/html/player.js). 38 # cache (refer to data/media/html/player.js).
39 ADD_T_PARAMETERS = ['Y', 'N'] 39 ADD_T_PARAMETERS = [False, True]
40 # Player.html should contain all the HTML and Javascript that is 40 # Player.html should contain all the HTML and Javascript that is
41 # necessary to run these tests. 41 # necessary to run these tests.
42 DEFAULT_PLAYER_HTML_URL = 'DEFAULT' 42 DEFAULT_PLAYER_HTML_URL = 'DEFAULT'
43 DEFAULT_PLAYER_HTML_URL_NICKNAME = 'local' 43 DEFAULT_PLAYER_HTML_URL_NICKNAME = 'local'
44 # Default base url nickname used to display the result in case it is not 44 # Default base url nickname used to display the result in case it is not
45 # specified by the environment variable. 45 # specified by the environment variable.
46 DEFAULT_PLAYER_HTML_URL_NICKNAME = 'local' 46 DEFAULT_PLAYER_HTML_URL_NICKNAME = 'local'
47 PRINT_ONLY_TIME = 'Y' 47 REMOVE_FIRST_RESULT = True
48 REMOVE_FIRST_RESULT = 'Y'
49 # The number of runs for each test. This is used to compute average values 48 # The number of runs for each test. This is used to compute average values
50 # from among all runs. 49 # from among all runs.
51 DEFAULT_NUMBER_OF_RUNS = 3 50 DEFAULT_NUMBER_OF_RUNS = 3
52 # The interval between measurement calls. 51 # The interval between measurement calls.
53 DEFAULT_MEASURE_INTERVALS = 3 52 DEFAULT_MEASURE_INTERVALS = 3
54 DEFAULT_SUITE_NAME = 'MEDIA_TESTS' 53 DEFAULT_SUITE_NAME = 'MEDIA_TESTS'
55 # This script is used to run the PYAUTO suite. 54 # This script is used to run the PYAUTO suite.
56 pyauto_functional_script_name = os.path.join(os.path.dirname(__file__), 55 pyauto_functional_script_name = os.path.join(os.path.dirname(__file__),
57 'pyauto_media.py') 56 'pyauto_media.py')
58 # This defines default file name for CSV file. 57 # This defines default file name for CSV file.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 parser.add_option( 104 parser.add_option(
106 '-c', '--test_scenario', dest='test_scenario', 105 '-c', '--test_scenario', dest='test_scenario',
107 default='', help='Test scenario (action triples delimited by \'|\')') 106 default='', help='Test scenario (action triples delimited by \'|\')')
108 parser.add_option('-s', '--suite', dest='suite', 107 parser.add_option('-s', '--suite', dest='suite',
109 help='Suite file') 108 help='Suite file')
110 parser.add_option('-e', '--media_file', dest='media_file', 109 parser.add_option('-e', '--media_file', dest='media_file',
111 default='', 110 default='',
112 help=('Media file to be played using player.html. ' 111 help=('Media file to be played using player.html. '
113 'The relative path needs to be specified starting ' 112 'The relative path needs to be specified starting '
114 'from data/html/ directory.')) 113 'from data/html/ directory.'))
114 parser.add_option('-a', '--reference_build', dest='reference_build',
115 help='Include reference build run', default=False,
116 action='store_true')
117 parser.add_option('-k', '--reference_build_dir', dest='reference_build_dir',
118 help='reference build dir location')
dennis_jeffrey 2011/05/20 18:10:46 reference --> Reference
dennis_jeffrey 2011/05/20 18:10:46 Maybe this would be more clear? dir location -->
imasaki1 2011/05/20 20:50:14 Done.
imasaki1 2011/05/20 20:50:14 Rewrite to match in the comments in the code below
119 parser.add_option('-v', '--verbose', dest='verbose', help='verbose mode',
dennis_jeffrey 2011/05/20 18:10:46 verbose mode --> Verbose mode
imasaki1 2011/05/20 20:50:14 Done.
120 default=False, action='store_true')
115 121
116 options, args = parser.parse_args() 122 options, args = parser.parse_args()
117 if args: 123 if args:
118 parser.print_help() 124 parser.print_help()
119 sys.exit(1) 125 sys.exit(1)
120 126
121 test_data_list = [] 127 test_data_list = []
122 if options.media_file: 128 if options.media_file:
123 test_data_list.append(['video', options.media_file, options.media_file]) 129 test_data_list.append(['video', options.media_file, options.media_file])
124 elif options.input_matrix_filename is None: 130 elif options.input_matrix_filename is None:
(...skipping 11 matching lines...) Expand all
136 True, options.video_matrix_home_url) 142 True, options.video_matrix_home_url)
137 if options.input_matrix_testcase_name is None: 143 if options.input_matrix_testcase_name is None:
138 # Use all test cases. 144 # Use all test cases.
139 test_data_list = all_data_list 145 test_data_list = all_data_list
140 else: 146 else:
141 # Choose particular video. 147 # Choose particular video.
142 media_info = MediaTestMatrix.LookForMediaInfoInCompactFormByNickName( 148 media_info = MediaTestMatrix.LookForMediaInfoInCompactFormByNickName(
143 all_data_list, options.input_matrix_testcase_name) 149 all_data_list, options.input_matrix_testcase_name)
144 if media_info is not None: 150 if media_info is not None:
145 test_data_list.append(media_info) 151 test_data_list.append(media_info)
152
153 # Determine whether we need to repeat a test using a reference build.
154 # The default is not to include a test using a reference build.
155 if options.reference_build:
156 reference_build_list = [False, True]
157 else:
158 reference_build_list = [False]
146 # This is a loop for iterating through all videos defined above (list 159 # This is a loop for iterating through all videos defined above (list
147 # or matrix). Each video has associated tag and nickname for display 160 # or matrix). Each video has associated tag and nickname for display
148 # purpose. 161 # purpose.
149 for tag, filename, nickname in test_data_list: 162 for tag, filename, nickname in test_data_list:
150 # This inner loop iterates twice. The first iteration of the loop 163 # This inner loop iterates twice. The first iteration of the loop
151 # disables the media cache, and the second iteration enables the media 164 # disables the media cache, and the second iteration enables the media
152 # cache. Other parameters remain the same on both loop iterations. 165 # cache. Other parameters remain the same on both loop iterations.
153 # There are two ways to disable the media cache: setting Chrome option 166 # There are two ways to disable the media cache: setting Chrome option
154 # to --media-cache-size=1 or adding t parameter in query parameter of 167 # to --media-cache-size=1 or adding t parameter in query parameter of
155 # URL in which player.js (data/media/html/player.js) disables the 168 # URL in which player.js (data/media/html/player.js) disables the
156 # media cache). We are doing both here. Please note the length of 169 # media cache). We are doing both here. Please note the length of
157 # CHROME_FLAGS and ADD_T_PARAMETERS should be the same. 170 # CHROME_FLAGS and ADD_T_PARAMETERS should be the same.
158 for j in range(len(CHROME_FLAGS)): 171 for j in range(len(CHROME_FLAGS)):
159 parent_envs = copy.deepcopy(os.environ) 172 for reference_build in reference_build_list:
160 if options.input_matrix_filename is None: 173 parent_envs = copy.deepcopy(os.environ)
161 filename = os.path.join(os.pardir, filename) 174 if options.input_matrix_filename is None:
162 envs = { 175 par_filename = os.path.join(os.pardir, filename)
163 MediaTestEnvNames.MEDIA_TAG_ENV_NAME: tag, 176 envs = {
164 MediaTestEnvNames.MEDIA_FILENAME_ENV_NAME: filename, 177 MediaTestEnvNames.MEDIA_TAG_ENV_NAME: tag,
165 MediaTestEnvNames.MEDIA_FILENAME_NICKNAME_ENV_NAME: nickname, 178 MediaTestEnvNames.MEDIA_FILENAME_ENV_NAME: par_filename,
166 MediaTestEnvNames.PLAYER_HTML_URL_ENV_NAME: 179 MediaTestEnvNames.MEDIA_FILENAME_NICKNAME_ENV_NAME: nickname,
167 options.player_html_url, 180 MediaTestEnvNames.PLAYER_HTML_URL_ENV_NAME:
168 MediaTestEnvNames.PLAYER_HTML_URL_NICKNAME_ENV_NAME: 181 options.player_html_url,
169 options.player_html_url_nickname, 182 MediaTestEnvNames.PLAYER_HTML_URL_NICKNAME_ENV_NAME:
170 MediaTestEnvNames.EXTRA_NICKNAME_ENV_NAME: 183 options.player_html_url_nickname,
171 EXTRA_NICKNAMES[j], 184 MediaTestEnvNames.EXTRA_NICKNAME_ENV_NAME:
172 # Enables or disables the media cache. 185 EXTRA_NICKNAMES[j],
173 # (refer to data/media/html/player.js) 186 # Enables or disables the media cache.
174 MediaTestEnvNames.ADD_T_PARAMETER_ENV_NAME: ADD_T_PARAMETERS[j], 187 # (refer to data/media/html/player.js)
175 MediaTestEnvNames.PRINT_ONLY_TIME_ENV_NAME: PRINT_ONLY_TIME, 188 MediaTestEnvNames.N_RUNS_ENV_NAME: str(options.number_of_runs),
176 MediaTestEnvNames.N_RUNS_ENV_NAME: str(options.number_of_runs), 189 MediaTestEnvNames.MEASURE_INTERVAL_ENV_NAME:
177 MediaTestEnvNames.REMOVE_FIRST_RESULT_ENV_NAME: 190 str(options.measure_intervals),
178 REMOVE_FIRST_RESULT, 191 MediaTestEnvNames.TEST_SCENARIO_FILE_ENV_NAME:
179 MediaTestEnvNames.MEASURE_INTERVAL_ENV_NAME: 192 options.test_scenario_input_filename,
180 str(options.measure_intervals), 193 MediaTestEnvNames.TEST_SCENARIO_ENV_NAME:
181 MediaTestEnvNames.TEST_SCENARIO_FILE_ENV_NAME: 194 options.test_scenario,
182 options.test_scenario_input_filename, 195 }
183 MediaTestEnvNames.TEST_SCENARIO_ENV_NAME: 196 # Boolean variables and their related variables.
184 options.test_scenario, 197 if ADD_T_PARAMETERS[j]:
185 } 198 envs[MediaTestEnvNames.ADD_T_PARAMETER_ENV_NAME] = str(
186 envs.update(parent_envs) 199 ADD_T_PARAMETERS[j])
187 if options.suite is None and options.test_prog_name is not None: 200 if reference_build:
188 # Suite is not used - run test program directly. 201 envs[MediaTestEnvNames.REFERENCE_BUILD_ENV_NAME] = str(
189 test_prog_name = options.test_prog_name 202 reference_build)
190 suite_string = '' 203 if REMOVE_FIRST_RESULT:
191 else: 204 envs[MediaTestEnvNames.REMOVE_FIRST_RESULT_ENV_NAME] = str(
192 # Suite is used. 205 REMOVE_FIRST_RESULT)
193 # The test script names are in the PYAUTO_TEST file. 206 if options.reference_build_dir:
194 test_prog_name = pyauto_functional_script_name 207 envs[MediaTestEnvNames.REFERENCE_BUILD_DIR_ENV_NAME] = (
195 if options.suite is None: 208 options.reference_build_dir)
196 suite_name = DEFAULT_SUITE_NAME 209 envs.update(parent_envs)
210 if options.suite is None and options.test_prog_name is not None:
211 # Suite is not used - run test program directly.
212 test_prog_name = options.test_prog_name
213 suite_string = ''
197 else: 214 else:
198 suite_name = options.suite 215 # Suite is used.
199 suite_string = ' --suite=%s' % suite_name 216 # The test script names are in the PYAUTO_TEST file.
200 test_prog_name = sys.executable + ' ' + test_prog_name 217 test_prog_name = pyauto_functional_script_name
201 cmd = test_prog_name + suite_string + ' ' + CHROME_FLAGS[j] 218 if options.suite is None:
202 proc = Popen(cmd, env=envs, shell=True) 219 suite_name = DEFAULT_SUITE_NAME
203 proc.communicate() 220 else:
221 suite_name = options.suite
222 suite_string = ' --suite=%s' % suite_name
223 test_prog_name = sys.executable + ' ' + test_prog_name
224 cmd = test_prog_name + suite_string + ' ' + CHROME_FLAGS[j]
225 if options.verbose:
226 cmd += ' -v'
227 proc = Popen(cmd, env=envs, shell=True)
228 proc.communicate()
204 if options.one_combination: 229 if options.one_combination:
205 sys.exit(0) 230 sys.exit(0)
206 231
207 232
208 if __name__ == '__main__': 233 if __name__ == '__main__':
209 main() 234 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698