示例#1
0
    def __init__(self, automation, devmgr, options):
        """
           Simple one-time initialization.
        """
        MochitestDesktop.__init__(self, options.flavor, vars(options))

        self.auto = automation
        self.dm = devmgr
        self.dm.default_timeout = 320
        self.options = options
        self.options.logFile = "robocop.log"
        self.environment = self.auto.environment
        self.deviceRoot = self.dm.getDeviceRoot()
        self.remoteProfile = options.remoteTestRoot + "/profile"
        self.remoteProfileCopy = options.remoteTestRoot + "/profile-copy"
        self.auto.setRemoteProfile(self.remoteProfile)
        self.remoteConfigFile = os.path.join(self.deviceRoot,
                                             "robotium.config")
        self.remoteLog = options.remoteLogFile
        self.auto.setRemoteLog(self.remoteLog)
        self.remoteScreenshots = "/mnt/sdcard/Robotium-Screenshots"
        self.remoteMozLog = os.path.join(options.remoteTestRoot, "mozlog")
        self.auto.setServerInfo(self.options.webServer, self.options.httpPort,
                                self.options.sslPort)
        self.localLog = options.logFile
        self.localProfile = None
        self.auto.setAppName(self.options.remoteappname)
        self.certdbNew = True
        self.remoteCopyAvailable = True
        self.passed = 0
        self.failed = 0
        self.todo = 0
示例#2
0
    def __init__(self, automation, devmgr, options):
        MochitestDesktop.__init__(self, options.flavor, vars(options))

        self._automation = automation
        self._dm = devmgr
        self.chromePushed = False
        self.environment = self._automation.environment
        self.remoteProfile = os.path.join(options.remoteTestRoot, "profile/")
        self.remoteModulesDir = os.path.join(options.remoteTestRoot, "modules/")
        self.remoteCache = os.path.join(options.remoteTestRoot, "cache/")
        self._automation.setRemoteProfile(self.remoteProfile)
        self.remoteLog = options.remoteLogFile
        self.localLog = options.logFile
        self._automation.deleteANRs()
        self._automation.deleteTombstones()
        self.certdbNew = True
        self.remoteMozLog = os.path.join(options.remoteTestRoot, "mozlog")
        self._dm.removeDir(self.remoteMozLog)
        self._dm.mkDir(self.remoteMozLog)
        self.remoteChromeTestDir = os.path.join(
            options.remoteTestRoot,
            "chrome")
        self._dm.removeDir(self.remoteChromeTestDir)
        self._dm.mkDir(self.remoteChromeTestDir)
        self._dm.removeDir(self.remoteProfile)
        self._dm.removeDir(self.remoteCache)
        # move necko cache to a location that can be cleaned up
        options.extraPrefs += ["browser.cache.disk.parent_directory=%s" % self.remoteCache]
示例#3
0
 def cleanup(self):
     """
        Cleanup at end of job run.
     """
     self.log.debug("Cleaning up...")
     self.stopServers()
     self.dm.killProcess(self.options.app.split('/')[-1])
     blobberUploadDir = os.environ.get('MOZ_UPLOAD_DIR', None)
     if blobberUploadDir:
         self.log.debug(
             "Pulling any remote moz logs and screenshots to %s." %
             blobberUploadDir)
         self.dm.getDirectory(self.remoteMozLog, blobberUploadDir)
         self.dm.getDirectory(self.remoteScreenshots, blobberUploadDir)
     MochitestDesktop.cleanup(self, self.options)
     if self.localProfile:
         os.system("rm -Rf %s" % self.localProfile)
     self.dm.removeDir(self.remoteProfile)
     self.dm.removeDir(self.remoteProfileCopy)
     self.dm.removeDir(self.remoteScreenshots)
     self.dm.removeDir(self.remoteMozLog)
     self.dm.removeFile(self.remoteConfigFile)
     if self.dm.fileExists(self.remoteLog):
         self.dm.removeFile(self.remoteLog)
     self.log.debug("Cleanup complete.")
示例#4
0
    def __init__(self, automation, devmgr, options):
        MochitestDesktop.__init__(self, options.flavor, vars(options))

        self._automation = automation
        self._dm = devmgr
        self.environment = self._automation.environment
        self.remoteProfile = os.path.join(options.remoteTestRoot, "profile/")
        self.remoteModulesDir = os.path.join(options.remoteTestRoot, "modules/")
        self.remoteCache = os.path.join(options.remoteTestRoot, "cache/")
        self._automation.setRemoteProfile(self.remoteProfile)
        self.remoteLog = options.remoteLogFile
        self.localLog = options.logFile
        self._automation.deleteANRs()
        self._automation.deleteTombstones()
        self.certdbNew = True
        self.remoteMozLog = os.path.join(options.remoteTestRoot, "mozlog")
        self._dm.removeDir(self.remoteMozLog)
        self._dm.mkDir(self.remoteMozLog)
        self.remoteChromeTestDir = os.path.join(
            options.remoteTestRoot,
            "chrome")
        self._dm.removeDir(self.remoteChromeTestDir)
        self._dm.mkDir(self.remoteChromeTestDir)
        self._dm.removeDir(self.remoteProfile)
        self._dm.removeDir(self.remoteCache)
        # move necko cache to a location that can be cleaned up
        options.extraPrefs += ["browser.cache.disk.parent_directory=%s" % self.remoteCache]
