# 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/.
# Check that Firefox is installed
expected = options.app.split("/")[-1] ifnot self.device.is_app_installed(expected): raise Exception("%s is not installed on this device" % expected)
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_emulator"] = self.device._device_serial.startswith("emulator-")
def dumpScreen(self, utilityPath): if self.haveDumpedScreen:
self.log.info( "Not taking screenshot here: see the one that was previously logged"
) return
self.haveDumpedScreen = True if self.device._device_serial.startswith("emulator-"):
dump_screen(utilityPath, self.log) else:
dump_device_screen(self.device, self.log)
def findPath(self, paths, filename=None): for path in paths:
p = path if filename:
p = os.path.join(p, filename) if os.path.exists(self.getFullPath(p)): return path returnNone
# This seems kludgy, but this class uses paths from the remote host in the # options, except when calling up to the base class, which doesn't # understand the distinction. This switches out the remote values for local # ones that the base class understands. This is necessary for the web # server, SSL tunnel and profile building functions. def switchToLocalPaths(self, options): """Set local paths in the options, return a function that will restore remote values"""
remoteXrePath = options.xrePath
remoteProfilePath = options.profilePath
remoteUtilityPath = options.utilityPath
paths = [
options.xrePath,
] if build_obj:
paths.append(os.path.join(build_obj.topobjdir, "dist", "bin"))
options.xrePath = self.findPath(paths) if options.xrePath isNone:
self.log.error( "unable to find xulrunner path for %s, please specify with --xre-path"
% os.name
)
sys.exit(1)
xpcshell = "xpcshell" if os.name == "nt":
xpcshell += ".exe"
if options.utilityPath isNone:
self.log.error( "unable to find utility path for %s, please specify with --utility-path"
% os.name
)
sys.exit(1)
xpcshell_path = os.path.join(options.utilityPath, xpcshell) if RemoteProcessMonitor.elf_arm(xpcshell_path):
self.log.error( "xpcshell at %s is an ARM binary; please use " "the --utility-path argument to specify the path " "to a desktop version." % xpcshell_path
)
sys.exit(1)
if self.localProfile:
options.profilePath = self.localProfile else:
options.profilePath = None
def startServers(self, options, debuggerInfo, public=None): """Create the servers on the host and start them up"""
restoreRemotePaths = self.switchToLocalPaths(options)
MochitestDesktop.startServers(self, options, debuggerInfo, public=True)
restoreRemotePaths()
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) 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
def environment(self, env=None, crashreporter=True, **kwargs): # Since running remote, do not mimic the local env: do not copy os.environ if env isNone:
env = {}
# Crash on non-local network connections by default. # MOZ_DISABLE_NONLOCAL_CONNECTIONS can be set to "0" to temporarily # enable non-local connections for the purposes of local testing. # Don't override the user's choice here. See bug 1049688.
env.setdefault("MOZ_DISABLE_NONLOCAL_CONNECTIONS", "1")
# Send an env var noting that we are in automation. Passing any # value except the empty string will declare the value to exist. # # This may be used to disabled network connections during testing, e.g. # Switchboard & telemetry uploads.
env.setdefault("MOZ_IN_AUTOMATION", "1")
# Set WebRTC logging in case it is not set yet.
env.setdefault("R_LOG_LEVEL", "6")
env.setdefault("R_LOG_DESTINATION", "stderr")
env.setdefault("R_LOG_VERBOSE", "1")
return env
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
def runApp(
self,
testUrl,
env,
app,
profile,
extraArgs,
utilityPath,
debuggerInfo=None,
valgrindPath=None,
valgrindArgs=None,
valgrindSuppFiles=None,
symbolsPath=None,
timeout=-1,
detectShutdownLeaks=False,
screenshotOnFail=False,
bisectChunk=None,
restartAfterFailure=False,
marionette_args=None,
e10s=True,
runFailures=False,
crashAsPass=False,
currentManifest=None,
): """
Run the app, log the duration it took to execute, return the status code.
Kill the app if it outputs nothing for |timeout| seconds. """
# TODO: not using runFailures or crashAsPass, if we choose to use them # we need to adjust status and check_for_crashes
self.log.info("runtestsremote.py | Application pid: %d" % pid) ifnot rpm.wait(timeout):
status = 1
self.log.info( "runtestsremote.py | Application ran for: %s"
% str(datetime.datetime.now() - startTime)
)
lastTestSeen = currentManifest or"Main app process exited normally"
crashed = self.check_for_crashes(symbolsPath, lastTestSeen) if crashed:
status = 1
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.