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

Side by Side Diff: build/android/pylib/remote/device/remote_device_test_run.py

Issue 832493005: Add Instrumentation test support to remote device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
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 json 7 import json
8 import logging 8 import logging
9 import os 9 import os
10 import sys 10 import sys
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 for h, _ in data_deps: 212 for h, _ in data_deps:
213 if os.path.isdir(h): 213 if os.path.isdir(h):
214 zip_utils.WriteToZipFile(zip_file, h, '.') 214 zip_utils.WriteToZipFile(zip_file, h, '.')
215 sdcard_files.extend(os.listdir(h)) 215 sdcard_files.extend(os.listdir(h))
216 else: 216 else:
217 zip_utils.WriteToZipFile(zip_file, h, os.path.basename(h)) 217 zip_utils.WriteToZipFile(zip_file, h, os.path.basename(h))
218 sdcard_files.append(os.path.basename(h)) 218 sdcard_files.append(os.path.basename(h))
219 config['sdcard_files'] = ','.join(sdcard_files) 219 config['sdcard_files'] = ','.join(sdcard_files)
220 config['host_test'] = host_test 220 config['host_test'] = host_test
221 self._test_id = self._UploadTestToDevice( 221 self._test_id = self._UploadTestToDevice(
222 'robotium', test_with_deps.name) 222 'robotium', test_with_deps.name, app_id=self._app_id)
223 else: 223 else:
224 self._test_id = self._UploadTestToDevice('robotium', test_path) 224 self._test_id = self._UploadTestToDevice('robotium', test_path)
225 225
226 logging.info('Setting config: %s' % config) 226 logging.info('Setting config: %s' % config)
227 self._SetTestConfig('robotium', config) 227 self._SetTestConfig('robotium', config)
228 228
229 def _UploadAppToDevice(self, app_path): 229 def _UploadAppToDevice(self, app_path):
230 """Upload app to device.""" 230 """Upload app to device."""
231 logging.info('Uploading %s to remote service.', app_path) 231 logging.info('Uploading %s to remote service.', app_path)
232 with open(app_path, 'rb') as apk_src: 232 with open(app_path, 'rb') as apk_src:
233 with appurify_sanitized.SanitizeLogging(self._env.verbose_count, 233 with appurify_sanitized.SanitizeLogging(self._env.verbose_count,
234 logging.WARNING): 234 logging.WARNING):
235 upload_results = appurify_sanitized.api.apps_upload( 235 upload_results = appurify_sanitized.api.apps_upload(
236 self._env.token, apk_src, 'raw', name=self._test_instance.suite) 236 self._env.token, apk_src, 'raw', name=self._test_instance.suite)
237 remote_device_helper.TestHttpResponse( 237 remote_device_helper.TestHttpResponse(
238 upload_results, 'Unable to upload %s.' % app_path) 238 upload_results, 'Unable to upload %s.' % app_path)
239 return upload_results.json()['response']['app_id'] 239 return upload_results.json()['response']['app_id']
240 240
241 def _UploadTestToDevice(self, test_type, test_path): 241 def _UploadTestToDevice(self, test_type, test_path, app_id=None):
242 """Upload test to device 242 """Upload test to device
243 Args: 243 Args:
244 test_type: Type of test that is being uploaded. Ex. uirobot, gtest.. 244 test_type: Type of test that is being uploaded. Ex. uirobot, gtest..
245 """ 245 """
246 logging.info('Uploading %s to remote service.' % test_path) 246 logging.info('Uploading %s to remote service.' % test_path)
247 with open(test_path, 'rb') as test_src: 247 with open(test_path, 'rb') as test_src:
248 with appurify_sanitized.SanitizeLogging(self._env.verbose_count, 248 with appurify_sanitized.SanitizeLogging(self._env.verbose_count,
249 logging.WARNING): 249 logging.WARNING):
250 upload_results = appurify_sanitized.api.tests_upload( 250 upload_results = appurify_sanitized.api.tests_upload(
251 self._env.token, test_src, 'raw', test_type) 251 self._env.token, test_src, 'raw', test_type, app_id=app_id)
252 remote_device_helper.TestHttpResponse(upload_results, 252 remote_device_helper.TestHttpResponse(upload_results,
253 'Unable to upload %s.' % test_path) 253 'Unable to upload %s.' % test_path)
254 return upload_results.json()['response']['test_id'] 254 return upload_results.json()['response']['test_id']
255 255
256 def _SetTestConfig(self, runner_type, body): 256 def _SetTestConfig(self, runner_type, body):
257 """Generates and uploads config file for test. 257 """Generates and uploads config file for test.
258 Args: 258 Args:
259 extras: Extra arguments to set in the config file. 259 extras: Extra arguments to set in the config file.
260 """ 260 """
261 logging.info('Generating config file for test.') 261 logging.info('Generating config file for test.')
262 with tempfile.TemporaryFile() as config: 262 with tempfile.TemporaryFile() as config:
263 config_data = [ 263 config_data = [
264 '[appurify]', 264 '[appurify]',
265 'pcap=0', 265 'pcap=0',
266 'profiler=0', 266 'profiler=0',
267 'videocapture=0', 267 'videocapture=0',
268 '[%s]' % runner_type 268 '[%s]' % runner_type
269 ] 269 ]
270 config_data.extend('%s=%s' % (k, v) for k, v in body.iteritems()) 270 config_data.extend('%s=%s' % (k, v) for k, v in body.iteritems())
271 config.write(''.join('%s\n' % l for l in config_data)) 271 config.write(''.join('%s\n' % l for l in config_data))
272 config.flush() 272 config.flush()
273 config.seek(0) 273 config.seek(0)
274 with appurify_sanitized.SanitizeLogging(self._env.verbose_count, 274 with appurify_sanitized.SanitizeLogging(self._env.verbose_count,
275 logging.WARNING): 275 logging.WARNING):
276 config_response = appurify_sanitized.api.config_upload( 276 config_response = appurify_sanitized.api.config_upload(
277 self._env.token, config, self._test_id) 277 self._env.token, config, self._test_id)
278 remote_device_helper.TestHttpResponse( 278 remote_device_helper.TestHttpResponse(
279 config_response, 'Unable to upload test config.') 279 config_response, 'Unable to upload test config.')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698