示例#5
0
 def cleanup(self):
     """
        Cleanup at end of job run.
     """
     self.log.debug("Cleaning up...")
     self.stopServers()
     self.device.stop_application(self.options.app.split('/')[-1])
     uploadDir = os.environ.get('MOZ_UPLOAD_DIR', None)
     if uploadDir:
         self.log.debug(
             "Pulling any remote moz logs and screenshots to %s." %
             uploadDir)
         if self.device.is_dir(self.remoteMozLog):
             self.device.pull(self.remoteMozLog, uploadDir)
         if self.device.is_dir(self.remoteScreenshots):
             self.device.pull(self.remoteScreenshots, uploadDir)
     MochitestDesktop.cleanup(self, self.options)
     if self.localProfile:
         mozfile.remove(self.localProfile)
     self.device.rm(self.remoteProfile, force=True, recursive=True)
     self.device.rm(self.remoteProfileCopy, force=True, recursive=True)
     self.device.rm(self.remoteScreenshots, force=True, recursive=True)
     self.device.rm(self.remoteMozLog, force=True, recursive=True)
     self.device.rm(self.remoteConfigFile, force=True)
     self.device.rm(self.remoteLogFile, force=True)
     self.log.debug("Cleanup complete.")
示例#6
0
 def startServers(self, options, debuggerInfo):
     """ Create the servers on the host and start them up """
     restoreRemotePaths = self.switchToLocalPaths(options)
     MochitestDesktop.startServers(
         self,
         options,
         debuggerInfo)
     restoreRemotePaths()
示例#7
0
 def startServers(self, options, debuggerInfo):
     """ Create the servers on the host and start them up """
     restoreRemotePaths = self.switchToLocalPaths(options)
     # ignoreSSLTunnelExts is a workaround for bug 1109310
     MochitestDesktop.startServers(self,
                                   options,
                                   debuggerInfo,
                                   ignoreSSLTunnelExts=True)
     restoreRemotePaths()
示例#8
0
 def startServers(self, options, debuggerInfo):
     """ Create the servers on the host and start them up """
     restoreRemotePaths = self.switchToLocalPaths(options)
     # ignoreSSLTunnelExts is a workaround for bug 1109310
     MochitestDesktop.startServers(
         self,
         options,
         debuggerInfo,
         ignoreSSLTunnelExts=True)
     restoreRemotePaths()
示例#9
0
 def cleanup(self, options):
     if self._dm.fileExists(self.remoteLog):
         self._dm.getFile(self.remoteLog, self.localLog)
         self._dm.removeFile(self.remoteLog)
     else:
         self.log.warning("Unable to retrieve log file (%s) from remote device" % self.remoteLog)
     self._dm.removeDir(self.remoteProfile)
     self._dm.removeDir(self.remoteChromeTestDir)
     blobberUploadDir = os.environ.get("MOZ_UPLOAD_DIR", None)
     if blobberUploadDir:
         self._dm.getDirectory(self.remoteMozLog, blobberUploadDir)
     MochitestDesktop.cleanup(self, options)
示例#10
0
 def cleanup(self, options, final=False):
     if final:
         self.device.rm(self.remoteChromeTestDir, force=True, recursive=True)
         self.chromePushed = False
         uploadDir = os.environ.get('MOZ_UPLOAD_DIR', None)
         if uploadDir and self.device.is_dir(self.remoteMozLog):
             self.device.pull(self.remoteMozLog, uploadDir)
     self.device.rm(self.remoteLogFile, force=True)
     self.device.rm(self.remoteProfile, force=True, recursive=True)
     self.device.rm(self.remoteCache, force=True, recursive=True)
     MochitestDesktop.cleanup(self, options, final)
     self.localProfile = None
示例#11
0
    def __init__(self, options, message_logger):
        """
           Simple one-time initialization.
        """
        MochitestDesktop.__init__(self, options.flavor, vars(options))

        verbose = False
        if options.log_tbpl_level == 'debug' or options.log_mach_level == 'debug':
            verbose = True
        self.device = ADBDevice(adb=options.adbPath or 'adb',
                                device=options.deviceSerial,
                                test_root=options.remoteTestRoot,
                                verbose=verbose)

        # Check that Firefox is installed
        expected = options.app.split('/')[-1]
        if not self.device.is_app_installed(expected):
            raise Exception("%s is not installed on this device" % expected)

        options.logFile = "robocop.log"
        if options.remoteTestRoot is None:
            options.remoteTestRoot = self.device.test_root
        self.remoteProfile = posixpath.join(options.remoteTestRoot, "profile")
        self.remoteProfileCopy = posixpath.join(options.remoteTestRoot,
                                                "profile-copy")

        self.remoteModulesDir = posixpath.join(options.remoteTestRoot,
                                               "modules/")
        self.remoteConfigFile = posixpath.join(options.remoteTestRoot,
                                               "robotium.config")
        self.remoteLogFile = posixpath.join(options.remoteTestRoot, "logs",
                                            "robocop.log")

        self.options = options

        process_args = {'messageLogger': message_logger}
        self.auto = RemoteAutomation(self.device,
                                     options.remoteappname,
                                     self.remoteProfile,
                                     self.remoteLogFile,
                                     processArgs=process_args)
        self.environment = self.auto.environment

        self.remoteScreenshots = "/mnt/sdcard/Robotium-Screenshots"
        self.remoteMozLog = posixpath.join(options.remoteTestRoot, "mozlog")

        self.localLog = options.logFile
        self.localProfile = None
        self.certdbNew = True
        self.passed = 0
        self.failed = 0
        self.todo = 0
