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

Unified Diff: tools/telemetry/telemetry/internal/platform/android_platform_backend.py

Issue 1491183003: [Telemetry] Move WPR life cycle from browser to platform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: work in progress Created 4 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 side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/internal/platform/android_platform_backend.py
diff --git a/tools/telemetry/telemetry/internal/platform/android_platform_backend.py b/tools/telemetry/telemetry/internal/platform/android_platform_backend.py
index 86264d887713967afa7e15fc42cf3fa98f23ecda..77547e63ccc5a40d24b5d7c8ccac8d763cb4b138 100644
--- a/tools/telemetry/telemetry/internal/platform/android_platform_backend.py
+++ b/tools/telemetry/telemetry/internal/platform/android_platform_backend.py
@@ -3,6 +3,7 @@
# found in the LICENSE file.
import logging
+import numbers
import os
import re
import shutil
@@ -501,7 +502,47 @@ class AndroidPlatformBackend(
return old_flag
def ForwardHostToDevice(self, host_port, device_port):
- self._device.adb.Forward('tcp:%d' % host_port, device_port)
+ """Forward host to device using adb.
+
+ Also prints lots of useful debug information in case of failure.
+
+ Args:
+ host_port, device_port: The host and device ports to pair. Each may be
+ given as an integer (assumed to be a tcp port), or a string with
+ a named socket.
+ """
+ if isinstance(host_port, numbers.Integral):
+ host_port = 'tcp:%d' % host_port
+ if isinstance(device_port, numbers.Integral):
+ device_port = 'tcp:%d' % device_port
+ try:
+ self._device.adb.Forward(host_port, device_port)
+ logging.info('Forwarding host %s to device %s.', host_port, device_port)
+ except Exception:
+ logging.exception('Failed to forward %s to %s.', host_port, device_port)
+ logging.warning('Currently forwarding:')
+ try:
+ for line in self._device.adb.ForwardList().splitlines():
+ logging.warning(' %s', line)
+ except Exception:
+ logging.warning('Exception raised while listing forwarded connections.')
+
+ logging.warning('Host tcp ports in use:')
+ try:
+ for line in subprocess.check_output(['netstat', '-t']).splitlines():
+ logging.warning(' %s', line)
+ except Exception:
+ logging.warning('Exception raised while listing tcp ports.')
+
+ logging.warning('Device unix domain sockets in use:')
+ try:
+ for line in self._device.ReadFile('/proc/net/unix', as_root=True,
+ force_pull=True).splitlines():
+ logging.warning(' %s', line)
+ except Exception:
+ logging.warning('Exception raised while listing unix domain sockets.')
+
+ raise # Re-raise the exception.
def StopForwardingHost(self, host_port):
for line in self._device.adb.ForwardList().strip().splitlines():

Powered by Google App Engine
This is Rietveld 408576698