Bug 1498680 - Fix wpt runner's browser stop implementation: request stop before waiting; r=kwierso
authorWes Kocher <wkocher@mozilla.com>
Fri, 12 Oct 2018 23:55:47 -0700
changeset 489367 54598c1940f1b4cf12c1e122431ce709237c686f
parent 489366 2cc5b3f51ec4fa0501af01e4ece67be0eed814c4
child 489368 b4d64ab443eaf93f046597999253c76e7461953d
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
Bug 1498680 - Fix wpt runner's browser stop implementation: request stop before waiting; r=kwierso The current implementation waits for fennec to stop before trying to stop it - easy enough to address. At the same time, I am updating the runner stop implementation to try stop_application before kill: stop_application shuts down the application more cleanly; kill should only be used as a backup.
--- a/testing/mozbase/mozrunner/mozrunner/base/device.py
+++ b/testing/mozbase/mozrunner/mozrunner/base/device.py
@@ -87,16 +87,19 @@ class DeviceRunner(BaseRunner):
         if not self.is_running():
             print("timed out waiting for '%s' process to start" % self.app_ctx.remote_process)
         if not self.device.wait_for_net():
             raise Exception("Failed to get a network connection")
         return pid
     def stop(self, sig=None):
+        if not sig and self.is_running():
+            self.app_ctx.stop_application()
         if self.is_running():
             timeout = 10
             self.app_ctx.device.pkill(self.app_ctx.remote_process, sig=sig)
             if self.wait(timeout) is None and sig is not None:
                 print("timed out waiting for '%s' process to exit, trying "
                       "without signal {}".format(
                           self.app_ctx.remote_process, sig))
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/fennec.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/fennec.py
@@ -231,16 +231,17 @@ class FennecBrowser(FirefoxBrowser):
                 if self.runner.device.connected:
             except Exception:
             # We assume that stopping the runner prompts the
             # browser to shut down. This allows the leak log to be written
+            self.runner.stop()
             for clean, stop_f in [(True, lambda: self.runner.wait(self.shutdown_timeout)),
                                   (False, lambda: self.runner.stop(signal.SIGTERM)),
                                   (False, lambda: self.runner.stop(signal.SIGKILL))]:
                 if not force or not clean:
                     retcode = stop_f()
                     if retcode is not None:
                         self.logger.info("Browser exited with return code %s" % retcode)