示例#12
0
 def cleanup(self, options):
     if self._dm.fileExists(self.remoteLog):
         self._dm.getFile(self.remoteLog, self.localLog)
         self._dm.removeFile(self.remoteLog)
     else:
         self.log.warning(
             "Unable to retrieve log file (%s) from remote device" %
             self.remoteLog)
     self._dm.removeDir(self.remoteProfile)
     self._dm.removeDir(self.remoteChromeTestDir)
     blobberUploadDir = os.environ.get('MOZ_UPLOAD_DIR', None)
     if blobberUploadDir:
         self._dm.getDirectory(self.remoteMozLog, blobberUploadDir)
     MochitestDesktop.cleanup(self, options)
    def buildProfile(self, options):
        restoreRemotePaths = self.switchToLocalPaths(options)
        if options.testingModulesDir:
            try:
                self.device.push(options.testingModulesDir,
                                 self.remoteModulesDir)
                self.device.chmod(self.remoteModulesDir,
                                  recursive=True,
                                  root=True)
            except Exception:
                self.log.error(
                    "Automation Error: Unable to copy test modules to device.")
                raise
            savedTestingModulesDir = options.testingModulesDir
            options.testingModulesDir = self.remoteModulesDir
        else:
            savedTestingModulesDir = None
        manifest = MochitestDesktop.buildProfile(self, options)
        if savedTestingModulesDir:
            options.testingModulesDir = savedTestingModulesDir
        self.localProfile = options.profilePath

        restoreRemotePaths()
        options.profilePath = self.remoteProfile
        return manifest
示例#14
0
    def buildProfile(self):
        """
           Build a profile locally, keep it locally for use by servers and
           push a copy to the remote profile-copy directory.

           This is similar to buildProfile in runtestsremote.py.
        """
        self.options.extraPrefs.append('browser.search.suggest.enabled=true')
        self.options.extraPrefs.append('browser.search.suggest.prompted=true')
        self.options.extraPrefs.append('layout.css.devPixelsPerPx=1.0')
        self.options.extraPrefs.append('browser.chrome.dynamictoolbar=false')
        self.options.extraPrefs.append('browser.snippets.enabled=false')
        self.options.extraPrefs.append('extensions.autoupdate.enabled=false')

        # Override the telemetry init delay for integration testing.
        self.options.extraPrefs.append('toolkit.telemetry.initDelay=1')

        self.options.extensionsToExclude.extend([
            '*****@*****.**',
        ])

        manifest = MochitestDesktop.buildProfile(self, self.options)
        self.localProfile = self.options.profilePath
        self.log.debug("Profile created at %s" % self.localProfile)
        # some files are not needed for robocop; save time by not pushing
        os.remove(os.path.join(self.localProfile, 'userChrome.css'))
        try:
            self.device.push(self.localProfile, self.remoteProfileCopy)
        except Exception:
            self.log.error(
                "Automation Error: Unable to copy profile to device.")
            raise

        return manifest
示例#15
0
    def buildProfile(self):
        """
           Build a profile locally, keep it locally for use by servers and
           push a copy to the remote profile-copy directory.

           This is similar to buildProfile in runtestsremote.py.
        """
        self.options.extraPrefs.append('browser.search.suggest.enabled=true')
        self.options.extraPrefs.append('browser.search.suggest.prompted=true')
        self.options.extraPrefs.append('layout.css.devPixelsPerPx=1.0')
        self.options.extraPrefs.append('browser.chrome.dynamictoolbar=false')
        self.options.extraPrefs.append('browser.snippets.enabled=false')
        self.options.extraPrefs.append('browser.casting.enabled=true')
        self.options.extraPrefs.append('extensions.autoupdate.enabled=false')
        manifest = MochitestDesktop.buildProfile(self, self.options)
        self.localProfile = self.options.profilePath
        self.log.debug("Profile created at %s" % self.localProfile)
        # some files are not needed for robocop; save time by not pushing
        shutil.rmtree(os.path.join(self.localProfile, 'webapps'))
        desktop_extensions = [
            '*****@*****.**', '*****@*****.**',
            '*****@*****.**'
        ]
        for ext in desktop_extensions:
            shutil.rmtree(
                os.path.join(self.localProfile, 'extensions', 'staged', ext))
        os.remove(os.path.join(self.localProfile, 'userChrome.css'))
        try:
            self.dm.pushDir(self.localProfile, self.remoteProfileCopy)
        except devicemanager.DMError:
            self.log.error(
                "Automation Error: Unable to copy profile to device.")
            raise

        return manifest
