OLD | NEW |
---|---|
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Run specific test on specific environment.""" | 5 """Run specific test on specific environment.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 import tempfile | 10 import tempfile |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 | 163 |
164 with appurify_sanitized.SanitizeLogging(self._env.verbose_count, | 164 with appurify_sanitized.SanitizeLogging(self._env.verbose_count, |
165 logging.WARNING): | 165 logging.WARNING): |
166 test_check_res = appurify_sanitized.api.tests_check_result( | 166 test_check_res = appurify_sanitized.api.tests_check_result( |
167 self._env.token, test_run_id) | 167 self._env.token, test_run_id) |
168 remote_device_helper.TestHttpResponse(test_check_res, | 168 remote_device_helper.TestHttpResponse(test_check_res, |
169 'Unable to get test status.') | 169 'Unable to get test status.') |
170 self._results = test_check_res.json()['response'] | 170 self._results = test_check_res.json()['response'] |
171 return self._results['status'] | 171 return self._results['status'] |
172 | 172 |
173 def _AmInstrumentTestSetup(self, app_path, test_path, runner_package): | 173 def _AmInstrumentTestSetup(self, app_path, test_path, runner_package, |
174 environment_variables): | |
174 config = {'runner': runner_package} | 175 config = {'runner': runner_package} |
176 if environment_variables: | |
177 config['environment_vars'] = ','.join( | |
178 '%s=%s' % (k, v) for k, v in environment_variables.iteritems()) | |
175 | 179 |
176 self._app_id = self._UploadAppToDevice(app_path) | 180 self._app_id = self._UploadAppToDevice(app_path) |
177 | 181 |
178 data_deps = self._test_instance.GetDataDependencies() | 182 data_deps = self._test_instance.GetDataDependencies() |
179 if data_deps: | 183 if data_deps: |
180 with tempfile.NamedTemporaryFile(suffix='.zip') as test_with_deps: | 184 with tempfile.NamedTemporaryFile(suffix='.zip') as test_with_deps: |
181 sdcard_files = [] | 185 sdcard_files = [] |
182 host_test = os.path.basename(test_path) | 186 host_test = os.path.basename(test_path) |
183 with zipfile.ZipFile(test_with_deps.name, 'w') as zip_file: | 187 with zipfile.ZipFile(test_with_deps.name, 'w') as zip_file: |
184 zip_file.write(test_path, host_test, zipfile.ZIP_DEFLATED) | 188 zip_file.write(test_path, host_test, zipfile.ZIP_DEFLATED) |
185 for h, _ in data_deps: | 189 for h, _ in data_deps: |
186 zip_utils.WriteToZipFile(zip_file, h, '.') | |
187 if os.path.isdir(h): | 190 if os.path.isdir(h): |
191 zip_utils.WriteToZipFile(zip_file, h, '.') | |
188 sdcard_files.extend(os.listdir(h)) | 192 sdcard_files.extend(os.listdir(h)) |
189 else: | 193 else: |
190 sdcard_files.extend(h) | 194 zip_utils.WriteToZipFile(zip_file, h, os.path.basename(h)) |
195 sdcard_files.append(os.path.basename(h)) | |
191 config['sdcard_files'] = ','.join(sdcard_files) | 196 config['sdcard_files'] = ','.join(sdcard_files) |
192 config['host_test'] = host_test | 197 config['host_test'] = host_test |
193 self._test_id = self._UploadTestToDevice( | 198 self._test_id = self._UploadTestToDevice( |
194 'robotium', test_with_deps.name) | 199 'robotium', test_with_deps.name) |
195 else: | 200 else: |
196 self._test_id = self._UploadTestToDevice('robotium', test_path) | 201 self._test_id = self._UploadTestToDevice('robotium', test_path) |
197 | 202 |
198 logging.info('Setting config: %s' % config) | 203 logging.info('Setting config: %s' % config) |
199 self._SetTestConfig('robotium', config) | 204 self._SetTestConfig('robotium', config) |
200 | 205 |
(...skipping 24 matching lines...) Expand all Loading... | |
225 'Unable to upload %s.' % test_path) | 230 'Unable to upload %s.' % test_path) |
226 return upload_results.json()['response']['test_id'] | 231 return upload_results.json()['response']['test_id'] |
227 | 232 |
228 def _SetTestConfig(self, runner_type, body): | 233 def _SetTestConfig(self, runner_type, body): |
229 """Generates and uploads config file for test. | 234 """Generates and uploads config file for test. |
230 Args: | 235 Args: |
231 extras: Extra arguments to set in the config file. | 236 extras: Extra arguments to set in the config file. |
232 """ | 237 """ |
233 logging.info('Generating config file for test.') | 238 logging.info('Generating config file for test.') |
234 with tempfile.TemporaryFile() as config: | 239 with tempfile.TemporaryFile() as config: |
235 config_data = ['[appurify]', '[%s]' % runner_type] | 240 config_data = [ |
241 '[appurify]', | |
242 'pcap=0', | |
243 'profiler=0', | |
244 'videocapture=0', | |
jbudorick
2015/01/13 19:17:56
We can revisit this when we support instrumentatio
| |
245 '[%s]' % runner_type | |
246 ] | |
236 config_data.extend('%s=%s' % (k, v) for k, v in body.iteritems()) | 247 config_data.extend('%s=%s' % (k, v) for k, v in body.iteritems()) |
237 config.write(''.join('%s\n' % l for l in config_data)) | 248 config.write(''.join('%s\n' % l for l in config_data)) |
238 config.flush() | 249 config.flush() |
239 config.seek(0) | 250 config.seek(0) |
240 with appurify_sanitized.SanitizeLogging(self._env.verbose_count, | 251 with appurify_sanitized.SanitizeLogging(self._env.verbose_count, |
241 logging.WARNING): | 252 logging.WARNING): |
242 config_response = appurify_sanitized.api.config_upload( | 253 config_response = appurify_sanitized.api.config_upload( |
243 self._env.token, config, self._test_id) | 254 self._env.token, config, self._test_id) |
244 remote_device_helper.TestHttpResponse( | 255 remote_device_helper.TestHttpResponse( |
245 config_response, 'Unable to upload test config.') | 256 config_response, 'Unable to upload test config.') |
OLD | NEW |