Example #1
0
 def __init__(self, marionette, profile_data_dir):
     B2GMochitest.__init__(self,
                           marionette,
                           out_of_process=False,
                           profile_data_dir=profile_data_dir)
     Mochitest.__init__(self)
     self.certdbNew = True
Example #2
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 nspr logs and screenshots to %s." %
             blobberUploadDir)
         self.dm.getDirectory(self.remoteNSPR, blobberUploadDir)
         self.dm.getDirectory(self.remoteScreenshots, blobberUploadDir)
     Mochitest.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.remoteNSPR)
     self.dm.removeFile(self.remoteConfigFile)
     if self.dm.fileExists(self.remoteLog):
         self.dm.removeFile(self.remoteLog)
     self.log.debug("Cleanup complete.")
Example #3
0
 def __init__(self, automation, devmgr, options):
     self._automation = automation
     Mochitest.__init__(self, self._automation)
     self._dm = devmgr
     self.runSSLTunnel = False
     self.remoteProfile = options.remoteTestRoot + "/profile"
     self.remoteLog = options.remoteLogFile
 def __init__(self, automation, devmgr, options):
     self._automation = automation
     Mochitest.__init__(self, self._automation)
     self._dm = devmgr
     self.runSSLTunnel = False
     self.remoteProfile = options.remoteTestRoot + "/profile"
     self.remoteLog = options.remoteLogFile
Example #5
0
 def __init__(self, marionette_args, logger_options, profile_data_dir):
     B2GMochitest.__init__(self,
                           marionette_args,
                           logger_options,
                           out_of_process=False,
                           profile_data_dir=profile_data_dir)
     Mochitest.__init__(self, logger_options)
     self.certdbNew = True
Example #6
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)
     Mochitest.cleanup(self, options)
Example #7
0
 def cleanup(self, options):
     if self._dm.fileExists(self.remoteLog):
         self._dm.getFile(self.remoteLog, self.localLog)
         self._dm.removeFile(self.remoteLog)
     else:
         log.warning("Unable to retrieve log file (%s) from remote device" % self.remoteLog)
     self._dm.removeDir(self.remoteProfile)
     Mochitest.cleanup(self, options)
Example #8
0
 def __init__(self, marionette_args, logger_options, profile_data_dir):
     B2GMochitest.__init__(
         self,
         marionette_args,
         logger_options,
         out_of_process=False,
         profile_data_dir=profile_data_dir)
     Mochitest.__init__(self, logger_options)
     self.certdbNew = True
Example #9
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
     Mochitest.startServers(self,
                            options,
                            debuggerInfo,
                            ignoreSSLTunnelExts=True)
     restoreRemotePaths()
Example #10
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.getDirectory(self.remoteNSPR, os.environ["MOZ_UPLOAD_DIR"])
     Mochitest.cleanup(self, options)
Example #11
0
 def __init__(self, automation, devmgr, options):
     self._automation = automation
     Mochitest.__init__(self, self._automation)
     self._dm = devmgr
     self.runSSLTunnel = False
     self.remoteProfile = options.remoteTestRoot + '/profile'
     self._automation.setRemoteProfile(self.remoteProfile)
     self.remoteLog = options.remoteLogFile
     self.remoteProfilesIniPath = '/data/b2g/mozilla/profiles.ini'
     self.originalProfilesIni = None
Example #12
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
     Mochitest.startServers(
         self,
         options,
         debuggerInfo,
         ignoreSSLTunnelExts=True)
     restoreRemotePaths()
Example #13
0
 def __init__(self, automation, devmgr, options):
     self._automation = automation
     Mochitest.__init__(self)
     self._dm = devmgr
     self.runSSLTunnel = False
     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()
Example #14
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)
     blobberUploadDir = os.environ.get('MOZ_UPLOAD_DIR', None)
     if blobberUploadDir:
         self._dm.getDirectory(self.remoteNSPR, blobberUploadDir)
     Mochitest.cleanup(self, options)
Example #15
0
 def __init__(self, automation, devmgr, options):
     self._automation = automation
     Mochitest.__init__(self)
     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.certdbNew = True