示例#16
0
    def buildProfile(self, options):
        restoreRemotePaths = self.switchToLocalPaths(options)
        if options.testingModulesDir:
            try:
                self._dm.pushDir(options.testingModulesDir,
                                 self.remoteModulesDir)
                self._dm.chmodDir(self.remoteModulesDir)
            except mozdevice.DMError:
                self.log.error(
                    "Automation Error: Unable to copy test modules to device.")
                raise
            savedTestingModulesDir = options.testingModulesDir
            options.testingModulesDir = self.remoteModulesDir
        else:
            savedTestingModulesDir = None
        manifest = MochitestDesktop.buildProfile(self, options)
        if savedTestingModulesDir:
            options.testingModulesDir = savedTestingModulesDir
        self.localProfile = options.profilePath
        self._dm.removeDir(self.remoteProfile)

        try:
            self._dm.pushDir(options.profilePath, self.remoteProfile)
            self._dm.chmodDir(self.remoteProfile)
        except mozdevice.DMError:
            self.log.error(
                "Automation Error: Unable to copy profile to device.")
            raise

        restoreRemotePaths()
        options.profilePath = self.remoteProfile
        return manifest
示例#17
0
    def buildProfile(self, options):
        restoreRemotePaths = self.switchToLocalPaths(options)
        if options.testingModulesDir:
            try:
                self._dm.pushDir(options.testingModulesDir, self.remoteModulesDir)
                self._dm.chmodDir(self.remoteModulesDir)
            except devicemanager.DMError:
                self.log.error(
                    "Automation Error: Unable to copy test modules to device.")
                raise
            savedTestingModulesDir = options.testingModulesDir
            options.testingModulesDir = self.remoteModulesDir
        else:
            savedTestingModulesDir = None
        manifest = MochitestDesktop.buildProfile(self, options)
        if savedTestingModulesDir:
            options.testingModulesDir = savedTestingModulesDir
        self.localProfile = options.profilePath
        self._dm.removeDir(self.remoteProfile)

        try:
            self._dm.pushDir(options.profilePath, self.remoteProfile)
            self._dm.chmodDir(self.remoteProfile)
        except devicemanager.DMError:
            self.log.error(
                "Automation Error: Unable to copy profile to device.")
            raise

        restoreRemotePaths()
        options.profilePath = self.remoteProfile
        return manifest
示例#18
0
    def buildProfile(self):
        """
           Build a profile locally, keep it locally for use by servers and
           push a copy to the remote profile-copy directory.

           This is similar to buildProfile in runtestsremote.py.
        """
        self.options.extraPrefs.append('browser.search.suggest.enabled=true')
        self.options.extraPrefs.append('browser.search.suggest.prompted=true')
        self.options.extraPrefs.append('layout.css.devPixelsPerPx=1.0')
        self.options.extraPrefs.append('browser.chrome.dynamictoolbar=false')
        self.options.extraPrefs.append('browser.snippets.enabled=false')
        self.options.extraPrefs.append('browser.casting.enabled=true')
        self.options.extraPrefs.append('extensions.autoupdate.enabled=false')
        manifest = MochitestDesktop.buildProfile(self, self.options)
        self.localProfile = self.options.profilePath
        self.log.debug("Profile created at %s" % self.localProfile)
        # some files are not needed for robocop; save time by not pushing
        shutil.rmtree(os.path.join(self.localProfile, 'webapps'))
        desktop_extensions = ['*****@*****.**', '*****@*****.**', '*****@*****.**']
        for ext in desktop_extensions:
            shutil.rmtree(os.path.join(self.localProfile, 'extensions', 'staged', ext))
        os.remove(os.path.join(self.localProfile, 'userChrome.css'))
        try:
            self.dm.pushDir(self.localProfile, self.remoteProfileCopy)
        except devicemanager.DMError:
            self.log.error(
                "Automation Error: Unable to copy profile to device.")
            raise

        return manifest
示例#19
0
 def buildBrowserEnv(self, options, debugger=False):
     browserEnv = MochitestDesktop.buildBrowserEnv(self, options, debugger=debugger)
     # remove desktop environment not used on device
     if "MOZ_WIN_INHERIT_STD_HANDLES_PRE_VISTA" in browserEnv:
         del browserEnv["MOZ_WIN_INHERIT_STD_HANDLES_PRE_VISTA"]
     if "XPCOM_MEM_BLOAT_LOG" in browserEnv:
         del browserEnv["XPCOM_MEM_BLOAT_LOG"]
     # override mozLogs to avoid processing in MochitestDesktop base class
     self.mozLogs = None
     browserEnv["MOZ_LOG_FILE"] = os.path.join(self.remoteMozLog, self.mozLogName)
     return browserEnv
示例#20
0
    def __init__(self, automation, devmgr, options):
        MochitestDesktop.__init__(self, options)

        self._automation = automation
        self._dm = devmgr
        self.environment = self._automation.environment
        self.remoteProfile = os.path.join(options.remoteTestRoot, "profile/")
        self.remoteModulesDir = os.path.join(options.remoteTestRoot, "modules/")
        self._automation.setRemoteProfile(self.remoteProfile)
        self.remoteLog = options.remoteLogFile
        self.localLog = options.logFile
        self._automation.deleteANRs()
        self._automation.deleteTombstones()
        self.certdbNew = True
        self.remoteMozLog = os.path.join(options.remoteTestRoot, "mozlog")
        self._dm.removeDir(self.remoteMozLog)
        self._dm.mkDir(self.remoteMozLog)
        self.remoteChromeTestDir = os.path.join(options.remoteTestRoot, "chrome")
        self._dm.removeDir(self.remoteChromeTestDir)
        self._dm.mkDir(self.remoteChromeTestDir)
