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 urllib | 10 import urllib |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 | 25 |
| 26 def get_config_defaults(self): | 26 def get_config_defaults(self): |
| 27 return { | 27 return { |
| 28 'REVISION': self.m.properties.get('revision', ''), | 28 'REVISION': self.m.properties.get('revision', ''), |
| 29 'CHECKOUT_PATH': self.m.path['checkout'], | 29 'CHECKOUT_PATH': self.m.path['checkout'], |
| 30 } | 30 } |
| 31 | 31 |
| 32 @property | 32 @property |
| 33 def devices(self): | 33 def devices(self): |
| 34 assert self._devices is not None,\ | 34 assert self._devices is not None,\ |
| 35 'devices is only available after device_status_check()' | 35 'devices is only available after device_status()' |
| 36 return self._devices | 36 return self._devices |
| 37 | 37 |
| 38 @property | 38 @property |
| 39 def out_path(self): | 39 def out_path(self): |
| 40 return self.m.path['checkout'].join('out') | 40 return self.m.path['checkout'].join('out') |
| 41 | 41 |
| 42 @property | 42 @property |
| 43 def coverage_dir(self): | 43 def coverage_dir(self): |
| 44 return self.out_path.join(self.c.BUILD_CONFIG, 'coverage') | 44 return self.out_path.join(self.c.BUILD_CONFIG, 'coverage') |
| 45 | 45 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 args = ['--verbose', '--adb-path', self.m.adb.adb_path()] | 317 args = ['--verbose', '--adb-path', self.m.adb.adb_path()] |
| 318 return self.m.python('authorize_adb_devices', script, args, infra_step=True, | 318 return self.m.python('authorize_adb_devices', script, args, infra_step=True, |
| 319 env=self.m.chromium.get_env()) | 319 env=self.m.chromium.get_env()) |
| 320 | 320 |
| 321 def detect_and_setup_devices(self, restart_usb=False, skip_wipe=False, | 321 def detect_and_setup_devices(self, restart_usb=False, skip_wipe=False, |
| 322 disable_location=False, min_battery_level=None, | 322 disable_location=False, min_battery_level=None, |
| 323 disable_network=False, disable_java_debug=False, | 323 disable_network=False, disable_java_debug=False, |
| 324 reboot_timeout=None, max_battery_temp=None, | 324 reboot_timeout=None, max_battery_temp=None, |
| 325 remove_system_webview=False): | 325 remove_system_webview=False): |
| 326 self.authorize_adb_devices() | 326 self.authorize_adb_devices() |
| 327 self.device_status_check(restart_usb=restart_usb) | 327 self.device_recovery() |
| 328 self.provision_devices( | 328 self.provision_devices( |
| 329 skip_wipe=skip_wipe, disable_location=disable_location, | 329 skip_wipe=skip_wipe, disable_location=disable_location, |
| 330 min_battery_level=min_battery_level, disable_network=disable_network, | 330 min_battery_level=min_battery_level, disable_network=disable_network, |
| 331 disable_java_debug=disable_java_debug, reboot_timeout=reboot_timeout, | 331 disable_java_debug=disable_java_debug, reboot_timeout=reboot_timeout, |
| 332 max_battery_temp=max_battery_temp, | 332 max_battery_temp=max_battery_temp, |
| 333 remove_system_webview=remove_system_webview) | 333 remove_system_webview=remove_system_webview) |
| 334 self.device_status() | |
| 334 | 335 |
| 335 @property | 336 @property |
| 336 def blacklist_file(self): | 337 def blacklist_file(self): |
| 337 return self.out_path.join('bad_devices.json') | 338 return self.out_path.join('bad_devices.json') |
| 338 | 339 |
| 339 def device_status_check(self, restart_usb=False, **kwargs): | 340 # TODO(rnephew): Get rid of this when everything calls device_recovery and |
| 340 # TODO(phajdan.jr): Remove path['build'] usage, http://crbug.com/437264 . | 341 # device_status directly. |
|
jbudorick
2016/06/15 14:05:38
I think this TODO should be maintained for now.
| |
| 341 devices_path = self.m.path['build'].join('site_config', '.known_devices') | 342 def device_status_check(self): |
|
jbudorick
2016/06/15 14:05:38
What's still calling this? Downstream?
rnephew (Reviews Here)
2016/06/15 14:32:45
Im more putting it in there as a just in case I mi
jbudorick
2016/06/15 14:48:50
I don't know of a good way to do this short of add
| |
| 343 self.device_recovery() | |
| 344 self.device_status() | |
| 345 | |
| 346 def device_recovery(self, restart_usb=False, **kwargs): | |
| 347 known_devices_path = self.m.path['build'].join('site_config', | |
|
jbudorick
2016/06/15 14:05:38
This should probably be in its own private functio
rnephew (Reviews Here)
2016/06/15 16:05:13
Done.
| |
| 348 '.known_devices') | |
| 342 args = [ | 349 args = [ |
| 343 '--adb-path', self.m.adb.adb_path(), | |
| 344 '--blacklist-file', self.blacklist_file, | 350 '--blacklist-file', self.blacklist_file, |
| 351 '--known-devices-file', known_devices_path, | |
| 352 '-v' | |
| 353 ] | |
| 354 self.m.step( | |
| 355 'device_recovery', | |
| 356 [self.m.path['checkout'].join('third_party', 'catapult', 'devil', | |
| 357 'devil', 'android', 'tools', | |
| 358 'device_recovery.py')] + args, | |
| 359 env=self.m.chromium.get_env(), | |
| 360 infra_step=True, | |
| 361 **kwargs) | |
| 362 | |
| 363 def device_status(self, **kwargs): | |
| 364 known_devices_path = self.m.path['build'].join('site_config', | |
| 365 '.known_devices') | |
| 366 buildbot_file = '/home/chrome-bot/.adb_device_info' | |
| 367 args = [ | |
| 345 '--json-output', self.m.json.output(), | 368 '--json-output', self.m.json.output(), |
| 346 '--known-devices-file', devices_path, | 369 '--blacklist-file', self.blacklist_file, |
| 370 '--known-devices-file', known_devices_path, | |
| 371 '--buildbot-path', buildbot_file, | |
| 372 '-v', '--overwrite-known-devices-files', | |
| 347 ] | 373 ] |
| 348 if restart_usb: | |
| 349 args += ['--restart-usb'] | |
| 350 | |
| 351 try: | 374 try: |
| 352 result = self.m.step( | 375 result = self.m.step( |
| 353 'device_status_check', | 376 'device_status', |
| 354 [self.m.path['checkout'].join('build', 'android', 'buildbot', | 377 [self.m.path['checkout'].join('third_party', 'catapult', 'devil', |
| 355 'bb_device_status_check.py')] + args, | 378 'devil', 'android', 'tools', |
| 379 'device_status.py')] + args, | |
| 356 step_test_data=lambda: self.m.json.test_api.output([ | 380 step_test_data=lambda: self.m.json.test_api.output([ |
| 357 { | 381 { |
| 358 "battery": { | 382 "battery": { |
| 359 "status": "5", | 383 "status": "5", |
| 360 "scale": "100", | 384 "scale": "100", |
| 361 "temperature": "249", | 385 "temperature": "249", |
| 362 "level": "100", | 386 "level": "100", |
| 363 "AC powered": "false", | 387 "AC powered": "false", |
| 364 "health": "2", | 388 "health": "2", |
| 365 "voltage": "4286", | 389 "voltage": "4286", |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 403 **kwargs) | 427 **kwargs) |
| 404 self._devices = [] | 428 self._devices = [] |
| 405 offline_device_index = 1 | 429 offline_device_index = 1 |
| 406 for d in result.json.output: | 430 for d in result.json.output: |
| 407 try: | 431 try: |
| 408 if not d['usb_status']: | 432 if not d['usb_status']: |
| 409 key = '%s: missing' % d['serial'] | 433 key = '%s: missing' % d['serial'] |
| 410 elif d['adb_status'] != 'device': | 434 elif d['adb_status'] != 'device': |
| 411 key = '%s: adb status %s' % (d['serial'], d['adb_status']) | 435 key = '%s: adb status %s' % (d['serial'], d['adb_status']) |
| 412 elif d['blacklisted']: | 436 elif d['blacklisted']: |
| 413 key = '%s: blacklisted' % d['serial'] | 437 key = '%s: blacklisted' % d['serial'] |
|
rnephew (Reviews Here)
2016/06/15 16:05:13
Isn't it already done here (displaying blacklisted
| |
| 414 else: | 438 else: |
| 415 key = '%s %s %s' % (d['type'], d['build'], d['serial']) | 439 key = '%s %s %s' % (d['type'], d['build'], d['serial']) |
| 416 self._devices.append(d['serial']) | 440 self._devices.append(d['serial']) |
| 417 except KeyError: | 441 except KeyError: |
| 418 key = 'unknown device %d' % offline_device_index | 442 key = 'unknown device %d' % offline_device_index |
| 419 offline_device_index += 1 | 443 offline_device_index += 1 |
| 420 result.presentation.logs[key] = self.m.json.dumps( | 444 result.presentation.logs[key] = self.m.json.dumps( |
| 421 d, indent=2).splitlines() | 445 d, indent=2).splitlines() |
| 422 result.presentation.step_text = 'Online devices: %s' % len(self._devices) | 446 result.presentation.step_text = 'Online devices: %s' % len(self._devices) |
| 423 return result | 447 return result |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 if emulators: | 503 if emulators: |
| 480 args.append('--emulators') | 504 args.append('--emulators') |
| 481 result = self.m.python( | 505 result = self.m.python( |
| 482 'provision_devices', | 506 'provision_devices', |
| 483 self.m.path['checkout'].join( | 507 self.m.path['checkout'].join( |
| 484 'build', 'android', 'provision_devices.py'), | 508 'build', 'android', 'provision_devices.py'), |
| 485 args=args, | 509 args=args, |
| 486 env=self.m.chromium.get_env(), | 510 env=self.m.chromium.get_env(), |
| 487 infra_step=True, | 511 infra_step=True, |
| 488 **kwargs) | 512 **kwargs) |
| 489 blacklisted_devices = result.json.output | 513 blacklisted_devices = result.json.output |
|
jbudorick
2016/06/15 14:05:38
I think the blacklist display stuff should move up
rnephew (Reviews Here)
2016/06/15 16:05:13
See above comment on line 437.
| |
| 490 if blacklisted_devices: | 514 if blacklisted_devices: |
| 491 result.presentation.status = self.m.step.WARNING | 515 result.presentation.status = self.m.step.WARNING |
| 492 for d in blacklisted_devices: | 516 for d in blacklisted_devices: |
| 493 key = 'blacklisted %s' % d | 517 key = 'blacklisted %s' % d |
| 494 result.presentation.logs[key] = [d] | 518 result.presentation.logs[key] = [d] |
| 495 | 519 |
| 496 def apk_path(self, apk): | 520 def apk_path(self, apk): |
| 497 return self.m.chromium.output_dir.join('apks', apk) if apk else None | 521 return self.m.chromium.output_dir.join('apks', apk) if apk else None |
| 498 | 522 |
| 499 def adb_install_apk(self, apk, allow_downgrade=False, devices=None): | 523 def adb_install_apk(self, apk, allow_downgrade=False, devices=None): |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 868 self.create_adb_symlink() | 892 self.create_adb_symlink() |
| 869 if self.c.gce_setup: | 893 if self.c.gce_setup: |
| 870 self.launch_gce_instances(snapshot=self.c.gce_snapshot, | 894 self.launch_gce_instances(snapshot=self.c.gce_snapshot, |
| 871 count=self.c.gce_count) | 895 count=self.c.gce_count) |
| 872 self.spawn_logcat_monitor() | 896 self.spawn_logcat_monitor() |
| 873 self.provision_devices(emulators=True, | 897 self.provision_devices(emulators=True, |
| 874 remove_system_webview=remove_system_webview) | 898 remove_system_webview=remove_system_webview) |
| 875 else: | 899 else: |
| 876 self.spawn_logcat_monitor() | 900 self.spawn_logcat_monitor() |
| 877 self.authorize_adb_devices() | 901 self.authorize_adb_devices() |
| 878 self.device_status_check() | 902 self.device_recovery() |
| 879 if perf_setup: | 903 if perf_setup: |
| 880 kwargs = { | 904 kwargs = { |
| 881 'min_battery_level': 95, | 905 'min_battery_level': 95, |
| 882 'disable_network': True, | 906 'disable_network': True, |
| 883 'disable_java_debug': True, | 907 'disable_java_debug': True, |
| 884 'max_battery_temp': 350} | 908 'max_battery_temp': 350} |
| 885 else: | 909 else: |
| 886 kwargs = {} | 910 kwargs = {} |
| 887 self.provision_devices(remove_system_webview=remove_system_webview, | 911 self.provision_devices(remove_system_webview=remove_system_webview, |
| 888 **kwargs) | 912 **kwargs) |
| 913 self.device_status() | |
| 889 if self.m.chromium.c.gyp_env.GYP_DEFINES.get('asan', 0) == 1: | 914 if self.m.chromium.c.gyp_env.GYP_DEFINES.get('asan', 0) == 1: |
| 890 self.asan_device_setup() | 915 self.asan_device_setup() |
| 891 | 916 |
| 892 self.spawn_device_monitor() | 917 self.spawn_device_monitor() |
| 893 | 918 |
| 894 def common_tests_final_steps(self, logcat_gs_bucket='chromium-android'): | 919 def common_tests_final_steps(self, logcat_gs_bucket='chromium-android'): |
| 895 if not self.c.gce_setup: | 920 if not self.c.gce_setup: |
| 896 self.shutdown_device_monitor() | 921 self.shutdown_device_monitor() |
| 897 self.logcat_dump(gs_bucket=logcat_gs_bucket) | 922 self.logcat_dump(gs_bucket=logcat_gs_bucket) |
| 898 self.stack_tool_steps() | 923 self.stack_tool_steps() |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1301 script = self.c.test_runner | 1326 script = self.c.test_runner |
| 1302 if wrapper_script_suite_name: | 1327 if wrapper_script_suite_name: |
| 1303 script = self.m.chromium.output_dir.join('bin', 'run_%s' % | 1328 script = self.m.chromium.output_dir.join('bin', 'run_%s' % |
| 1304 wrapper_script_suite_name) | 1329 wrapper_script_suite_name) |
| 1305 else: | 1330 else: |
| 1306 env = kwargs.get('env', {}) | 1331 env = kwargs.get('env', {}) |
| 1307 env['CHROMIUM_OUTPUT_DIR'] = env.get('CHROMIUM_OUTPUT_DIR', | 1332 env['CHROMIUM_OUTPUT_DIR'] = env.get('CHROMIUM_OUTPUT_DIR', |
| 1308 self.m.chromium.output_dir) | 1333 self.m.chromium.output_dir) |
| 1309 kwargs['env'] = env | 1334 kwargs['env'] = env |
| 1310 return self.m.python(step_name, script, args, **kwargs) | 1335 return self.m.python(step_name, script, args, **kwargs) |
| OLD | NEW |