From a5e5920acaf18f80506fbdc0c3d4120076cccf74 Mon Sep 17 00:00:00 2001 From: Stephen Kyle Date: Wed, 7 Apr 2021 17:02:53 +0100 Subject: [PATCH] speedometer: ensure adb reverse works across reboots Before this patch, if you used reboot_policy: "each_job", the adb reverse connection would be lost. --- wa/workloads/speedometer/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/wa/workloads/speedometer/__init__.py b/wa/workloads/speedometer/__init__.py index 131954e8..0b696949 100755 --- a/wa/workloads/speedometer/__init__.py +++ b/wa/workloads/speedometer/__init__.py @@ -231,6 +231,8 @@ class Speedometer(Workload): def run(self, context): super(Speedometer, self).run(context) + self.archive_server.expose_to_device(self.target) + # Generate a UUID to search for in the browser's local storage to find out # when the workload has ended. report_end_id = uuid.uuid4().hex @@ -245,6 +247,8 @@ class Speedometer(Workload): self.wait_for_benchmark_to_complete(report_end_id) + self.archive_server.hide_from_device(self.target) + def target_file_was_created(self, f): """Assume that once self.target.file_exists(f) returns True, it will always be True from that point forward, so cache the response into the @@ -419,13 +423,15 @@ class ArchiveServer(object): self._thread = ArchiveServerThread(self._httpd) self._thread.start() - adb_command(target.adb_name, "reverse tcp:{0} tcp:{0}".format(self._port)) - def stop(self, target): - adb_command(target.adb_name, "reverse --remove tcp:{}".format(self._port)) - self._httpd.shutdown() self._thread.join() + def expose_to_device(self, target): + adb_command(target.adb_name, "reverse tcp:{0} tcp:{0}".format(self._port)) + + def hide_from_device(self, target): + adb_command(target.adb_name, "reverse --remove tcp:{}".format(self._port)) + def get_port(self): return self._port