Example #16
0
 def __init__(self, automation, devmgr, options):
     self._automation = automation
     Mochitest.__init__(self, self._automation)
     self._dm = devmgr
     self.runSSLTunnel = False
     self.remoteProfile = options.remoteTestRoot + '/profile'
     self._automation.setRemoteProfile(self.remoteProfile)
     self.remoteLog = options.remoteLogFile
     self.userJS = '/data/local/user.js'
     self.remoteMozillaPath = '/data/b2g/mozilla'
     self.remoteProfilesIniPath = os.path.join(self.remoteMozillaPath, 'profiles.ini')
     self.originalProfilesIni = None
Example #17
0
    def __init__(self, automation, OOP=True, profile_data_dir=None,
                    locations=os.path.join(here, 'server-locations.txt')):
        Mochitest.__init__(self, automation)
        self.OOP = OOP
        self.locations = locations
        self.preferences = []
        self.webapps = None

        if profile_data_dir:
            self.preferences = [os.path.join(profile_data_dir, f)
                                 for f in os.listdir(profile_data_dir) if f.startswith('pref')]
            self.webapps = [os.path.join(profile_data_dir, f)
                             for f in os.listdir(profile_data_dir) if f.startswith('webapp')]
Example #18
0
    def __init__(self, automation, OOP=True, profile_data_dir=None,
                    locations=os.path.join(here, 'server-locations.txt')):
        Mochitest.__init__(self, automation)
        self.OOP = OOP
        self.locations = locations
        self.preferences = []
        self.webapps = None

        if profile_data_dir:
            self.preferences = [os.path.join(profile_data_dir, f)
                                 for f in os.listdir(profile_data_dir) if f.startswith('pref')]
            self.webapps = [os.path.join(profile_data_dir, f)
                             for f in os.listdir(profile_data_dir) if f.startswith('webapp')]
Example #19
0
 def __init__(self, automation, devmgr, options):
     self._automation = automation
     Mochitest.__init__(self, self._automation)
     self._dm = devmgr
     self.runSSLTunnel = False
     self.remoteProfile = options.remoteTestRoot + '/profile'
     self._automation.setRemoteProfile(self.remoteProfile)
     self.remoteLog = options.remoteLogFile
     self.userJS = '/data/local/user.js'
     self.testDir = '/data/local/tests'
     self.remoteMozillaPath = '/data/b2g/mozilla'
     self.remoteProfilesIniPath = os.path.join(self.remoteMozillaPath, 'profiles.ini')
     self.originalProfilesIni = None
Example #20
0
    def __init__(self, marionette, devicemanager, profile_data_dir,
                 local_binary_dir, remote_test_root=None, remote_log_file=None):
        B2GMochitest.__init__(self, marionette, out_of_process=True, profile_data_dir=profile_data_dir)
        Mochitest.__init__(self)
        self._dm = devicemanager
        self.remote_test_root = remote_test_root or self._dm.getDeviceRoot()
        self.remote_profile = posixpath.join(self.remote_test_root, 'profile')
        self.remote_log = remote_log_file or posixpath.join(self.remote_test_root, 'log', 'mochitest.log')
        self.local_log = None
        self.local_binary_dir = local_binary_dir

        if not self._dm.dirExists(posixpath.dirname(self.remote_log)):
            self._dm.mkDirs(self.remote_log)
Example #21
0
    def __init__(self, automation, devmgr, options, message_logger=None):
        self._automation = automation
        Mochitest.__init__(self)
        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.certdbNew = True

        # structured logging
        self.message_logger = message_logger or MessageLogger(logger=log)
Example #22
0
 def __init__(self, automation, devmgr, options):
     self._automation = automation
     Mochitest.__init__(self, self._automation)
     self._dm = devmgr
     self.runSSLTunnel = False
     self.remoteProfile = options.remoteTestRoot + "/profile"
     self._automation.setRemoteProfile(self.remoteProfile)
     self.remoteLog = options.remoteLogFile
     self.localLog = None
     self.userJS = "/data/local/user.js"
     self.remoteMozillaPath = "/data/b2g/mozilla"
     self.bundlesDir = "/system/b2g/distribution/bundles"
     self.remoteProfilesIniPath = os.path.join(self.remoteMozillaPath, "profiles.ini")
     self.originalProfilesIni = None