示例#21
0
 def buildBrowserEnv(self, options, debugger=False):
     browserEnv = MochitestDesktop.buildBrowserEnv(self,
                                                   options,
                                                   debugger=debugger)
     # remove desktop environment not used on device
     if "XPCOM_MEM_BLOAT_LOG" in browserEnv:
         del browserEnv["XPCOM_MEM_BLOAT_LOG"]
     # override mozLogs to avoid processing in MochitestDesktop base class
     self.mozLogs = None
     browserEnv["MOZ_LOG_FILE"] = os.path.join(self.remoteMozLog,
                                               self.mozLogName)
     return browserEnv
示例#22
0
    def __init__(self, automation, devmgr, options):
        MochitestDesktop.__init__(self, options)

        self._automation = automation
        self._dm = devmgr
        self.environment = self._automation.environment
        self.remoteProfile = options.remoteTestRoot + "/profile"
        self._automation.setRemoteProfile(self.remoteProfile)
        self.remoteLog = options.remoteLogFile
        self.localLog = options.logFile
        self._automation.deleteANRs()
        self._automation.deleteTombstones()
        self.certdbNew = True
        self.remoteNSPR = os.path.join(options.remoteTestRoot, "nspr")
        self._dm.removeDir(self.remoteNSPR)
        self._dm.mkDir(self.remoteNSPR)
        self.remoteChromeTestDir = os.path.join(
            options.remoteTestRoot,
            "chrome")
        self._dm.removeDir(self.remoteChromeTestDir)
        self._dm.mkDir(self.remoteChromeTestDir)
示例#23
0
    def addChromeToProfile(self, options):
        manifest = MochitestDesktop.addChromeToProfile(self, options)

        # Support Firefox (browser), B2G (shell), SeaMonkey (navigator), and Webapp
        # Runtime (webapp).
        if options.flavor == "chrome":
            # append overlay to chrome.manifest
            chrome = "overlay chrome://browser/content/browser.xul chrome://mochikit/content/browser-test-overlay.xul"
            path = os.path.join(options.profilePath, "extensions", "staged", "*****@*****.**", "chrome.manifest")
            with open(path, "a") as f:
                f.write(chrome)
        return manifest
示例#24
0
    def addChromeToProfile(self, options):
        manifest = MochitestDesktop.addChromeToProfile(self, options)

        # Support Firefox (browser), B2G (shell), SeaMonkey (navigator), and Webapp
        # Runtime (webapp).
        if options.flavor == 'chrome':
            # append overlay to chrome.manifest
            chrome = "overlay chrome://browser/content/browser.xul chrome://mochikit/content/browser-test-overlay.xul"
            path = os.path.join(options.profilePath, 'extensions', 'staged',
                                '*****@*****.**', 'chrome.manifest')
            with open(path, "a") as f:
                f.write(chrome)
        return manifest
示例#25
0
    def addChromeToProfile(self, options):
        manifest = MochitestDesktop.addChromeToProfile(self, options)

        # Support Firefox (browser), SeaMonkey (navigator), and Webapp Runtime (webapp).
        if options.flavor == 'chrome':
            # append overlay to chrome.manifest
            chrome = ("overlay chrome://browser/content/browser.xul "
                      "chrome://mochikit/content/browser-test-overlay.xul")
            path = os.path.join(options.profilePath, 'extensions', 'staged',
                                '*****@*****.**', 'chrome.manifest')
            with open(path, "a") as f:
                f.write(chrome)
        return manifest
示例#26
0
 def buildBrowserEnv(self, options, debugger=False):
     browserEnv = MochitestDesktop.buildBrowserEnv(self,
                                                   options,
                                                   debugger=debugger)
     # remove desktop environment not used on device
     if "MOZ_WIN_INHERIT_STD_HANDLES_PRE_VISTA" in browserEnv:
         del browserEnv["MOZ_WIN_INHERIT_STD_HANDLES_PRE_VISTA"]
     if "XPCOM_MEM_BLOAT_LOG" in browserEnv:
         del browserEnv["XPCOM_MEM_BLOAT_LOG"]
     # override nsprLogs to avoid processing in MochitestDesktop base class
     self.nsprLogs = None
     browserEnv["NSPR_LOG_FILE"] = os.path.join(self.remoteNSPR,
                                                self.nsprLogName)
     return browserEnv
