OLD | NEW |
---|---|
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 parser.add_option( | 105 parser.add_option( |
106 '-c', '--test_scenario', dest='test_scenario', | 106 '-c', '--test_scenario', dest='test_scenario', |
107 default='', help='Test scenario (action triples delimited by \'|\')') | 107 default='', help='Test scenario (action triples delimited by \'|\')') |
108 parser.add_option('-s', '--suite', dest='suite', | 108 parser.add_option('-s', '--suite', dest='suite', |
109 help='Suite file') | 109 help='Suite file') |
110 parser.add_option('-e', '--media_file', dest='media_file', | 110 parser.add_option('-e', '--media_file', dest='media_file', |
111 default='', | 111 default='', |
112 help=('Media file to be played using player.html. ' | 112 help=('Media file to be played using player.html. ' |
113 'The relative path needs to be specified starting ' | 113 'The relative path needs to be specified starting ' |
114 'from data/html/ directory.')) | 114 'from data/html/ directory.')) |
115 parser.add_option('-a', '--reference_build', dest='reference_build', | |
116 help='Include reference build run', default=False) | |
dennis_jeffrey
2011/05/19 01:20:13
add the following parameter:
action='store_true'
imasaki1
2011/05/20 05:12:01
Done.
| |
115 | 117 |
116 options, args = parser.parse_args() | 118 options, args = parser.parse_args() |
117 if args: | 119 if args: |
118 parser.print_help() | 120 parser.print_help() |
119 sys.exit(1) | 121 sys.exit(1) |
120 | 122 |
121 test_data_list = [] | 123 test_data_list = [] |
122 if options.media_file: | 124 if options.media_file: |
123 test_data_list.append(['video', options.media_file, options.media_file]) | 125 test_data_list.append(['video', options.media_file, options.media_file]) |
124 elif options.input_matrix_filename is None: | 126 elif options.input_matrix_filename is None: |
(...skipping 11 matching lines...) Expand all Loading... | |
136 True, options.video_matrix_home_url) | 138 True, options.video_matrix_home_url) |
137 if options.input_matrix_testcase_name is None: | 139 if options.input_matrix_testcase_name is None: |
138 # Use all test cases. | 140 # Use all test cases. |
139 test_data_list = all_data_list | 141 test_data_list = all_data_list |
140 else: | 142 else: |
141 # Choose particular video. | 143 # Choose particular video. |
142 media_info = MediaTestMatrix.LookForMediaInfoInCompactFormByNickName( | 144 media_info = MediaTestMatrix.LookForMediaInfoInCompactFormByNickName( |
143 all_data_list, options.input_matrix_testcase_name) | 145 all_data_list, options.input_matrix_testcase_name) |
144 if media_info is not None: | 146 if media_info is not None: |
145 test_data_list.append(media_info) | 147 test_data_list.append(media_info) |
148 | |
149 # Determine if we need to loop. The defsault is False | |
dennis_jeffrey
2011/05/19 01:20:13
I recommend this comment, if it's accurate:
# Det
Nirnimesh
2011/05/19 06:40:20
typo: defsault
imasaki1
2011/05/20 05:12:01
Done.
imasaki1
2011/05/20 05:12:01
Done.
| |
150 reference_build_list = [False] | |
151 # reference_build_list = [True] | |
Nirnimesh
2011/05/19 06:40:20
remove commented code
imasaki1
2011/05/20 05:12:01
Done.
| |
152 if options.reference_build: | |
153 reference_build_list.append(True) | |
dennis_jeffrey
2011/05/19 01:20:13
(optional) I recommend replacing lines 150-153 wit
imasaki1
2011/05/20 05:12:01
Done.
| |
146 # This is a loop for iterating through all videos defined above (list | 154 # This is a loop for iterating through all videos defined above (list |
147 # or matrix). Each video has associated tag and nickname for display | 155 # or matrix). Each video has associated tag and nickname for display |
148 # purpose. | 156 # purpose. |
149 for tag, filename, nickname in test_data_list: | 157 for tag, filename, nickname in test_data_list: |
150 # This inner loop iterates twice. The first iteration of the loop | 158 # This inner loop iterates twice. The first iteration of the loop |
151 # disables the media cache, and the second iteration enables the media | 159 # disables the media cache, and the second iteration enables the media |
152 # cache. Other parameters remain the same on both loop iterations. | 160 # cache. Other parameters remain the same on both loop iterations. |
153 # There are two ways to disable the media cache: setting Chrome option | 161 # 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 | 162 # 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 | 163 # 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 | 164 # media cache). We are doing both here. Please note the length of |
157 # CHROME_FLAGS and ADD_T_PARAMETERS should be the same. | 165 # CHROME_FLAGS and ADD_T_PARAMETERS should be the same. |
158 for j in range(len(CHROME_FLAGS)): | 166 for j in range(len(CHROME_FLAGS)): |
159 parent_envs = copy.deepcopy(os.environ) | 167 for reference_build in reference_build_list: |
160 if options.input_matrix_filename is None: | 168 parent_envs = copy.deepcopy(os.environ) |
161 filename = os.path.join(os.pardir, filename) | 169 if options.input_matrix_filename is None: |
162 envs = { | 170 par_filename = os.path.join(os.pardir, filename) |
163 MediaTestEnvNames.MEDIA_TAG_ENV_NAME: tag, | 171 envs = { |
164 MediaTestEnvNames.MEDIA_FILENAME_ENV_NAME: filename, | 172 MediaTestEnvNames.MEDIA_TAG_ENV_NAME: tag, |
165 MediaTestEnvNames.MEDIA_FILENAME_NICKNAME_ENV_NAME: nickname, | 173 MediaTestEnvNames.MEDIA_FILENAME_ENV_NAME: par_filename, |
166 MediaTestEnvNames.PLAYER_HTML_URL_ENV_NAME: | 174 MediaTestEnvNames.MEDIA_FILENAME_NICKNAME_ENV_NAME: nickname, |
167 options.player_html_url, | 175 MediaTestEnvNames.PLAYER_HTML_URL_ENV_NAME: |
168 MediaTestEnvNames.PLAYER_HTML_URL_NICKNAME_ENV_NAME: | 176 options.player_html_url, |
169 options.player_html_url_nickname, | 177 MediaTestEnvNames.PLAYER_HTML_URL_NICKNAME_ENV_NAME: |
170 MediaTestEnvNames.EXTRA_NICKNAME_ENV_NAME: | 178 options.player_html_url_nickname, |
171 EXTRA_NICKNAMES[j], | 179 MediaTestEnvNames.EXTRA_NICKNAME_ENV_NAME: |
172 # Enables or disables the media cache. | 180 EXTRA_NICKNAMES[j], |
173 # (refer to data/media/html/player.js) | 181 # Enables or disables the media cache. |
174 MediaTestEnvNames.ADD_T_PARAMETER_ENV_NAME: ADD_T_PARAMETERS[j], | 182 # (refer to data/media/html/player.js) |
175 MediaTestEnvNames.PRINT_ONLY_TIME_ENV_NAME: PRINT_ONLY_TIME, | 183 MediaTestEnvNames.ADD_T_PARAMETER_ENV_NAME: ADD_T_PARAMETERS[j], |
176 MediaTestEnvNames.N_RUNS_ENV_NAME: str(options.number_of_runs), | 184 MediaTestEnvNames.PRINT_ONLY_TIME_ENV_NAME: PRINT_ONLY_TIME, |
177 MediaTestEnvNames.REMOVE_FIRST_RESULT_ENV_NAME: | 185 MediaTestEnvNames.N_RUNS_ENV_NAME: str(options.number_of_runs), |
178 REMOVE_FIRST_RESULT, | 186 MediaTestEnvNames.REMOVE_FIRST_RESULT_ENV_NAME: |
179 MediaTestEnvNames.MEASURE_INTERVAL_ENV_NAME: | 187 REMOVE_FIRST_RESULT, |
180 str(options.measure_intervals), | 188 MediaTestEnvNames.MEASURE_INTERVAL_ENV_NAME: |
181 MediaTestEnvNames.TEST_SCENARIO_FILE_ENV_NAME: | 189 str(options.measure_intervals), |
182 options.test_scenario_input_filename, | 190 MediaTestEnvNames.TEST_SCENARIO_FILE_ENV_NAME: |
183 MediaTestEnvNames.TEST_SCENARIO_ENV_NAME: | 191 options.test_scenario_input_filename, |
184 options.test_scenario, | 192 MediaTestEnvNames.TEST_SCENARIO_ENV_NAME: |
185 } | 193 options.test_scenario, |
186 envs.update(parent_envs) | 194 MediaTestEnvNames.REFERENCE_BUILD_ENV_NAME: |
187 if options.suite is None and options.test_prog_name is not None: | 195 str(reference_build), |
188 # Suite is not used - run test program directly. | 196 } |
189 test_prog_name = options.test_prog_name | 197 envs.update(parent_envs) |
190 suite_string = '' | 198 if options.suite is None and options.test_prog_name is not None: |
191 else: | 199 # Suite is not used - run test program directly. |
192 # Suite is used. | 200 test_prog_name = options.test_prog_name |
193 # The test script names are in the PYAUTO_TEST file. | 201 suite_string = '' |
194 test_prog_name = pyauto_functional_script_name | |
195 if options.suite is None: | |
196 suite_name = DEFAULT_SUITE_NAME | |
197 else: | 202 else: |
198 suite_name = options.suite | 203 # Suite is used. |
199 suite_string = ' --suite=%s' % suite_name | 204 # The test script names are in the PYAUTO_TEST file. |
200 test_prog_name = sys.executable + ' ' + test_prog_name | 205 test_prog_name = pyauto_functional_script_name |
201 cmd = test_prog_name + suite_string + ' ' + CHROME_FLAGS[j] | 206 if options.suite is None: |
202 proc = Popen(cmd, env=envs, shell=True) | 207 suite_name = DEFAULT_SUITE_NAME |
203 proc.communicate() | 208 else: |
209 suite_name = options.suite | |
210 suite_string = ' --suite=%s' % suite_name | |
211 test_prog_name = sys.executable + ' ' + test_prog_name | |
212 cmd = test_prog_name + suite_string + ' ' + CHROME_FLAGS[j] + ' -v' | |
213 proc = Popen(cmd, env=envs, shell=True) | |
214 proc.communicate() | |
204 if options.one_combination: | 215 if options.one_combination: |
205 sys.exit(0) | 216 sys.exit(0) |
206 | 217 |
207 | 218 |
208 if __name__ == '__main__': | 219 if __name__ == '__main__': |
209 main() | 220 main() |
OLD | NEW |