Example #23
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)
     # Don't leave an old robotium.config hanging around; the
     # profile it references was just deleted!
     deviceRoot = self._dm.getDeviceRoot()
     self._dm.removeFile(os.path.join(deviceRoot, "robotium.config"))
     blobberUploadDir = os.environ.get("MOZ_UPLOAD_DIR", None)
     if blobberUploadDir:
         self._dm.getDirectory(self.remoteNSPR, blobberUploadDir)
     Mochitest.cleanup(self, options)
Example #24
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)
     # Don't leave an old robotium.config hanging around; the
     # profile it references was just deleted!
     deviceRoot = self._dm.getDeviceRoot()
     self._dm.removeFile(os.path.join(deviceRoot, "robotium.config"))
     blobberUploadDir = os.environ.get('MOZ_UPLOAD_DIR', None)
     if blobberUploadDir:
         self._dm.getDirectory(self.remoteNSPR, blobberUploadDir)
     Mochitest.cleanup(self, options)
Example #25
0
    def buildProfile(self, options):
        if self.localProfile:
            options.profilePath = self.localProfile
        manifest = Mochitest.buildProfile(self, options)
        self.localProfile = options.profilePath
        self._dm.removeDir(self.remoteProfile)

        # we do not need this for robotium based tests, lets save a LOT of time
        if options.robocop:
            shutil.rmtree(os.path.join(options.profilePath, 'webapps'))
            shutil.rmtree(os.path.join(options.profilePath, 'extensions', 'staged', '*****@*****.**'))
            shutil.rmtree(os.path.join(options.profilePath, 'extensions', 'staged', '*****@*****.**'))
            shutil.rmtree(os.path.join(options.profilePath, 'extensions', 'staged', '*****@*****.**'))
            shutil.rmtree(os.path.join(options.profilePath, 'extensions', 'staged', '*****@*****.**'))
            os.remove(os.path.join(options.profilePath, 'userChrome.css'))
            if os.path.exists(os.path.join(options.profilePath, 'tests.jar')):
                os.remove(os.path.join(options.profilePath, 'tests.jar'))
            if os.path.exists(os.path.join(options.profilePath, 'tests.manifest')):
                os.remove(os.path.join(options.profilePath, 'tests.manifest'))

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

        options.profilePath = self.remoteProfile
        return manifest
Example #26
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 = Mochitest.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
Example #27
0
    def buildProfile(self, options):
        if self.localProfile:
            options.profilePath = self.localProfile
        manifest = Mochitest.buildProfile(self, options)
        self.localProfile = options.profilePath
        self._dm.removeDir(self.remoteProfile)

        # we do not need this for robotium based tests, lets save a LOT of time
        if options.robocop:
            shutil.rmtree(os.path.join(options.profilePath, 'webapps'))
            shutil.rmtree(os.path.join(options.profilePath, 'extensions', 'staged', '*****@*****.**'))
            shutil.rmtree(os.path.join(options.profilePath, 'extensions', 'staged', '*****@*****.**'))
            shutil.rmtree(os.path.join(options.profilePath, 'extensions', 'staged', '*****@*****.**'))
            os.remove(os.path.join(options.profilePath, 'userChrome.css'))
            if os.path.exists(os.path.join(options.profilePath, 'tests.jar')):
                os.remove(os.path.join(options.profilePath, 'tests.jar'))
            if os.path.exists(os.path.join(options.profilePath, 'tests.manifest')):
                os.remove(os.path.join(options.profilePath, 'tests.manifest'))

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

        options.profilePath = self.remoteProfile
        return manifest