示例#27
0
    def __init__(self, automation, devmgr, options):
        """
           Simple one-time initialization.
        """
        MochitestDesktop.__init__(self, options)

        self.auto = automation
        self.dm = devmgr
        self.dm.default_timeout = 320
        self.options = options
        self.options.logFile = "robocop.log"
        self.environment = self.auto.environment
        self.deviceRoot = self.dm.getDeviceRoot()
        self.remoteProfile = options.remoteTestRoot + "/profile"
        self.remoteProfileCopy = options.remoteTestRoot + "/profile-copy"
        self.auto.setRemoteProfile(self.remoteProfile)
        self.remoteConfigFile = os.path.join(
            self.deviceRoot, "robotium.config")
        self.remoteLog = options.remoteLogFile
        self.auto.setRemoteLog(self.remoteLog)
        self.remoteScreenshots = "/mnt/sdcard/Robotium-Screenshots"
        self.remoteMozLog = os.path.join(options.remoteTestRoot, "mozlog")
        self.auto.setServerInfo(
            self.options.webServer, self.options.httpPort, self.options.sslPort)
        self.localLog = options.logFile
        self.localProfile = None
        productPieces = self.options.remoteProductName.split('.')
        if (productPieces is not None):
            self.auto.setProduct(productPieces[0])
        else:
            self.auto.setProduct(self.options.remoteProductName)
        self.auto.setAppName(self.options.remoteappname)
        self.certdbNew = True
        self.remoteCopyAvailable = True
        self.passed = 0
        self.failed = 0
        self.todo = 0
示例#28
0
 def cleanup(self):
     """
        Cleanup at end of job run.
     """
     self.log.debug("Cleaning up...")
     self.stopServers()
     self.dm.killProcess(self.options.app.split('/')[-1])
     blobberUploadDir = os.environ.get('MOZ_UPLOAD_DIR', None)
     if blobberUploadDir:
         self.log.debug("Pulling any remote moz logs and screenshots to %s." %
                        blobberUploadDir)
         self.dm.getDirectory(self.remoteMozLog, blobberUploadDir)
         self.dm.getDirectory(self.remoteScreenshots, blobberUploadDir)
     MochitestDesktop.cleanup(self, self.options)
     if self.localProfile:
         os.system("rm -Rf %s" % self.localProfile)
     self.dm.removeDir(self.remoteProfile)
     self.dm.removeDir(self.remoteProfileCopy)
     self.dm.removeDir(self.remoteScreenshots)
     self.dm.removeDir(self.remoteMozLog)
     self.dm.removeFile(self.remoteConfigFile)
     if self.dm.fileExists(self.remoteLog):
         self.dm.removeFile(self.remoteLog)
     self.log.debug("Cleanup complete.")
示例#29
0
    def buildProfile(self, options):
        restoreRemotePaths = self.switchToLocalPaths(options)
        manifest = MochitestDesktop.buildProfile(self, options)
        self.localProfile = options.profilePath
        self._dm.removeDir(self.remoteProfile)

        try:
            self._dm.pushDir(options.profilePath, self.remoteProfile)
        except devicemanager.DMError:
            self.log.error(
                "Automation Error: Unable to copy profile to device.")
            raise

        restoreRemotePaths()
        options.profilePath = self.remoteProfile
        return manifest
示例#30
0
 def buildBrowserEnv(self, options, debugger=False):
     browserEnv = MochitestDesktop.buildBrowserEnv(
         self,
         options,
         debugger=debugger)
     # remove desktop environment not used on device
     if "XPCOM_MEM_BLOAT_LOG" in browserEnv:
         del browserEnv["XPCOM_MEM_BLOAT_LOG"]
     # override mozLogs to avoid processing in MochitestDesktop base class
     self.mozLogs = None
     browserEnv["MOZ_LOG_FILE"] = os.path.join(
         self.remoteMozLog,
         self.mozLogName)
     if options.dmd:
         browserEnv['DMD'] = '1'
     return browserEnv
示例#31
0
 def buildBrowserEnv(self, options, debugger=False):
     browserEnv = MochitestDesktop.buildBrowserEnv(self, options, debugger=debugger)
     # remove desktop environment not used on device
     if "XPCOM_MEM_BLOAT_LOG" in browserEnv:
         del browserEnv["XPCOM_MEM_BLOAT_LOG"]
     if self.mozLogs:
         browserEnv["MOZ_LOG_FILE"] = os.path.join(
             self.remoteMozLog, "moz-pid=%PID-uid={}.log".format(str(uuid.uuid4()))
         )
     if options.dmd:
         browserEnv["DMD"] = "1"
     # Contents of remoteMozLog will be pulled from device and copied to the
     # host MOZ_UPLOAD_DIR, to be made available as test artifacts. Make
     # MOZ_UPLOAD_DIR available to the browser environment so that tests
     # can use it as though they were running on the host.
     browserEnv["MOZ_UPLOAD_DIR"] = self.remoteMozLog
     return browserEnv
示例#32
0
    def buildURLOptions(self, options, env):
        saveLogFile = options.logFile
        options.logFile = self.remoteLogFile
        options.profilePath = self.localProfile
        env["MOZ_HIDE_RESULTS_TABLE"] = "1"
        retVal = MochitestDesktop.buildURLOptions(self, options, env)

        # we really need testConfig.js (for browser chrome)
        try:
            self.device.push(options.profilePath, self.remoteProfile)
            self.device.chmod(self.remoteProfile, recursive=True, root=True)
        except Exception:
            self.log.error("Automation Error: Unable to copy profile to device.")
            raise

        options.profilePath = self.remoteProfile
        options.logFile = saveLogFile
        return retVal
