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 os | 5 import os |
6 import urllib | 6 import urllib |
7 | 7 |
8 from slave import recipe_api | 8 from slave import recipe_api |
9 | 9 |
10 class AndroidApi(recipe_api.RecipeApi): | 10 class AndroidApi(recipe_api.RecipeApi): |
11 def __init__(self, **kwargs): | 11 def __init__(self, **kwargs): |
12 super(AndroidApi, self).__init__(**kwargs) | 12 super(AndroidApi, self).__init__(**kwargs) |
| 13 self._devices = None |
13 | 14 |
14 def get_config_defaults(self): | 15 def get_config_defaults(self): |
15 return { | 16 return { |
16 'REVISION': self.m.properties.get('revision', '') | 17 'REVISION': self.m.properties.get('revision', '') |
17 } | 18 } |
18 | 19 |
19 def get_env(self): | 20 def get_env(self): |
20 return self.m.chromium.get_env() | 21 return self.m.chromium.get_env() |
21 | 22 |
22 @property | 23 @property |
| 24 def devices(self): |
| 25 assert self._devices is not None,\ |
| 26 'devices is only available after device_status_check()' |
| 27 return self._devices |
| 28 |
| 29 @property |
23 def out_path(self): | 30 def out_path(self): |
24 return self.m.path['checkout'].join('out') | 31 return self.m.path['checkout'].join('out') |
25 | 32 |
26 @property | 33 @property |
27 def coverage_dir(self): | 34 def coverage_dir(self): |
28 return self.out_path.join(self.c.BUILD_CONFIG, 'coverage') | 35 return self.out_path.join(self.c.BUILD_CONFIG, 'coverage') |
29 | 36 |
30 def configure_from_properties(self, config_name, **kwargs): | 37 def configure_from_properties(self, config_name, **kwargs): |
31 self.set_config(config_name, **kwargs) | 38 self.set_config(config_name, **kwargs) |
32 | 39 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 env=self.m.chromium.get_env(), | 244 env=self.m.chromium.get_env(), |
238 infra_step=True) | 245 infra_step=True) |
239 | 246 |
240 def detect_and_setup_devices(self, restart_usb=False, skip_wipe=False, | 247 def detect_and_setup_devices(self, restart_usb=False, skip_wipe=False, |
241 disable_location=False): | 248 disable_location=False): |
242 self.device_status_check(restart_usb=restart_usb) | 249 self.device_status_check(restart_usb=restart_usb) |
243 self.provision_devices( | 250 self.provision_devices( |
244 skip_wipe=skip_wipe, disable_location=disable_location) | 251 skip_wipe=skip_wipe, disable_location=disable_location) |
245 | 252 |
246 def device_status_check(self, restart_usb=False, **kwargs): | 253 def device_status_check(self, restart_usb=False, **kwargs): |
247 args = [] | 254 args = ['--json-output', self.m.json.output()] |
248 if restart_usb: | 255 if restart_usb: |
249 args = ['--restart-usb'] | 256 args += ['--restart-usb'] |
250 | 257 |
251 try: | 258 try: |
252 self.m.step( | 259 result = self.m.step( |
253 'device_status_check', | 260 'device_status_check', |
254 [self.m.path['checkout'].join('build', 'android', 'buildbot', | 261 [self.m.path['checkout'].join('build', 'android', 'buildbot', |
255 'bb_device_status_check.py')] + args, | 262 'bb_device_status_check.py')] + args, |
| 263 step_test_data=lambda: self.m.json.test_api.output([{ |
| 264 "battery": { |
| 265 "status": "5", |
| 266 "scale": "100", |
| 267 "temperature": "249", |
| 268 "level": "100", |
| 269 "AC powered": "false", |
| 270 "health": "2", |
| 271 "voltage": "4286", |
| 272 "Wireless powered": "false", |
| 273 "USB powered": "true", |
| 274 "technology": "Li-ion", |
| 275 "present": "true" |
| 276 }, |
| 277 "wifi_ip": "", |
| 278 "imei_slice": "Unknown", |
| 279 "build": "LRX21O", |
| 280 "build_detail": |
| 281 "google/razor/flo:5.0/LRX21O/1570415:userdebug/dev-keys", |
| 282 "serial": "07a00ca4", |
| 283 "type": "flo" |
| 284 }]), |
256 env=self.m.chromium.get_env(), | 285 env=self.m.chromium.get_env(), |
257 infra_step=True, | 286 infra_step=True, |
258 **kwargs) | 287 **kwargs) |
| 288 self._devices = [d['serial'] for d in result.json.output] |
259 except self.m.step.InfraFailure as f: | 289 except self.m.step.InfraFailure as f: |
260 params = { | 290 params = { |
261 'summary': ('Device Offline on %s %s' % | 291 'summary': ('Device Offline on %s %s' % |
262 (self.m.properties['mastername'], self.m.properties['slavename'])), | 292 (self.m.properties['mastername'], self.m.properties['slavename'])), |
263 'comment': ('Buildbot: %s\n(Please do not change any labels)' % | 293 'comment': ('Buildbot: %s\n(Please do not change any labels)' % |
264 self.m.properties['buildername']), | 294 self.m.properties['buildername']), |
265 'labels': 'Restrict-View-Google,OS-Android,Infra,Infra-Labs', | 295 'labels': 'Restrict-View-Google,OS-Android,Infra,Infra-Labs', |
266 } | 296 } |
267 link = ('https://code.google.com/p/chromium/issues/entry?%s' % | 297 link = ('https://code.google.com/p/chromium/issues/entry?%s' % |
268 urllib.urlencode(params)) | 298 urllib.urlencode(params)) |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 **kwargs) | 627 **kwargs) |
598 | 628 |
599 self.m.gsutil.upload( | 629 self.m.gsutil.upload( |
600 source=self.coverage_dir.join('coverage_html'), | 630 source=self.coverage_dir.join('coverage_html'), |
601 bucket='chrome-code-coverage', | 631 bucket='chrome-code-coverage', |
602 dest=gs_dest, | 632 dest=gs_dest, |
603 args=['-R'], | 633 args=['-R'], |
604 name='upload coverage report', | 634 name='upload coverage report', |
605 link_name='Coverage report', | 635 link_name='Coverage report', |
606 **kwargs) | 636 **kwargs) |
OLD | NEW |