Example #28
0
    def buildURLOptions(self, options, env):
        self.localLog = options.logFile
        options.logFile = self.remoteLog
        options.profilePath = self.localProfile
        retVal = Mochitest.buildURLOptions(self, options, env)

        # set the testURL
        testURL = self.buildTestPath(options)
        if len(self.urlOpts) > 0:
            testURL += "?" + "&".join(self.urlOpts)
        self._automation.testURL = testURL

        # Set the B2G homepage as a static local page, since wi-fi generally
        # isn't available as soon as the device boots.
        f = open(os.path.join(options.profilePath, "user.js"), "a")
        f.write('user_pref("browser.homescreenURL", "data:text/html,mochitest-plain should start soon");\n')
        f.close()

        self._dm.removeDir(self.remoteProfile)
        if self._dm.pushDir(options.profilePath, self.remoteProfile) == None:
            raise devicemanager.FileError("Unable to copy profile to device.")

        self.updateProfilesIni(self.remoteProfile)

        options.profilePath = self.remoteProfile
        options.logFile = self.localLog
        return retVal
Example #29
0
 def buildBrowserEnv(self, options, debugger=False):
     browserEnv = Mochitest.buildBrowserEnv(self, options, debugger=debugger)
     # override nsprLogs to avoid processing in Mochitest base class
     self.nsprLogs = None
     browserEnv["NSPR_LOG_FILE"] = os.path.join(self.remoteNSPR, self.nsprLogName)
     self.buildRobotiumConfig(options, browserEnv)
     return browserEnv
Example #30
0
    def __init__(self, automation, devmgr, options):
        Mochitest.__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);
Example #31
0
    def buildProfile(self, options):
        restoreRemotePaths = self.switchToLocalPaths(options)
        manifest = Mochitest.buildProfile(self, options)
        self.localProfile = options.profilePath
        self._dm.removeDir(self.remoteProfile)

        # we do not need this for robotium based tests, lets save a LOT of time
        if options.robocopIni:
            shutil.rmtree(os.path.join(options.profilePath, 'webapps'))
            shutil.rmtree(
                os.path.join(options.profilePath, 'extensions', 'staged',
                             '*****@*****.**'))
            shutil.rmtree(
                os.path.join(options.profilePath, 'extensions', 'staged',
                             '*****@*****.**'))
            shutil.rmtree(
                os.path.join(options.profilePath, 'extensions', 'staged',
                             '*****@*****.**'))
            os.remove(os.path.join(options.profilePath, 'userChrome.css'))

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

        restoreRemotePaths()
        options.profilePath = self.remoteProfile
        return manifest
Example #32
0
    def buildProfile(self, options):
        manifest = Mochitest.buildProfile(self, options)
        self.localProfile = options.profilePath
        if self._dm.pushDir(options.profilePath, self.remoteProfile) == None:
            raise devicemanager.FileError("Unable to copy profile to device.")

        options.profilePath = self.remoteProfile
        return manifest
    def buildProfile(self, options):
        manifest = Mochitest.buildProfile(self, options)
        self.localProfile = options.profilePath
        if self._dm.pushDir(options.profilePath, self.remoteProfile) == None:
            raise devicemanager.FileError("Unable to copy profile to device.")

        options.profilePath = self.remoteProfile
        return manifest