示例#33
0
    def buildURLOptions(self, options, env):
        self.localLog = options.logFile
        options.logFile = self.remoteLog
        options.fileLevel = 'INFO'
        options.profilePath = self.localProfile
        env["MOZ_HIDE_RESULTS_TABLE"] = "1"
        retVal = MochitestDesktop.buildURLOptions(self, options, env)

        # we really need testConfig.js (for browser chrome)
        try:
            self._dm.pushDir(options.profilePath, self.remoteProfile)
        except devicemanager.DMError:
            self.log.error(
                "Automation Error: Unable to copy profile to device.")
            raise

        options.profilePath = self.remoteProfile
        options.logFile = self.localLog
        return retVal
示例#34
0
 def buildBrowserEnv(self, options, debugger=False):
     browserEnv = MochitestDesktop.buildBrowserEnv(self,
                                                   options,
                                                   debugger=debugger)
     # remove desktop environment not used on device
     if "XPCOM_MEM_BLOAT_LOG" in browserEnv:
         del browserEnv["XPCOM_MEM_BLOAT_LOG"]
     # override mozLogs to avoid processing in MochitestDesktop base class
     self.mozLogs = None
     browserEnv["MOZ_LOG_FILE"] = os.path.join(self.remoteMozLog,
                                               self.mozLogName)
     if options.dmd:
         browserEnv['DMD'] = '1'
     # Contents of remoteMozLog will be pulled from device and copied to the
     # host MOZ_UPLOAD_DIR, to be made available as test artifacts. Make
     # MOZ_UPLOAD_DIR available to the browser environment so that tests
     # can use it as though they were running on the host.
     browserEnv["MOZ_UPLOAD_DIR"] = self.remoteMozLog
     return browserEnv
示例#35
0
    def buildURLOptions(self, options, env):
        self.localLog = options.logFile
        options.logFile = self.remoteLog
        options.fileLevel = "INFO"
        options.profilePath = self.localProfile
        env["MOZ_HIDE_RESULTS_TABLE"] = "1"
        retVal = MochitestDesktop.buildURLOptions(self, options, env)

        # we really need testConfig.js (for browser chrome)
        try:
            self._dm.pushDir(options.profilePath, self.remoteProfile)
            self._dm.chmodDir(self.remoteProfile)
        except mozdevice.DMError:
            self.log.error("Automation Error: Unable to copy profile to device.")
            raise

        options.profilePath = self.remoteProfile
        options.logFile = self.localLog
        return retVal
示例#36
0
    def buildProfile(self):
        """
           Build a profile locally, keep it locally for use by servers and
           push a copy to the remote profile-copy directory.

           This is similar to buildProfile in runtestsremote.py.
        """
        self.options.extraPrefs.append('browser.search.suggest.enabled=true')
        self.options.extraPrefs.append('browser.search.suggest.prompted=true')
        self.options.extraPrefs.append('layout.css.devPixelsPerPx=1.0')
        self.options.extraPrefs.append('browser.chrome.dynamictoolbar=false')
        self.options.extraPrefs.append('browser.snippets.enabled=false')
        self.options.extraPrefs.append('browser.casting.enabled=true')
        self.options.extraPrefs.append('extensions.autoupdate.enabled=false')

        # Override the telemetry init delay for integration testing.
        self.options.extraPrefs.append('toolkit.telemetry.initDelay=1')

        self.options.extensionsToExclude.extend([
            '*****@*****.**',
            '*****@*****.**',
            '*****@*****.**',
            '*****@*****.**',
        ])

        manifest = MochitestDesktop.buildProfile(self, self.options)
        self.localProfile = self.options.profilePath
        self.log.debug("Profile created at %s" % self.localProfile)
        # some files are not needed for robocop; save time by not pushing
        os.remove(os.path.join(self.localProfile, 'userChrome.css'))
        try:
            self.dm.pushDir(self.localProfile, self.remoteProfileCopy)
        except mozdevice.DMError:
            self.log.error(
                "Automation Error: Unable to copy profile to device.")
            raise

        return manifest
