Browse Source

Remove mozrunner devices changes

Ian Neal 3 months ago
parent
commit
e7e80b3d73

+ 0 - 158
mozilla-release/patches/1428714-67a1.patch

@@ -78,164 +78,6 @@ diff --git a/testing/mozbase/mozrunner/mozrunner/base/runner.py b/testing/mozbas
  
          self.logger = get_default_logger()
  
-diff --git a/testing/mozbase/mozrunner/mozrunner/devices/android_device.py b/testing/mozbase/mozrunner/mozrunner/devices/android_device.py
---- a/testing/mozbase/mozrunner/mozrunner/devices/android_device.py
-+++ b/testing/mozbase/mozrunner/mozrunner/devices/android_device.py
-@@ -3,28 +3,28 @@
- # file, You can obtain one at http://mozilla.org/MPL/2.0/.
- 
- from __future__ import absolute_import, print_function
- 
- import fileinput
- import glob
- import os
- import platform
--import psutil
- import shutil
- import signal
- import sys
- import telnetlib
- import time
--import urlparse
--import urllib2
- from distutils.spawn import find_executable
- 
-+import psutil
-+import six.moves.urllib as urllib
- from mozdevice import DeviceManagerADB, DMError
- from mozprocess import ProcessHandler
-+from six.moves.urllib.parse import urlparse
- 
- EMULATOR_HOME_DIR = os.path.join(os.path.expanduser('~'), '.mozbuild', 'android-device')
- 
- EMULATOR_AUTH_FILE = os.path.join(os.path.expanduser('~'), '.emulator_console_auth_token')
- 
- TOOLTOOL_URL = 'https://raw.githubusercontent.com/mozilla/build-tooltool/master/tooltool.py'
- 
- TRY_URL = 'https://hg.mozilla.org/try/raw-file/default'
-@@ -304,17 +304,16 @@ def grant_runtime_permissions(build_obj)
-             dm.shellCheckOutput(['pm', 'grant', app, 'android.permission.READ_EXTERNAL_STORAGE'])
-             dm.shellCheckOutput(['pm', 'grant', app, 'android.permission.ACCESS_FINE_LOCATION'])
-             dm.shellCheckOutput(['pm', 'grant', app, 'android.permission.CAMERA'])
-     except DMError:
-         _log_warning("Unable to grant runtime permissions to %s" % app)
- 
- 
- class AndroidEmulator(object):
--
-     """
-         Support running the Android emulator with an AVD from Mozilla
-         test automation.
- 
-         Example usage:
-             emulator = AndroidEmulator()
-             if not emulator.is_running() and emulator.is_available():
-                 if not emulator.check_avd():
-@@ -423,16 +422,17 @@ class AndroidEmulator(object):
-         # create an empty auth file to disable emulator authentication
-         auth_file = open(EMULATOR_AUTH_FILE, 'w')
-         auth_file.close()
- 
-         def outputHandler(line):
-             self.emulator_log.write("<%s>\n" % line)
-             if "Invalid value for -gpu" in line or "Invalid GPU mode" in line:
-                 self.gpu = False
-+
-         env = os.environ
-         env['ANDROID_AVD_HOME'] = os.path.join(EMULATOR_HOME_DIR, "avd")
-         command = [self.emulator_path, "-avd",
-                    self.avd_info.name, "-port", "5554"]
-         if self.gpu:
-             command += ['-gpu', 'swiftshader']
-         if self.avd_info.extra_args:
-             # -enable-kvm option is not valid on OSX
-@@ -561,17 +561,17 @@ class AndroidEmulator(object):
-         telnet.write('%s\n' % command)
-         result = telnet.read_until('OK', 10)
-         _log_debug("<<< " + result)
-         return result
- 
-     def _verify_emulator(self):
-         telnet_ok = False
-         tn = None
--        while(not telnet_ok):
-+        while (not telnet_ok):
-             try:
-                 tn = telnetlib.Telnet('localhost', 5554, 10)
-                 if tn is not None:
-                     tn.read_until('OK', 10)
-                     self._telnet_cmd(tn, 'avd status')
-                     self._telnet_cmd(tn, 'redir list')
-                     self._telnet_cmd(tn, 'network status')
-                     tn.write('quit\n')
-@@ -690,17 +690,17 @@ def _log_warning(text):
- 
- 
- def _log_info(text):
-     print("%s" % text)
- 
- 
- def _download_file(url, filename, path):
-     _log_debug("Download %s to %s/%s..." % (url, path, filename))
--    f = urllib2.urlopen(url)
-+    f = urllib.urlopen(url)
-     if not os.path.isdir(path):
-         try:
-             os.makedirs(path)
-         except Exception as e:
-             _log_warning(str(e))
-             return False
-     local_file = open(os.path.join(path, filename), 'wb')
-     local_file.write(f.read())
-@@ -726,16 +726,17 @@ def _get_tooltool_manifest(substs, src_p
-     if not copied:
-         url = os.path.join(TRY_URL, src_path)
-         _download_file(url, filename, dst_path)
- 
- 
- def _tooltool_fetch():
-     def outputHandler(line):
-         _log_debug(line)
-+
-     _download_file(TOOLTOOL_URL, 'tooltool.py', EMULATOR_HOME_DIR)
-     command = [sys.executable, 'tooltool.py',
-                'fetch', '-o', '-m', 'releng.manifest']
-     proc = ProcessHandler(
-         command, processOutputLine=outputHandler, storeOutput=False,
-         cwd=EMULATOR_HOME_DIR)
-     proc.run()
-     try:
-diff --git a/testing/mozbase/mozrunner/mozrunner/devices/base.py b/testing/mozbase/mozrunner/mozrunner/devices/base.py
---- a/testing/mozbase/mozrunner/mozrunner/devices/base.py
-+++ b/testing/mozbase/mozrunner/mozrunner/devices/base.py
-@@ -1,26 +1,22 @@
- from __future__ import absolute_import, print_function
- 
--
--from ConfigParser import (
--    ConfigParser,
--    RawConfigParser
--)
- import datetime
- import os
- import posixpath
- import re
- import shutil
- import subprocess
- import tempfile
- import time
- 
- from mozdevice import ADBHost, ADBError
- from mozprocess import ProcessHandler
-+from six.moves.configparser import ConfigParser, RawConfigParser
- 
- 
- class Device(object):
-     connected = False
-     logcat_proc = None
- 
-     def __init__(self, app_ctx, logdir=None, serial=None, restore=True):
-         self.app_ctx = app_ctx
 diff --git a/testing/mozbase/mozrunner/mozrunner/utils.py b/testing/mozbase/mozrunner/mozrunner/utils.py
 --- a/testing/mozbase/mozrunner/mozrunner/utils.py
 +++ b/testing/mozbase/mozrunner/mozrunner/utils.py

+ 0 - 459
mozilla-release/patches/1440714-16-61a1.patch

@@ -212,465 +212,6 @@ diff --git a/testing/mozbase/mozrunner/mozrunner/application.py b/testing/mozbas
  class FirefoxContext(object):
      profile_class = FirefoxProfile
  
-diff --git a/testing/mozbase/mozrunner/mozrunner/base/device.py b/testing/mozbase/mozrunner/mozrunner/base/device.py
---- a/testing/mozbase/mozrunner/mozrunner/base/device.py
-+++ b/testing/mozbase/mozrunner/mozrunner/base/device.py
-@@ -52,18 +52,18 @@ class DeviceRunner(BaseRunner):
-         BaseRunner.__init__(self, **kwargs)
- 
-         device_args = device_args or {}
-         self.device = device_class(**device_args)
- 
-     @property
-     def command(self):
-         cmd = [self.app_ctx.adb]
--        if self.app_ctx.dm._deviceSerial:
--            cmd.extend(['-s', self.app_ctx.dm._deviceSerial])
-+        if self.app_ctx.device_serial:
-+            cmd.extend(['-s', self.app_ctx.device_serial])
-         cmd.append('shell')
-         for k, v in self._device_env.iteritems():
-             cmd.append('%s=%s' % (k, v))
-         cmd.append(self.app_ctx.remote_binary)
-         return cmd
- 
-     def start(self, *args, **kwargs):
-         if isinstance(self.device, BaseEmulator) and not self.device.connected:
-@@ -82,17 +82,17 @@ class DeviceRunner(BaseRunner):
-         pid = BaseRunner.start(self, *args, **kwargs)
- 
-         timeout = 10  # seconds
-         starttime = datetime.datetime.now()
-         while datetime.datetime.now() - starttime < datetime.timedelta(seconds=timeout):
-             if self.is_running():
-                 break
-             time.sleep(1)
--        else:
-+        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):
-         def _wait_for_shutdown(pid, timeout=10):
-@@ -101,18 +101,17 @@ class DeviceRunner(BaseRunner):
-             while datetime.datetime.now() - start_time < end_time:
-                 if self.is_running() != pid:
-                     return True
-                 time.sleep(1)
-             return False
- 
-         remote_pid = self.is_running()
-         if remote_pid:
--            self.app_ctx.dm.killProcess(
--                self.app_ctx.remote_process, sig=sig)
-+            self.app_ctx.device.pkill(self.app_ctx.remote_process, sig=sig)
-             if not _wait_for_shutdown(remote_pid) and sig is not None:
-                 print("timed out waiting for '%s' process to exit, trying "
-                       "without signal {}".format(
-                           self.app_ctx.remote_process, sig))
- 
-             # need to call adb stop otherwise the system will attempt to
-             # restart the process
-             remote_pid = self.is_running() or remote_pid
-@@ -165,18 +164,18 @@ class FennecRunner(DeviceRunner):
- 
-     def __init__(self, cmdargs=None, **kwargs):
-         super(FennecRunner, self).__init__(**kwargs)
-         self.cmdargs = cmdargs or []
- 
-     @property
-     def command(self):
-         cmd = [self.app_ctx.adb]
--        if self.app_ctx.dm._deviceSerial:
--            cmd.extend(["-s", self.app_ctx.dm._deviceSerial])
-+        if self.app_ctx.device_serial:
-+            cmd.extend(["-s", self.app_ctx.device_serial])
-         cmd.append("shell")
-         app = "%s/org.mozilla.gecko.BrowserApp" % self.app_ctx.remote_process
-         am_subcommand = ["am", "start", "-a", "android.activity.MAIN", "-n", app]
-         app_params = ["-no-remote", "-profile", self.app_ctx.remote_profile]
-         app_params.extend(self.cmdargs)
-         am_subcommand.extend(["--es", "args", "'%s'" % " ".join(app_params)])
-         # Append env variables in the form |--es env0 MOZ_CRASHREPORTER=1|
-         for (count, (k, v)) in enumerate(self._device_env.iteritems()):
-diff --git a/testing/mozbase/mozrunner/mozrunner/base/device.py.1440714.later b/testing/mozbase/mozrunner/mozrunner/base/device.py.1440714.later
-new file mode 100644
---- /dev/null
-+++ b/testing/mozbase/mozrunner/mozrunner/base/device.py.1440714.later
-@@ -0,0 +1,26 @@
-+--- device.py
-++++ device.py
-+@@ -111,20 +111,20 @@ class DeviceRunner(BaseRunner):
-+ 
-+     @property
-+     def returncode(self):
-+         """The returncode of the remote process.
-+ 
-+         A value of None indicates the process is still running. Otherwise 0 is
-+         returned, because there is no known way yet to retrieve the real exit code.
-+         """
-+-        if self.app_ctx.dm.processExist(self.app_ctx.remote_process) is None:
-+-            return 0
-++        if self.app_ctx.device.process_exist(self.app_ctx.remote_process):
-++            return None
-+ 
-+-        return None
-++        return 0
-+ 
-+     def wait(self, timeout=None):
-+         """Wait for the remote process to exit.
-+ 
-+         :param timeout: if not None, will return after timeout seconds.
-+ 
-+         :returns: the process return code or None if timeout was reached
-+                   and the process is still running.
-diff --git a/testing/mozbase/mozrunner/mozrunner/devices/base.py b/testing/mozbase/mozrunner/mozrunner/devices/base.py
---- a/testing/mozbase/mozrunner/mozrunner/devices/base.py
-+++ b/testing/mozbase/mozrunner/mozrunner/devices/base.py
-@@ -9,44 +9,44 @@ import datetime
- import os
- import posixpath
- import re
- import shutil
- import subprocess
- import tempfile
- import time
- 
--from mozdevice import DMError
-+from mozdevice import ADBHost, ADBError
- from mozprocess import ProcessHandler
- 
- 
- class Device(object):
-     connected = False
-     logcat_proc = None
- 
-     def __init__(self, app_ctx, logdir=None, serial=None, restore=True):
-         self.app_ctx = app_ctx
--        self.dm = self.app_ctx.dm
-+        self.device = self.app_ctx.device
-         self.restore = restore
-         self.serial = serial
-         self.logdir = os.path.abspath(os.path.expanduser(logdir))
-         self.added_files = set()
-         self.backup_files = set()
- 
-     @property
-     def remote_profiles(self):
-         """
-         A list of remote profiles on the device.
-         """
-         remote_ini = self.app_ctx.remote_profiles_ini
--        if not self.dm.fileExists(remote_ini):
-+        if not self.device.is_file(remote_ini):
-             raise IOError("Remote file '%s' not found" % remote_ini)
- 
-         local_ini = tempfile.NamedTemporaryFile()
--        self.dm.getFile(remote_ini, local_ini.name)
-+        self.device.pull(remote_ini, local_ini.name)
-         cfg = ConfigParser()
-         cfg.read(local_ini.name)
- 
-         profiles = []
-         for section in cfg.sections():
-             if cfg.has_option(section, 'Path'):
-                 if cfg.has_option(section, 'IsRelative') and cfg.getint(section, 'IsRelative'):
-                     profiles.append(posixpath.join(posixpath.dirname(remote_ini),
-@@ -58,100 +58,102 @@ class Device(object):
-     def pull_minidumps(self):
-         """
-         Saves any minidumps found in the remote profile on the local filesystem.
- 
-         :returns: Path to directory containing the dumps.
-         """
-         remote_dump_dir = posixpath.join(self.app_ctx.remote_profile, 'minidumps')
-         local_dump_dir = tempfile.mkdtemp()
--        self.dm.getDirectory(remote_dump_dir, local_dump_dir)
-+        try:
-+            self.device.pull(remote_dump_dir, local_dump_dir)
-+        except ADBError as e:
-+            # OK if directory not present -- sometimes called before browser start
-+            if 'does not exist' not in str(e):
-+                raise
-         if os.listdir(local_dump_dir):
--            for f in self.dm.listFiles(remote_dump_dir):
--                self.dm.removeFile(posixpath.join(remote_dump_dir, f))
-+            self.device.rm(remote_dump_dir, recursive=True)
-         return local_dump_dir
- 
-     def setup_profile(self, profile):
-         """
-         Copy profile to the device and update the remote profiles.ini
-         to point to the new profile.
- 
-         :param profile: mozprofile object to copy over.
-         """
--        self.dm.remount()
-+        if self.device.is_dir(self.app_ctx.remote_profile):
-+            self.device.rm(self.app_ctx.remote_profile, recursive=True)
- 
--        if self.dm.dirExists(self.app_ctx.remote_profile):
--            self.dm.shellCheckOutput(['rm', '-r', self.app_ctx.remote_profile])
--
--        self.dm.pushDir(profile.profile, self.app_ctx.remote_profile)
-+        self.device.push(profile.profile, self.app_ctx.remote_profile)
- 
-         timeout = 5  # seconds
-         starttime = datetime.datetime.now()
-         while datetime.datetime.now() - starttime < datetime.timedelta(seconds=timeout):
--            if self.dm.fileExists(self.app_ctx.remote_profiles_ini):
-+            if self.device.is_file(self.app_ctx.remote_profiles_ini):
-                 break
-             time.sleep(1)
--        else:
-+        local_profiles_ini = tempfile.NamedTemporaryFile()
-+        if not self.device.is_file(self.app_ctx.remote_profiles_ini):
-+            # Unless fennec is already running, and/or remote_profiles_ini is
-+            # not inside the remote_profile (deleted above), this is entirely
-+            # normal.
-             print("timed out waiting for profiles.ini")
--
--        local_profiles_ini = tempfile.NamedTemporaryFile()
--        self.dm.getFile(self.app_ctx.remote_profiles_ini, local_profiles_ini.name)
-+        else:
-+            self.device.pull(self.app_ctx.remote_profiles_ini, local_profiles_ini.name)
- 
-         config = ProfileConfigParser()
-         config.read(local_profiles_ini.name)
-         for section in config.sections():
-             if 'Profile' in section:
-                 config.set(section, 'IsRelative', 0)
-                 config.set(section, 'Path', self.app_ctx.remote_profile)
- 
-         new_profiles_ini = tempfile.NamedTemporaryFile()
-         config.write(open(new_profiles_ini.name, 'w'))
- 
-         self.backup_file(self.app_ctx.remote_profiles_ini)
--        self.dm.pushFile(new_profiles_ini.name, self.app_ctx.remote_profiles_ini)
-+        self.device.push(new_profiles_ini.name, self.app_ctx.remote_profiles_ini)
- 
-         # Ideally all applications would read the profile the same way, but in practice
-         # this isn't true. Perform application specific profile-related setup if necessary.
-         if hasattr(self.app_ctx, 'setup_profile'):
-             for remote_path in self.app_ctx.remote_backup_files:
-                 self.backup_file(remote_path)
-             self.app_ctx.setup_profile(profile)
- 
-     def _get_online_devices(self):
--        return [d[0] for d in self.dm.devices()
--                if d[1] != 'offline'
--                if not d[0].startswith('emulator')]
-+        adbhost = ADBHost()
-+        devices = adbhost.devices()
-+        return [d['device_serial'] for d in devices
-+                if d['state'] != 'offline'
-+                if not d['device_serial'].startswith('emulator')]
- 
-     def connect(self):
-         """
-         Connects to a running device. If no serial was specified in the
-         constructor, defaults to the first entry in `adb devices`.
-         """
-         if self.connected:
-             return
- 
--        if self.serial:
--            serial = self.serial
--        else:
--            online_devices = self._get_online_devices()
--            if not online_devices:
--                raise IOError("No devices connected. Ensure the device is on and "
--                              "remote debugging via adb is enabled in the settings.")
--            serial = online_devices[0]
-+        online_devices = self._get_online_devices()
-+        if not online_devices:
-+            raise IOError("No devices connected. Ensure the device is on and "
-+                          "remote debugging via adb is enabled in the settings.")
-+        self.serial = online_devices[0]
- 
--        self.dm._deviceSerial = serial
--        self.dm.connect()
-         self.connected = True
- 
-         if self.logdir:
-             # save logcat
--            logcat_log = os.path.join(self.logdir, '%s.log' % serial)
-+            logcat_log = os.path.join(self.logdir, '%s.log' % self.serial)
-             if os.path.isfile(logcat_log):
-                 self._rotate_log(logcat_log)
--            self.logcat_proc = self.start_logcat(serial, logfile=logcat_log)
-+            self.logcat_proc = self.start_logcat(self.serial, logfile=logcat_log)
- 
-     def start_logcat(self, serial, logfile=None, stream=None, filterspec=None):
-         logcat_args = [self.app_ctx.adb, '-s', '%s' % serial,
-                        'logcat', '-v', 'time', '-b', 'main', '-b', 'radio']
-         # only log filterspec
-         if filterspec:
-             logcat_args.extend(['-s', filterspec])
-         process_args = {}
-@@ -162,35 +164,17 @@ class Device(object):
-         proc = ProcessHandler(logcat_args, **process_args)
-         proc.run()
-         return proc
- 
-     def reboot(self):
-         """
-         Reboots the device via adb.
-         """
--        self.dm.reboot(wait=True)
--
--    def install_busybox(self, busybox):
--        """
--        Installs busybox on the device.
--
--        :param busybox: Path to busybox binary to install.
--        """
--        self.dm.remount()
--        print('pushing %s' % self.app_ctx.remote_busybox)
--        self.dm.pushFile(busybox, self.app_ctx.remote_busybox, retryLimit=10)
--        # TODO for some reason using dm.shellCheckOutput doesn't work,
--        #      while calling adb shell directly does.
--        args = [self.app_ctx.adb, '-s', self.dm._deviceSerial,
--                'shell', 'cd /system/bin; chmod 555 busybox;'
--                'for x in `./busybox --list`; do ln -s ./busybox $x; done']
--        adb = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
--        adb.wait()
--        self.dm._verifyZip()
-+        self.device.reboot()
- 
-     def wait_for_net(self):
-         active = False
-         time_out = 0
-         while not active and time_out < 40:
-             proc = subprocess.Popen([self.app_ctx.adb, 'shell', '/system/bin/netcfg'],
-                                     stdout=subprocess.PIPE)
-             proc.stdout.readline()  # ignore first line
-@@ -203,50 +187,47 @@ class Device(object):
-             time_out += 1
-             time.sleep(1)
-         return active
- 
-     def backup_file(self, remote_path):
-         if not self.restore:
-             return
- 
--        if self.dm.fileExists(remote_path) or self.dm.dirExists(remote_path):
--            self.dm.copyTree(remote_path, '%s.orig' % remote_path)
-+        if self.device.exists(remote_path):
-+            self.device.cp(remote_path, '%s.orig' % remote_path, recursive=True)
-             self.backup_files.add(remote_path)
-         else:
-             self.added_files.add(remote_path)
- 
-     def cleanup(self):
-         """
-         Cleanup the device.
-         """
-         if not self.restore:
-             return
- 
-         try:
--            self.dm._verifyDevice()
--        except DMError:
--            return
-+            self.device.remount()
-+            # Restore the original profile
-+            for added_file in self.added_files:
-+                self.device.rm(added_file)
- 
--        self.dm.remount()
--        # Restore the original profile
--        for added_file in self.added_files:
--            self.dm.removeFile(added_file)
-+            for backup_file in self.backup_files:
-+                if self.device.exists('%s.orig' % backup_file):
-+                    self.device.mv('%s.orig' % backup_file, backup_file)
- 
--        for backup_file in self.backup_files:
--            if self.dm.fileExists('%s.orig' % backup_file) or \
--               self.dm.dirExists('%s.orig' % backup_file):
--                self.dm.moveTree('%s.orig' % backup_file, backup_file)
-+            # Perform application specific profile cleanup if necessary
-+            if hasattr(self.app_ctx, 'cleanup_profile'):
-+                self.app_ctx.cleanup_profile()
- 
--        # Perform application specific profile cleanup if necessary
--        if hasattr(self.app_ctx, 'cleanup_profile'):
--            self.app_ctx.cleanup_profile()
--
--        # Remove the test profile
--        self.dm.removeDir(self.app_ctx.remote_profile)
-+            # Remove the test profile
-+            self.device.rm(self.app_ctx.remote_profile, recursive=True)
-+        except Exception as e:
-+            print("cleanup aborted: %s" % str(e))
- 
-     def _rotate_log(self, srclog, index=1):
-         """
-         Rotate a logfile, by recursively rotating logs further in the sequence,
-         deleting the last file if necessary.
-         """
-         basename = os.path.basename(srclog)
-         basename = basename[:-len('.log')]
-diff --git a/testing/mozbase/mozrunner/mozrunner/devices/emulator.py b/testing/mozbase/mozrunner/mozrunner/devices/emulator.py
---- a/testing/mozbase/mozrunner/mozrunner/devices/emulator.py
-+++ b/testing/mozbase/mozrunner/mozrunner/devices/emulator.py
-@@ -7,16 +7,17 @@ from __future__ import absolute_import
- from telnetlib import Telnet
- import datetime
- import os
- import shutil
- import subprocess
- import tempfile
- import time
- 
-+from mozdevice import ADBHost
- from mozprocess import ProcessHandler
- 
- from .base import Device
- from .emulator_battery import EmulatorBattery
- from .emulator_geo import EmulatorGeo
- from .emulator_screen import EmulatorScreen
- from ..errors import TimeoutException
- 
-@@ -136,30 +137,30 @@ class BaseEmulator(Device):
-                 raise TimeoutException(
-                     'timed out waiting for emulator to start')
-             devices = set(self._get_online_devices())
-         devices = devices - original_devices
-         self.serial = devices.pop()
-         self.connect()
- 
-     def _get_online_devices(self):
--        return [d[0] for d in self.dm.devices() if d[1] != 'offline' if
--                d[0].startswith('emulator')]
-+        adbhost = ADBHost()
-+        return [d['device_serial'] for d in adbhost.devices() if d['state'] != 'offline' if
-+                d['device_serial'].startswith('emulator')]
- 
-     def connect(self):
-         """
-         Connects to a running device. If no serial was specified in the
-         constructor, defaults to the first entry in `adb devices`.
-         """
-         if self.connected:
-             return
- 
-         super(BaseEmulator, self).connect()
--        serial = self.serial or self.dm._deviceSerial
--        self.port = int(serial[serial.rindex('-') + 1:])
-+        self.port = int(self.serial[self.serial.rindex('-') + 1:])
- 
-     def cleanup(self):
-         """
-         Cleans up and kills the emulator, if it was started by mozrunner.
-         """
-         super(BaseEmulator, self).cleanup()
-         if self.proc:
-             self.proc.kill()
 diff --git a/testing/mozbase/mozrunner/mozrunner/runners.py b/testing/mozbase/mozrunner/mozrunner/runners.py
 --- a/testing/mozbase/mozrunner/mozrunner/runners.py
 +++ b/testing/mozbase/mozrunner/mozrunner/runners.py

+ 0 - 132
mozilla-release/patches/1447401-61a1.patch

@@ -238,138 +238,6 @@ diff --git a/testing/mozbase/mozrunner/mozrunner/application.py b/testing/mozbas
  
  class ThunderbirdContext(object):
      profile_class = ThunderbirdProfile
-diff --git a/testing/mozbase/mozrunner/mozrunner/base/device.py b/testing/mozbase/mozrunner/mozrunner/base/device.py
---- a/testing/mozbase/mozrunner/mozrunner/base/device.py
-+++ b/testing/mozbase/mozrunner/mozrunner/base/device.py
-@@ -15,17 +15,17 @@ import mozfile
- 
- from .runner import BaseRunner
- from ..devices import BaseEmulator
- 
- 
- class DeviceRunner(BaseRunner):
-     """
-     The base runner class used for running gecko on
--    remote devices (or emulators), such as B2G.
-+    remote devices (or emulators).
-     """
-     env = {'MOZ_CRASHREPORTER': '1',
-            'MOZ_CRASHREPORTER_NO_REPORT': '1',
-            'MOZ_CRASHREPORTER_SHUTDOWN': '1',
-            'MOZ_HIDE_RESULTS_TABLE': '1',
-            'MOZ_LOG': 'signaling:3,mtransport:4,DataChannel:4,jsep:4,MediaPipelineFactory:4',
-            'R_LOG_LEVEL': '6',
-            'R_LOG_DESTINATION': 'stderr',
-diff --git a/testing/mozbase/mozrunner/mozrunner/devices/__init__.py b/testing/mozbase/mozrunner/mozrunner/devices/__init__.py
---- a/testing/mozbase/mozrunner/mozrunner/devices/__init__.py
-+++ b/testing/mozbase/mozrunner/mozrunner/devices/__init__.py
-@@ -1,15 +1,15 @@
- # This Source Code Form is subject to the terms of the Mozilla Public
- # License, v. 2.0. If a copy of the MPL was not distributed with this file,
- # You can obtain one at http://mozilla.org/MPL/2.0/.
- 
- from __future__ import absolute_import
- 
--from .emulator import BaseEmulator, Emulator, EmulatorAVD
-+from .emulator import BaseEmulator, EmulatorAVD
- from .base import Device
- 
- from mozrunner.devices import emulator_battery
- from mozrunner.devices import emulator_geo
- from mozrunner.devices import emulator_screen
- 
--__all__ = ['BaseEmulator', 'Emulator', 'EmulatorAVD', 'Device',
-+__all__ = ['BaseEmulator', 'EmulatorAVD', 'Device',
-            'emulator_battery', 'emulator_geo', 'emulator_screen']
-diff --git a/testing/mozbase/mozrunner/mozrunner/devices/emulator.py b/testing/mozbase/mozrunner/mozrunner/devices/emulator.py
---- a/testing/mozbase/mozrunner/mozrunner/devices/emulator.py
-+++ b/testing/mozbase/mozrunner/mozrunner/devices/emulator.py
-@@ -190,85 +190,16 @@ class BaseEmulator(Device):
-         return self._get_telnet_response(command)
- 
-     def __del__(self):
-         if self.telnet:
-             self.telnet.write('exit\n')
-             self.telnet.read_all()
- 
- 
--class Emulator(BaseEmulator):
--
--    def __init__(self, app_ctx, arch, resolution=None, sdcard=None, userdata=None,
--                 no_window=None, binary=None, **kwargs):
--        super(Emulator, self).__init__(app_ctx, arch=arch, binary=binary, **kwargs)
--
--        # emulator args
--        self.resolution = resolution or '320x480'
--        self._sdcard_size = sdcard
--        self._sdcard = None
--        self.userdata = tempfile.NamedTemporaryFile(prefix='userdata-qemu', dir=self.tmpdir)
--        self.initdata = userdata if userdata else os.path.join(self.arch.sysdir, 'userdata.img')
--        self.no_window = no_window
--
--    @property
--    def sdcard(self):
--        if self._sdcard_size and not self._sdcard:
--            self._sdcard = SDCard(self, self._sdcard_size).path
--        else:
--            return self._sdcard
--
--    @property
--    def args(self):
--        """
--        Arguments to pass into the emulator binary.
--        """
--        qemu_args = super(Emulator, self).args
--        qemu_args.extend([
--            '-kernel', self.arch.kernel,
--            '-sysdir', self.arch.sysdir,
--            '-data', self.userdata.name,
--            '-initdata', self.initdata,
--            '-wipe-data'])
--        if self.no_window:
--            qemu_args.append('-no-window')
--        if self.sdcard:
--            qemu_args.extend(['-sdcard', self.sdcard])
--        qemu_args.extend(['-memory', '512',
--                          '-partition-size', '512',
--                          '-verbose',
--                          '-skin', self.resolution,
--                          '-gpu', 'on',
--                          '-qemu'] + self.arch.extra_args)
--        return qemu_args
--
--    def connect(self):
--        """
--        Connects to a running device. If no serial was specified in the
--        constructor, defaults to the first entry in `adb devices`.
--        """
--        if self.connected:
--            return
--
--        super(Emulator, self).connect()
--        self.geo.set_default_location()
--        self.screen.initialize()
--
--        # setup DNS fix for networking
--        self.app_ctx.dm.shellCheckOutput(['setprop', 'net.dns1', '10.0.2.3'])
--
--    def cleanup(self):
--        """
--        Cleans up and kills the emulator, if it was started by mozrunner.
--        """
--        super(Emulator, self).cleanup()
--        # Remove temporary files
--        self.userdata.close()
--
--
- class EmulatorAVD(BaseEmulator):
- 
-     def __init__(self, app_ctx, binary, avd, port=5554, **kwargs):
-         super(EmulatorAVD, self).__init__(app_ctx, binary=binary, avd=avd, **kwargs)
-         self.port = port
- 
-     @property
-     def args(self):
 diff --git a/testing/mozbase/mozrunner/mozrunner/runners.py b/testing/mozbase/mozrunner/mozrunner/runners.py
 --- a/testing/mozbase/mozrunner/mozrunner/runners.py
 +++ b/testing/mozbase/mozrunner/mozrunner/runners.py

+ 0 - 99
mozilla-release/patches/1567642-1-71a1.patch

@@ -531,105 +531,6 @@ diff --git a/testing/mozbase/mozrunner/mozrunner/base/runner.py b/testing/mozbas
              # TODO: other arguments
          else:
              # this run uses the managed processhandler
-diff --git a/testing/mozbase/mozrunner/mozrunner/devices/android_device.py b/testing/mozbase/mozrunner/mozrunner/devices/android_device.py
---- a/testing/mozbase/mozrunner/mozrunner/devices/android_device.py
-+++ b/testing/mozbase/mozrunner/mozrunner/devices/android_device.py
-@@ -11,18 +11,18 @@ import platform
- import shutil
- import signal
- import sys
- import telnetlib
- import time
- from distutils.spawn import find_executable
- 
- import psutil
--import six.moves.urllib as urllib
- from mozdevice import DeviceManagerADB, DMError
-+from six.moves import input, urllib
- from mozprocess import ProcessHandler
- from six.moves.urllib.parse import urlparse
- 
- EMULATOR_HOME_DIR = os.path.join(os.path.expanduser('~'), '.mozbuild', 'android-device')
- 
- EMULATOR_AUTH_FILE = os.path.join(os.path.expanduser('~'), '.emulator_console_auth_token')
- 
- TOOLTOOL_URL = 'https://raw.githubusercontent.com/mozilla/build-tooltool/master/tooltool.py'
-@@ -109,17 +109,17 @@ def verify_android_device(build_obj, ins
-        already connected.
-     """
-     device_verified = False
-     emulator = AndroidEmulator('*', substs=build_obj.substs, verbose=verbose)
-     devices = emulator.dm.devices()
-     if (len(devices) > 0) and ('device' in [d[1] for d in devices]):
-         device_verified = True
-     elif emulator.is_available():
--        response = raw_input(
-+        response = input(
-             "No Android devices connected. Start an emulator? (Y/n) ").strip()
-         if response.lower().startswith('y') or response == '':
-             if not emulator.check_avd():
-                 _log_info("Fetching AVD. This may take a while...")
-                 emulator.update_avd()
-             _log_info("Starting emulator running %s..." %
-                       emulator.get_avd_description())
-             emulator.start()
-@@ -137,17 +137,17 @@ def verify_android_device(build_obj, ins
-         # the current build is installed, and certainly no way to
-         # determine if the installed build is the desired build.
-         # Installing every time is problematic because:
-         #  - it prevents testing against other builds (downloaded apk)
-         #  - installation may take a couple of minutes.
-         installed = emulator.dm.shellCheckOutput(['pm', 'list',
-                                                   'packages', 'org.mozilla.'])
-         if 'fennec' not in installed and 'firefox' not in installed:
--            response = raw_input(
-+            response = input(
-                 "It looks like Firefox is not installed on this device.\n"
-                 "Install Firefox? (Y/n) ").strip()
-             if response.lower().startswith('y') or response == '':
-                 _log_info("Installing Firefox. This may take a while...")
-                 build_obj._run_make(directory=".", target='install',
-                                     ensure_exit_code=False)
- 
-     if device_verified and xre:
-@@ -166,17 +166,17 @@ def verify_android_device(build_obj, ins
-             xre_path = glob.glob(os.path.join(EMULATOR_HOME_DIR, 'host-utils*'))
-             for path in xre_path:
-                 if os.path.isdir(path) and os.path.isfile(os.path.join(path, 'xpcshell')):
-                     os.environ['MOZ_HOST_BIN'] = path
-                     err = None
-                     break
-         if err:
-             _log_info("Host utilities not found: %s" % err)
--            response = raw_input(
-+            response = input(
-                 "Download and setup your host utilities? (Y/n) ").strip()
-             if response.lower().startswith('y') or response == '':
-                 _log_info("Installing host utilities. This may take a while...")
-                 host_platform = _get_host_platform()
-                 if host_platform:
-                     path = os.path.join(MANIFEST_PATH, host_platform, 'hostutils.manifest')
-                     _get_tooltool_manifest(build_obj.substs, path, EMULATOR_HOME_DIR,
-                                            'releng.manifest')
-@@ -201,17 +201,17 @@ def verify_android_device(build_obj, ins
-         gdb_path = os.path.join(jimdb_path, 'bin', 'gdb')
-         err = None
-         if not os.path.isdir(jimdb_path):
-             err = '%s does not exist' % jimdb_path
-         elif not os.path.isfile(gdb_path):
-             err = '%s not found' % gdb_path
-         if err:
-             _log_info("JimDB (%s) not found: %s" % (build_platform, err))
--            response = raw_input(
-+            response = input(
-                 "Download and setup JimDB (%s)? (Y/n) " % build_platform).strip()
-             if response.lower().startswith('y') or response == '':
-                 host_platform = _get_host_platform()
-                 if host_platform:
-                     _log_info(
-                         "Installing JimDB (%s/%s). This may take a while..." % (host_platform,
-                                                                                 build_platform))
-                     path = os.path.join(MANIFEST_PATH, host_platform,
 diff --git a/testing/mozbase/mozsystemmonitor/tests/test_resource_monitor.py b/testing/mozbase/mozsystemmonitor/tests/test_resource_monitor.py
 --- a/testing/mozbase/mozsystemmonitor/tests/test_resource_monitor.py
 +++ b/testing/mozbase/mozsystemmonitor/tests/test_resource_monitor.py

+ 1 - 33
mozilla-release/patches/1646421-3-79a1.patch

@@ -2,7 +2,7 @@
 # User Sylvestre Ledru <sledru@mozilla.com>
 # Date 1592646405 0
 # Node ID 797a96210c412d1b3e61f22165db5481f80fee44
-# Parent  890582014369faf82e77b63f41efe49508725d94
+# Parent  4434d419ad2bff11b6d3f14ee68ee3375887395b
 Bug 1646421 - flake8 Fix a bunch of actual errors r=ahal
 
 Differential Revision: https://phabricator.services.mozilla.com/D80078
@@ -185,38 +185,6 @@ diff --git a/testing/mozbase/mozlog/mozlog/pytest_mozlog/plugin.py b/testing/moz
              status, expected, message, stack = self.results.get(test, defaults)
              self.logger.test_end(test=test, status=status, expected=expected,
                                   message=message, stack=stack)
-diff --git a/testing/mozbase/mozrunner/mozrunner/base/device.py b/testing/mozbase/mozrunner/mozrunner/base/device.py
---- a/testing/mozbase/mozrunner/mozrunner/base/device.py
-+++ b/testing/mozbase/mozrunner/mozrunner/base/device.py
-@@ -108,26 +108,26 @@ class DeviceRunner(BaseRunner):
-                     return True
-                 time.sleep(1)
-             return False
- 
-         remote_pid = self.is_running()
-         if remote_pid:
-             self.app_ctx.device.pkill(self.app_ctx.remote_process, sig=sig)
-             if not _wait_for_shutdown(remote_pid) and sig is not None:
--                print("timed out waiting for '%s' process to exit, trying "
-+                print("timed out waiting for '{}' process to exit, trying "
-                       "without signal {}".format(
-                           self.app_ctx.remote_process, sig))
- 
-             # need to call adb stop otherwise the system will attempt to
-             # restart the process
-             remote_pid = self.is_running() or remote_pid
-             self.app_ctx.stop_application()
-             if not _wait_for_shutdown(remote_pid):
--                print("timed out waiting for '%s' process to exit".format(
-+                print("timed out waiting for '{}' process to exit".format(
-                     self.app_ctx.remote_process))
- 
-     def is_running(self):
-         return self.app_ctx.dm.processExist(self.app_ctx.remote_process)
- 
-     def on_output(self, line):
-         match = re.findall(r"TEST-START \| ([^\s]*)", line)
-         if match:
 diff --git a/testing/talos/talos/whitelist.py b/testing/talos/talos/whitelist.py
 --- a/testing/talos/talos/whitelist.py
 +++ b/testing/talos/talos/whitelist.py