Example #34
0
    def buildURLOptions(self, options, env):
        self.localLog = options.logFile
        options.logFile = self.remoteLog
        options.profilePath = self.localProfile
        retVal = Mochitest.buildURLOptions(self, options, env)

        # set the testURL
        testURL = self.buildTestPath(options)
        if len(self.urlOpts) > 0:
            testURL += "?" + "&".join(self.urlOpts)
        self._automation.testURL = testURL

        # Set extra prefs for B2G.
        f = open(os.path.join(options.profilePath, "user.js"), "a")
        f.write(
            """
user_pref("browser.homescreenURL","app://system.gaiamobile.org");\n
user_pref("dom.mozBrowserFramesEnabled", true);\n
user_pref("dom.ipc.tabs.disabled", false);\n
user_pref("dom.ipc.browser_frames.oop_by_default", true);\n
user_pref("browser.manifestURL","app://system.gaiamobile.org/manifest.webapp");\n
user_pref("dom.mozBrowserFramesWhitelist","app://system.gaiamobile.org,http://mochi.test:8888");\n
user_pref("network.dns.localDomains","app://system.gaiamobile.org");\n
"""
        )
        f.close()

        # Copy the profile to the device.
        self._dm._checkCmdAs(["shell", "rm", "-r", self.remoteProfile])
        try:
            self._dm.pushDir(options.profilePath, self.remoteProfile)
        except devicemanager.DMError:
            print "Automation Error: Unable to copy profile to device."
            raise

        # Copy the extensions to the B2G bundles dir.
        extensionDir = os.path.join(options.profilePath, "extensions", "staged")
        # need to write to read-only dir
        self._dm._checkCmdAs(["remount"])
        for filename in os.listdir(extensionDir):
            self._dm._checkCmdAs(["shell", "rm", "-rf", os.path.join(self.bundlesDir, filename)])
        try:
            self._dm.pushDir(extensionDir, self.bundlesDir)
        except devicemanager.DMError:
            print "Automation Error: Unable to copy extensions to device."
            raise

        # In B2G, user.js is always read from /data/local, not the profile
        # directory.  Backup the original user.js first so we can restore it.
        if not self._dm.fileExists("%s.orig" % self.userJS):
            self.copyRemoteFile(self.userJS, "%s.orig" % self.userJS)
        self._dm.pushFile(os.path.join(options.profilePath, "user.js"), self.userJS)
        self.updateProfilesIni(self.remoteProfile)
        options.profilePath = self.remoteProfile
        options.logFile = self.localLog
        return retVal
Example #35
0
    def buildProfile(self, options):
        if self.localProfile:
            options.profilePath = self.localProfile
        manifest = Mochitest.buildProfile(self, options)
        self.localProfile = options.profilePath

        # Profile isn't actually copied to device until
        # buildURLOptions is called.

        options.profilePath = self.remoteProfile
        return manifest
    def buildProfile(self, options):
        if self.localProfile:
            options.profilePath = self.localProfile
        manifest = Mochitest.buildProfile(self, options)
        self.localProfile = options.profilePath

        # Profile isn't actually copied to device until
        # buildURLOptions is called.

        options.profilePath = self.remoteProfile
        return manifest
    def buildURLOptions(self, options):
        self.localLog = options.logFile
        options.logFile = self.remoteLog
        options.profilePath = self.localProfile
        retVal = Mochitest.buildURLOptions(self, options)
        #we really need testConfig.js (for browser chrome)
        if self._dm.pushDir(options.profilePath, self.remoteProfile) == None:
            raise devicemanager.FileError("Unable to copy profile to device.")

        options.profilePath = self.remoteProfile
        options.logFile = self.localLog
        return retVal
    def buildURLOptions(self, options, env):
        self.localLog = options.logFile
        options.logFile = self.remoteLog
        options.profilePath = self.localProfile
        retVal = Mochitest.buildURLOptions(self, options, env)
        #we really need testConfig.js (for browser chrome)
        if self._dm.pushDir(options.profilePath, self.remoteProfile) == None:
            raise devicemanager.FileError("Unable to copy profile to device.")

        options.profilePath = self.remoteProfile
        options.logFile = self.localLog
        return retVal
Example #39
0
    def buildProfile(self, options):
        if self.localProfile:
            options.profilePath = self.localProfile
        manifest = Mochitest.buildProfile(self, options)
        self.localProfile = options.profilePath
        self._dm.removeDir(self.remoteProfile)
        try:
            self._dm.pushDir(options.profilePath, self.remoteProfile)
        except devicemanager.DMError:
            print "Automation Error: Unable to copy profile to device."
            raise

        options.profilePath = self.remoteProfile
        return manifest
Example #40
0
 def buildBrowserEnv(self, options, debugger=False):
     browserEnv = Mochitest.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 Mochitest base class
     self.nsprLogs = None
     browserEnv["NSPR_LOG_FILE"] = os.path.join(self.remoteNSPR,
                                                self.nsprLogName)
     return browserEnv
    def buildProfile(self, options):
        if self.localProfile:
            options.profilePath = self.localProfile
        manifest = Mochitest.buildProfile(self, options)
        self.localProfile = options.profilePath
        self._dm.removeDir(self.remoteProfile)
        try:
            self._dm.pushDir(options.profilePath, self.remoteProfile)
        except devicemanager.DMError:
            print "Automation Error: Unable to copy profile to device."
            raise

        options.profilePath = self.remoteProfile
        return manifest
