Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 import contextlib | 5 import contextlib |
| 6 import datetime | 6 import datetime |
| 7 import json | 7 import json |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import sys | 10 import sys |
| 11 import urllib | 11 import urllib |
| 12 | 12 |
| 13 from recipe_engine.types import freeze | 13 from recipe_engine.types import freeze |
| 14 from recipe_engine import recipe_api | 14 from recipe_engine import recipe_api |
| 15 | 15 |
| 16 def _TimestampToIsoFormat(timestamp): | 16 def _TimestampToIsoFormat(timestamp): |
| 17 return datetime.datetime.utcfromtimestamp(timestamp).strftime('%Y%m%dT%H%M%S') | 17 return datetime.datetime.utcfromtimestamp(timestamp).strftime('%Y%m%dT%H%M%S') |
| 18 | 18 |
| 19 | 19 |
| 20 class AndroidApi(recipe_api.RecipeApi): | 20 class AndroidApi(recipe_api.RecipeApi): |
| 21 def __init__(self, **kwargs): | 21 def __init__(self, **kwargs): |
| 22 super(AndroidApi, self).__init__(**kwargs) | 22 super(AndroidApi, self).__init__(**kwargs) |
| 23 self._devices = None | 23 self._devices = None |
| 24 self._file_changes_path = None | 24 self._file_changes_path = None |
| 25 self._multiple_device_test = False | |
|
jbudorick
2016/07/15 01:23:19
O_O
| |
| 25 | 26 |
| 26 def get_config_defaults(self): | 27 def get_config_defaults(self): |
| 27 return { | 28 return { |
| 28 'REVISION': self.m.properties.get('revision', ''), | 29 'REVISION': self.m.properties.get('revision', ''), |
| 29 'CHECKOUT_PATH': self.m.path['checkout'], | 30 'CHECKOUT_PATH': self.m.path['checkout'], |
| 30 } | 31 } |
| 31 | 32 |
| 32 @property | 33 @property |
| 34 def multiple_device_test(self): | |
| 35 return self._multiple_device_test | |
| 36 | |
| 37 @multiple_device_test.setter | |
| 38 def multiple_device_test(self, value): | |
| 39 self._multiple_device_test = value | |
| 40 | |
| 41 @property | |
| 33 def devices(self): | 42 def devices(self): |
| 34 assert self._devices is not None,\ | 43 assert self._devices is not None,\ |
| 35 'devices is only available after device_status()' | 44 'devices is only available after device_status()' |
| 36 return self._devices | 45 return self._devices |
| 37 | 46 |
| 38 @property | 47 @property |
| 39 def out_path(self): | 48 def out_path(self): |
| 40 return self.m.path['checkout'].join('out') | 49 return self.m.path['checkout'].join('out') |
| 41 | 50 |
| 42 @property | 51 @property |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 ] | 388 ] |
| 380 self.m.step( | 389 self.m.step( |
| 381 'device_recovery', | 390 'device_recovery', |
| 382 [self.m.path['checkout'].join('third_party', 'catapult', 'devil', | 391 [self.m.path['checkout'].join('third_party', 'catapult', 'devil', |
| 383 'devil', 'android', 'tools', | 392 'devil', 'android', 'tools', |
| 384 'device_recovery.py')] + args, | 393 'device_recovery.py')] + args, |
| 385 env=self.m.chromium.get_env(), | 394 env=self.m.chromium.get_env(), |
| 386 infra_step=True, | 395 infra_step=True, |
| 387 **kwargs) | 396 **kwargs) |
| 388 | 397 |
| 389 def device_status(self, **kwargs): | 398 def device_status(self, **kwargs): |
|
jbudorick
2016/07/15 01:23:19
nit: no extra space
| |
| 390 buildbot_file = '/home/chrome-bot/.adb_device_info' | 399 buildbot_file = '/home/chrome-bot/.adb_device_info' |
| 391 args = [ | 400 args = [ |
| 392 '--json-output', self.m.json.output(), | 401 '--json-output', self.m.json.output(), |
| 393 '--blacklist-file', self.blacklist_file, | 402 '--blacklist-file', self.blacklist_file, |
| 394 '--known-devices-file', self.known_devices_file, | 403 '--known-devices-file', self.known_devices_file, |
| 395 '--buildbot-path', buildbot_file, | 404 '--buildbot-path', buildbot_file, |
| 396 '--adb-path', self.m.adb.adb_path(), | 405 '--adb-path', self.m.adb.adb_path(), |
| 397 '-v', '--overwrite-known-devices-files', | 406 '-v', '--overwrite-known-devices-files', |
| 398 ] | 407 ] |
| 399 try: | 408 try: |
| 409 device_step_name = 'device_status' | |
|
jbudorick
2016/07/15 01:23:18
Why are you optionally changing the step name?
Ziqi Xiong
2016/07/15 01:36:06
I thought it was easier to feed step data and made
| |
| 410 if self.multiple_device_test: | |
| 411 device_step_name = 'multiple_device_status' | |
| 400 result = self.m.step( | 412 result = self.m.step( |
| 401 'device_status', | 413 device_step_name, |
| 402 [self.m.path['checkout'].join('third_party', 'catapult', 'devil', | 414 [self.m.path['checkout'].join('third_party', 'catapult', 'devil', |
| 403 'devil', 'android', 'tools', | 415 'devil', 'android', 'tools', |
| 404 'device_status.py')] + args, | 416 'device_status.py')] + args, |
| 405 step_test_data=lambda: self.m.json.test_api.output([ | 417 step_test_data=lambda: self.m.json.test_api.output([ |
| 406 { | 418 { |
| 407 "battery": { | 419 "battery": { |
| 408 "status": "5", | 420 "status": "5", |
| 409 "scale": "100", | 421 "scale": "100", |
| 410 "temperature": "249", | 422 "temperature": "249", |
| 411 "level": "100", | 423 "level": "100", |
| (...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1377 script = self.c.test_runner | 1389 script = self.c.test_runner |
| 1378 if wrapper_script_suite_name: | 1390 if wrapper_script_suite_name: |
| 1379 script = self.m.chromium.output_dir.join('bin', 'run_%s' % | 1391 script = self.m.chromium.output_dir.join('bin', 'run_%s' % |
| 1380 wrapper_script_suite_name) | 1392 wrapper_script_suite_name) |
| 1381 else: | 1393 else: |
| 1382 env = kwargs.get('env', {}) | 1394 env = kwargs.get('env', {}) |
| 1383 env['CHROMIUM_OUTPUT_DIR'] = env.get('CHROMIUM_OUTPUT_DIR', | 1395 env['CHROMIUM_OUTPUT_DIR'] = env.get('CHROMIUM_OUTPUT_DIR', |
| 1384 self.m.chromium.output_dir) | 1396 self.m.chromium.output_dir) |
| 1385 kwargs['env'] = env | 1397 kwargs['env'] = env |
| 1386 return self.m.python(step_name, script, args, **kwargs) | 1398 return self.m.python(step_name, script, args, **kwargs) |
| OLD | NEW |