示例#37
0
    def __init__(self, options):
        MochitestDesktop.__init__(self, options.flavor, vars(options))

        verbose = False
        if options.log_tbpl_level == 'debug' or options.log_mach_level == 'debug':
            verbose = True
        if hasattr(options, 'log'):
            delattr(options, 'log')

        self.certdbNew = True
        self.chromePushed = False
        self.mozLogName = "moz.log"

        self.device = ADBDevice(adb=options.adbPath or 'adb',
                                device=options.deviceSerial,
                                test_root=options.remoteTestRoot,
                                verbose=verbose)

        if options.remoteTestRoot is None:
            options.remoteTestRoot = self.device.test_root
        options.dumpOutputDirectory = options.remoteTestRoot
        self.remoteLogFile = posixpath.join(options.remoteTestRoot, "logs", "mochitest.log")
        logParent = posixpath.dirname(self.remoteLogFile)
        self.device.rm(logParent, force=True, recursive=True)
        self.device.mkdir(logParent)

        self.remoteProfile = posixpath.join(options.remoteTestRoot, "profile/")
        self.device.rm(self.remoteProfile, force=True, recursive=True)

        self.counts = dict()
        self.message_logger = MessageLogger(logger=None)
        self.message_logger.logger = self.log
        process_args = {'messageLogger': self.message_logger, 'counts': self.counts}
        self.automation = RemoteAutomation(self.device, options.remoteappname, self.remoteProfile,
                                           self.remoteLogFile, processArgs=process_args)
        self.environment = self.automation.environment

        # Check that Firefox is installed
        expected = options.app.split('/')[-1]
        if not self.device.is_app_installed(expected):
            raise Exception("%s is not installed on this device" % expected)

        self.automation.deleteANRs()
        self.automation.deleteTombstones()
        self.device.clear_logcat()

        self.remoteModulesDir = posixpath.join(options.remoteTestRoot, "modules/")

        self.remoteCache = posixpath.join(options.remoteTestRoot, "cache/")
        self.device.rm(self.remoteCache, force=True, recursive=True)

        # move necko cache to a location that can be cleaned up
        options.extraPrefs += ["browser.cache.disk.parent_directory=%s" % self.remoteCache]

        self.remoteMozLog = posixpath.join(options.remoteTestRoot, "mozlog")
        self.device.rm(self.remoteMozLog, force=True, recursive=True)
        self.device.mkdir(self.remoteMozLog)

        self.remoteChromeTestDir = posixpath.join(
            options.remoteTestRoot,
            "chrome")
        self.device.rm(self.remoteChromeTestDir, force=True, recursive=True)
        self.device.mkdir(self.remoteChromeTestDir)

        procName = options.app.split('/')[-1]
        self.device.stop_application(procName)
        if self.device.process_exist(procName):
            self.log.warning("unable to kill %s before running tests!" % procName)

        # Add Android version (SDK level) to mozinfo so that manifest entries
        # can be conditional on android_version.
        self.log.info(
            "Android sdk version '%s'; will use this to filter manifests" %
            str(self.device.version))
        mozinfo.info['android_version'] = str(self.device.version)
        mozinfo.info['isFennec'] = not ('geckoview' in options.app)
        mozinfo.info['is_emulator'] = self.device._device_serial.startswith('emulator-')
示例#38
0
    def __init__(self, options):
        MochitestDesktop.__init__(self, options.flavor, vars(options))

        verbose = False
        if (options.log_mach_verbose or options.log_tbpl_level == "debug"
                or options.log_mach_level == "debug"
                or options.log_raw_level == "debug"):
            verbose = True
        if hasattr(options, "log"):
            delattr(options, "log")

        self.certdbNew = True
        self.chromePushed = False

        expected = options.app.split("/")[-1]
        self.device = ADBDeviceFactory(
            adb=options.adbPath or "adb",
            device=options.deviceSerial,
            test_root=options.remoteTestRoot,
            verbose=verbose,
            run_as_package=expected,
        )

        if options.remoteTestRoot is None:
            options.remoteTestRoot = self.device.test_root
        options.dumpOutputDirectory = options.remoteTestRoot
        self.remoteLogFile = posixpath.join(options.remoteTestRoot, "logs",
                                            "mochitest.log")
        logParent = posixpath.dirname(self.remoteLogFile)
        self.device.rm(logParent, force=True, recursive=True)
        self.device.mkdir(logParent, parents=True)

        self.remoteProfile = posixpath.join(options.remoteTestRoot, "profile")
        self.device.rm(self.remoteProfile, force=True, recursive=True)

        self.message_logger = MessageLogger(logger=None)
        self.message_logger.logger = self.log

        # Check that Firefox is installed
        expected = options.app.split("/")[-1]
        if not self.device.is_app_installed(expected):
            raise Exception("%s is not installed on this device" % expected)

        self.device.clear_logcat()

        self.remoteModulesDir = posixpath.join(options.remoteTestRoot,
                                               "modules/")

        self.remoteCache = posixpath.join(options.remoteTestRoot, "cache/")
        self.device.rm(self.remoteCache, force=True, recursive=True)

        # move necko cache to a location that can be cleaned up
        options.extraPrefs += [
            "browser.cache.disk.parent_directory=%s" % self.remoteCache
        ]

        self.remoteMozLog = posixpath.join(options.remoteTestRoot, "mozlog")
        self.device.rm(self.remoteMozLog, force=True, recursive=True)
        self.device.mkdir(self.remoteMozLog, parents=True)

        self.remoteChromeTestDir = posixpath.join(options.remoteTestRoot,
                                                  "chrome")
        self.device.rm(self.remoteChromeTestDir, force=True, recursive=True)
        self.device.mkdir(self.remoteChromeTestDir, parents=True)

        self.appName = options.remoteappname
        self.device.stop_application(self.appName)
        if self.device.process_exist(self.appName):
            self.log.warning("unable to kill %s before running tests!" %
                             self.appName)

        # Add Android version (SDK level) to mozinfo so that manifest entries
        # can be conditional on android_version.
        self.log.info(
            "Android sdk version '%s'; will use this to filter manifests" %
            str(self.device.version))
        mozinfo.info["android_version"] = str(self.device.version)
        mozinfo.info["is_fennec"] = not ("geckoview" in options.app)
        mozinfo.info["is_emulator"] = self.device._device_serial.startswith(
            "emulator-")