Example #42
0
    def buildURLOptions(self, options, env):
        retVal = Mochitest.buildURLOptions(self, options, env)

        self.setupCommonOptions(options, OOP=False)

        # Copy the extensions to the B2G bundles dir.
        extensionDir = os.path.join(options.profilePath, "extensions", "staged")
        bundlesDir = os.path.join(os.path.dirname(options.app), "distribution", "bundles")

        for filename in os.listdir(extensionDir):
            shutil.rmtree(os.path.join(bundlesDir, filename), True)
            shutil.copytree(os.path.join(extensionDir, filename), os.path.join(bundlesDir, filename))

        return retVal
Example #43
0
    def __init__(self, automation, devmgr, options):
        """
           Simple one-time initialization.
        """
        Mochitest.__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.remoteNSPR = os.path.join(options.remoteTestRoot, "nspr")
        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
Example #44
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 nspr logs and screenshots to %s." %
                        blobberUploadDir)
         self.dm.getDirectory(self.remoteNSPR, blobberUploadDir)
         self.dm.getDirectory(self.remoteScreenshots, blobberUploadDir)
     Mochitest.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.remoteNSPR)
     self.dm.removeFile(self.remoteConfigFile)
     if self.dm.fileExists(self.remoteLog):
         self.dm.removeFile(self.remoteLog)
     self.log.debug("Cleanup complete.")
Example #45
0
    def buildURLOptions(self, options, env):
        self.localLog = options.logFile
        options.logFile = self.remoteLog
        options.profilePath = self.localProfile
        retVal = Mochitest.buildURLOptions(self, options, env)
        #we really need testConfig.js (for browser chrome)
        try:
            self._dm.pushDir(options.profilePath, self.remoteProfile)
        except devicemanager.DMError:
            print "Automation Error: Unable to copy profile to device."
            raise

        options.profilePath = self.remoteProfile
        options.logFile = self.localLog
        return retVal
    def buildURLOptions(self, options, env):
        self.localLog = options.logFile
        options.logFile = self.remoteLog
        options.profilePath = self.localProfile
        retVal = Mochitest.buildURLOptions(self, options, env)
        #we really need testConfig.js (for browser chrome)
        try:
            self._dm.pushDir(options.profilePath, self.remoteProfile)
        except devicemanager.DMError:
            print "Automation Error: Unable to copy profile to device."
            raise

        options.profilePath = self.remoteProfile
        options.logFile = self.localLog
        return retVal
Example #47
0
    def buildURLOptions(self, options, env):
        retVal = Mochitest.buildURLOptions(self, options, env)

        self.setupCommonOptions(options, OOP=False)

        # Copy the extensions to the B2G bundles dir.
        extensionDir = os.path.join(options.profilePath, 'extensions', 'staged')
        bundlesDir = os.path.join(os.path.dirname(options.app),
                                  'distribution', 'bundles')

        for filename in os.listdir(extensionDir):
            shutil.rmtree(os.path.join(bundlesDir, filename), True)
            shutil.copytree(os.path.join(extensionDir, filename),
                            os.path.join(bundlesDir, filename))

        return retVal
Example #48
0
    def buildProfile(self, options):
        restoreRemotePaths = self.switchToLocalPaths(options)
        manifest = Mochitest.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
Example #49
0
    def buildProfile(self, options):
        restoreRemotePaths = self.switchToLocalPaths(options)
        manifest = Mochitest.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
Example #50
0
 def buildBrowserEnv(self, options, debugger=False):
     browserEnv = Mochitest.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 Mochitest base class
     self.nsprLogs = None
     browserEnv["NSPR_LOG_FILE"] = os.path.join(
         self.remoteNSPR,
         self.nsprLogName)
     return browserEnv
Example #51
0
    def buildURLOptions(self, options, env):
        self.localLog = options.logFile
        options.logFile = self.remoteLog
        options.profilePath = self.localProfile
        retVal = Mochitest.buildURLOptions(self, options, env)

        # set the testURL
        testURL = self.buildTestPath(options)
        if len(self.urlOpts) > 0:
            testURL += "?" + "&".join(self.urlOpts)
        self._automation.testURL = testURL

        # Set the B2G homepage as a static local page, since wi-fi generally
        # isn't available as soon as the device boots.
        f = open(os.path.join(options.profilePath, "user.js"), "a")
        f.write(
            'user_pref("browser.homescreenURL", "data:text/html,<h1>mochitest-plain should start soon</h1>");\n'
        )
        f.close()

        # Copy the profile to the device.
        self._dm.removeDir(self.remoteProfile)
        if self._dm.pushDir(options.profilePath, self.remoteProfile) == None:
            raise devicemanager.FileError("Unable to copy profile to device.")

        # In B2G, user.js is always read from /data/local, not the profile
        # directory.  Backup the original user.js first so we can restore it.
        self._dm.checkCmdAs(['shell', 'rm', '-f', '%s.orig' % self.userJS])
        if self._dm.useDDCopy:
            self._dm.checkCmdAs([
                'shell', 'dd',
                'if=%s' % self.userJS,
                'of=%s.orig' % self.userJS
            ])
        else:
            self._dm.checkCmdAs(
                ['shell', 'cp', self.userJS,
                 '%s.orig' % self.userJS])
        self._dm.pushFile(os.path.join(options.profilePath, "user.js"),
                          self.userJS)

        self.updateProfilesIni(self.remoteProfile)

        options.profilePath = self.remoteProfile
        options.logFile = self.localLog
        return retVal
Example #52
0
    def buildURLOptions(self, options, env):
        self.localLog = options.logFile
        options.logFile = self.remoteLog
        options.profilePath = self.localProfile
        env["MOZ_HIDE_RESULTS_TABLE"] = "1"
        retVal = Mochitest.buildURLOptions(self, options, env)

        if not options.robocopIni:
            #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
Example #53
0
    def buildURLOptions(self, options, env):
        self.localLog = options.logFile
        options.logFile = self.remoteLog
        options.profilePath = self.localProfile
        retVal = Mochitest.buildURLOptions(self, options, env)

        # set the testURL
        testURL = self.buildTestPath(options)
        if len(self.urlOpts) > 0:
            testURL += "?" + "&".join(self.urlOpts)
        self._automation.testURL = testURL

        # Set extra prefs for B2G.
        f = open(os.path.join(options.profilePath, "user.js"), "a")
        f.write("""
user_pref("browser.homescreenURL","app://system.gaiamobile.org");\n
user_pref("dom.mozBrowserFramesEnabled", true);\n
user_pref("dom.ipc.tabs.disabled", false);\n
user_pref("dom.ipc.browser_frames.oop_by_default", true);\n
user_pref("browser.manifestURL","app://system.gaiamobile.org/manifest.webapp");\n
user_pref("dom.mozBrowserFramesWhitelist","app://system.gaiamobile.org,http://mochi.test:8888");\n
user_pref("network.dns.localDomains","app://system.gaiamobile.org");\n
""")
        f.close()

        # Copy the profile to the device.
        self._dm._checkCmdAs(['shell', 'rm', '-r', self.remoteProfile])
        try:
            self._dm.pushDir(options.profilePath, self.remoteProfile)
        except devicemanager.DMError:
            print "Automation Error: Unable to copy profile to device."
            raise

        # In B2G, user.js is always read from /data/local, not the profile
        # directory.  Backup the original user.js first so we can restore it.
        if not self._dm.fileExists('%s.orig' % self.userJS):
            self.copyRemoteFile(self.userJS, '%s.orig' % self.userJS)
        self._dm.pushFile(os.path.join(options.profilePath, "user.js"),
                          self.userJS)
        self.updateProfilesIni(self.remoteProfile)
        options.profilePath = self.remoteProfile
        options.logFile = self.localLog
        return retVal