2012-05-21 15:12:37 +04:00
|
|
|
# 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/.
|
2010-03-24 20:51:17 +03:00
|
|
|
|
2017-04-13 23:33:42 +03:00
|
|
|
from contextlib import closing
|
2010-03-16 01:35:59 +03:00
|
|
|
import sys
|
2017-04-11 18:21:37 +03:00
|
|
|
import logging
|
2010-03-16 01:35:59 +03:00
|
|
|
import os
|
|
|
|
import time
|
2010-06-24 13:32:01 +04:00
|
|
|
import tempfile
|
2012-11-05 17:03:54 +04:00
|
|
|
import traceback
|
2016-02-10 00:19:44 +03:00
|
|
|
import urllib2
|
2010-03-16 01:35:59 +03:00
|
|
|
|
2016-02-10 00:19:44 +03:00
|
|
|
import mozdevice
|
2015-07-16 15:20:08 +03:00
|
|
|
import mozinfo
|
2016-02-05 23:44:20 +03:00
|
|
|
from automation import Automation
|
2012-11-13 01:57:13 +04:00
|
|
|
from remoteautomation import RemoteAutomation, fennecLogcatFilters
|
2010-03-16 01:35:59 +03:00
|
|
|
|
2016-02-05 23:44:20 +03:00
|
|
|
from output import OutputHandler
|
|
|
|
from runreftest import RefTest, ReftestResolver
|
2015-08-25 16:07:23 +03:00
|
|
|
import reftestcommandline
|
2010-03-16 01:35:59 +03:00
|
|
|
|
2016-02-05 23:44:20 +03:00
|
|
|
# We need to know our current directory so that we can serve our test files from it.
|
|
|
|
SCRIPT_DIRECTORY = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
|
|
|
|
|
|
|
|
|
2015-08-25 16:07:23 +03:00
|
|
|
class RemoteReftestResolver(ReftestResolver):
|
|
|
|
def absManifestPath(self, path):
|
|
|
|
script_abs_path = os.path.join(SCRIPT_DIRECTORY, path)
|
|
|
|
if os.path.exists(script_abs_path):
|
|
|
|
rv = script_abs_path
|
|
|
|
elif os.path.exists(os.path.abspath(path)):
|
|
|
|
rv = os.path.abspath(path)
|
2010-07-27 05:43:34 +04:00
|
|
|
else:
|
2015-08-25 16:07:23 +03:00
|
|
|
print >> sys.stderr, "Could not find manifest %s" % script_abs_path
|
|
|
|
sys.exit(1)
|
|
|
|
return os.path.normpath(rv)
|
2011-04-20 02:17:01 +04:00
|
|
|
|
2015-08-25 16:07:23 +03:00
|
|
|
def manifestURL(self, options, path):
|
2017-02-14 22:50:56 +03:00
|
|
|
# Dynamically build the reftest URL if possible, beware that args[0] should exist 'inside'
|
|
|
|
# webroot. It's possible for this url to have a leading "..", but reftest.js will fix that
|
2015-08-25 16:07:23 +03:00
|
|
|
relPath = os.path.relpath(path, SCRIPT_DIRECTORY)
|
|
|
|
return "http://%s:%s/%s" % (options.remoteWebServer, options.httpPort, relPath)
|
2013-06-27 07:42:46 +04:00
|
|
|
|
2010-06-24 13:32:01 +04:00
|
|
|
|
2010-06-24 13:32:01 +04:00
|
|
|
class ReftestServer:
|
|
|
|
""" Web server used to serve Reftests, for closer fidelity to the real web.
|
|
|
|
It is virtually identical to the server used in mochitest and will only
|
|
|
|
be used for running reftests remotely.
|
2010-07-27 05:43:34 +04:00
|
|
|
Bug 581257 has been filed to refactor this wrapper around httpd.js into
|
2010-06-24 13:32:01 +04:00
|
|
|
it's own class and use it in both remote and non-remote testing. """
|
|
|
|
|
2010-09-18 04:18:06 +04:00
|
|
|
def __init__(self, automation, options, scriptDir):
|
2014-01-24 19:34:01 +04:00
|
|
|
self.automation = automation
|
2010-06-24 13:32:01 +04:00
|
|
|
self._utilityPath = options.utilityPath
|
|
|
|
self._xrePath = options.xrePath
|
|
|
|
self._profileDir = options.serverProfilePath
|
|
|
|
self.webServer = options.remoteWebServer
|
|
|
|
self.httpPort = options.httpPort
|
2010-09-18 04:18:06 +04:00
|
|
|
self.scriptDir = scriptDir
|
2011-05-12 20:47:38 +04:00
|
|
|
self.pidFile = options.pidFile
|
2013-06-29 06:20:08 +04:00
|
|
|
self._httpdPath = os.path.abspath(options.httpdPath)
|
2017-04-13 23:33:42 +03:00
|
|
|
if options.remoteWebServer == "10.0.2.2":
|
|
|
|
# probably running an Android emulator and 10.0.2.2 will
|
|
|
|
# not be visible from host
|
|
|
|
shutdownServer = "127.0.0.1"
|
|
|
|
else:
|
|
|
|
shutdownServer = self.webServer
|
2017-02-14 22:50:56 +03:00
|
|
|
self.shutdownURL = "http://%(server)s:%(port)s/server/shutdown" % {
|
2017-04-13 23:33:42 +03:00
|
|
|
"server": shutdownServer, "port": self.httpPort}
|
2010-06-24 13:32:01 +04:00
|
|
|
|
|
|
|
def start(self):
|
|
|
|
"Run the Refest server, returning the process ID of the server."
|
2012-08-10 22:25:20 +04:00
|
|
|
|
2017-02-14 22:50:56 +03:00
|
|
|
env = self.automation.environment(xrePath=self._xrePath)
|
2010-06-24 13:32:01 +04:00
|
|
|
env["XPCOM_DEBUG_BREAK"] = "warn"
|
2014-01-24 19:34:01 +04:00
|
|
|
if self.automation.IS_WIN32:
|
2010-06-24 13:32:01 +04:00
|
|
|
env["PATH"] = env["PATH"] + ";" + self._xrePath
|
|
|
|
|
|
|
|
args = ["-g", self._xrePath,
|
|
|
|
"-v", "170",
|
2013-06-27 07:42:46 +04:00
|
|
|
"-f", os.path.join(self._httpdPath, "httpd.js"),
|
2017-02-14 22:50:56 +03:00
|
|
|
"-e", "const _PROFILE_PATH = '%(profile)s';const _SERVER_PORT = "
|
|
|
|
"'%(port)s'; const _SERVER_ADDR ='%(server)s';" % {
|
|
|
|
"profile": self._profileDir.replace('\\', '\\\\'), "port": self.httpPort,
|
|
|
|
"server": self.webServer},
|
2010-09-18 04:18:06 +04:00
|
|
|
"-f", os.path.join(self.scriptDir, "server.js")]
|
2010-06-24 13:32:01 +04:00
|
|
|
|
|
|
|
xpcshell = os.path.join(self._utilityPath,
|
2014-01-24 19:34:01 +04:00
|
|
|
"xpcshell" + self.automation.BIN_SUFFIX)
|
2013-01-04 05:37:26 +04:00
|
|
|
|
|
|
|
if not os.access(xpcshell, os.F_OK):
|
|
|
|
raise Exception('xpcshell not found at %s' % xpcshell)
|
2014-01-24 19:34:01 +04:00
|
|
|
if self.automation.elf_arm(xpcshell):
|
2013-01-04 05:37:26 +04:00
|
|
|
raise Exception('xpcshell at %s is an ARM binary; please use '
|
|
|
|
'the --utility-path argument to specify the path '
|
|
|
|
'to a desktop version.' % xpcshell)
|
|
|
|
|
2017-02-14 22:50:56 +03:00
|
|
|
self._process = self.automation.Process([xpcshell] + args, env=env)
|
2010-06-24 13:32:01 +04:00
|
|
|
pid = self._process.pid
|
|
|
|
if pid < 0:
|
2013-09-19 16:20:17 +04:00
|
|
|
print "TEST-UNEXPECTED-FAIL | remotereftests.py | Error starting server."
|
2012-06-13 22:20:43 +04:00
|
|
|
return 2
|
2014-01-24 19:34:01 +04:00
|
|
|
self.automation.log.info("INFO | remotereftests.py | Server pid: %d", pid)
|
2010-06-24 13:32:01 +04:00
|
|
|
|
2011-05-12 20:47:38 +04:00
|
|
|
if (self.pidFile != ""):
|
|
|
|
f = open(self.pidFile + ".xpcshell.pid", 'w')
|
|
|
|
f.write("%s" % pid)
|
|
|
|
f.close()
|
|
|
|
|
2010-06-24 13:32:01 +04:00
|
|
|
def ensureReady(self, timeout):
|
|
|
|
assert timeout >= 0
|
|
|
|
|
|
|
|
aliveFile = os.path.join(self._profileDir, "server_alive.txt")
|
|
|
|
i = 0
|
|
|
|
while i < timeout:
|
|
|
|
if os.path.exists(aliveFile):
|
|
|
|
break
|
|
|
|
time.sleep(1)
|
|
|
|
i += 1
|
|
|
|
else:
|
2017-02-14 22:50:56 +03:00
|
|
|
print ("TEST-UNEXPECTED-FAIL | remotereftests.py | "
|
|
|
|
"Timed out while waiting for server startup.")
|
2010-06-24 13:32:01 +04:00
|
|
|
self.stop()
|
2012-06-13 22:20:43 +04:00
|
|
|
return 1
|
2010-06-24 13:32:01 +04:00
|
|
|
|
|
|
|
def stop(self):
|
2012-08-10 22:25:20 +04:00
|
|
|
if hasattr(self, '_process'):
|
|
|
|
try:
|
2017-04-13 23:33:42 +03:00
|
|
|
with closing(urllib2.urlopen(self.shutdownURL)) as c:
|
|
|
|
c.read()
|
2010-06-24 13:32:01 +04:00
|
|
|
|
2012-08-10 22:25:20 +04:00
|
|
|
rtncode = self._process.poll()
|
2017-02-14 22:50:56 +03:00
|
|
|
if (rtncode is None):
|
2012-08-10 22:25:20 +04:00
|
|
|
self._process.terminate()
|
|
|
|
except:
|
2017-04-13 23:33:42 +03:00
|
|
|
self.automation.log.info("Failed to shutdown server at %s" %
|
|
|
|
self.shutdownURL)
|
|
|
|
traceback.print_exc()
|
2012-08-10 22:25:20 +04:00
|
|
|
self._process.kill()
|
2010-06-24 13:32:01 +04:00
|
|
|
|
2017-02-14 22:50:56 +03:00
|
|
|
|
2010-03-16 01:35:59 +03:00
|
|
|
class RemoteReftest(RefTest):
|
2016-03-09 22:38:13 +03:00
|
|
|
use_marionette = False
|
2010-03-16 01:35:59 +03:00
|
|
|
remoteApp = ''
|
2015-08-25 16:07:23 +03:00
|
|
|
resolver_cls = RemoteReftestResolver
|
2010-03-16 01:35:59 +03:00
|
|
|
|
|
|
|
def __init__(self, automation, devicemanager, options, scriptDir):
|
2014-07-29 19:47:50 +04:00
|
|
|
RefTest.__init__(self)
|
|
|
|
self.automation = automation
|
2010-03-16 01:35:59 +03:00
|
|
|
self._devicemanager = devicemanager
|
|
|
|
self.scriptDir = scriptDir
|
|
|
|
self.remoteApp = options.app
|
2010-06-24 13:32:01 +04:00
|
|
|
self.remoteProfile = options.remoteProfile
|
2010-06-24 13:32:01 +04:00
|
|
|
self.remoteTestRoot = options.remoteTestRoot
|
2010-07-27 05:43:34 +04:00
|
|
|
self.remoteLogFile = options.remoteLogFile
|
|
|
|
self.localLogName = options.localLogName
|
2011-04-20 02:17:01 +04:00
|
|
|
self.pidFile = options.pidFile
|
2010-06-24 13:32:01 +04:00
|
|
|
if self.automation.IS_DEBUG_BUILD:
|
|
|
|
self.SERVER_STARTUP_TIMEOUT = 180
|
|
|
|
else:
|
|
|
|
self.SERVER_STARTUP_TIMEOUT = 90
|
2013-05-17 00:32:52 +04:00
|
|
|
self.automation.deleteANRs()
|
2014-08-11 21:55:28 +04:00
|
|
|
self.automation.deleteTombstones()
|
2010-06-24 13:32:01 +04:00
|
|
|
|
2016-02-05 23:44:20 +03:00
|
|
|
self._populate_logger(options)
|
|
|
|
outputHandler = OutputHandler(self.log, options.utilityPath, options.symbolsPath)
|
|
|
|
# RemoteAutomation.py's 'messageLogger' is also used by mochitest. Mimic a mochitest
|
|
|
|
# MessageLogger object to re-use this code path.
|
|
|
|
outputHandler.write = outputHandler.__call__
|
|
|
|
self.automation._processArgs['messageLogger'] = outputHandler
|
|
|
|
|
2017-02-14 22:50:56 +03:00
|
|
|
def findPath(self, paths, filename=None):
|
2010-06-24 13:32:01 +04:00
|
|
|
for path in paths:
|
|
|
|
p = path
|
|
|
|
if filename:
|
|
|
|
p = os.path.join(p, filename)
|
|
|
|
if os.path.exists(self.getFullPath(p)):
|
|
|
|
return path
|
|
|
|
return None
|
|
|
|
|
|
|
|
def startWebServer(self, options):
|
|
|
|
""" Create the webserver on the host and start it up """
|
|
|
|
remoteXrePath = options.xrePath
|
|
|
|
remoteUtilityPath = options.utilityPath
|
|
|
|
localAutomation = Automation()
|
2011-02-24 22:45:42 +03:00
|
|
|
localAutomation.IS_WIN32 = False
|
|
|
|
localAutomation.IS_LINUX = False
|
|
|
|
localAutomation.IS_MAC = False
|
|
|
|
localAutomation.UNIXISH = False
|
|
|
|
hostos = sys.platform
|
2017-02-14 22:50:56 +03:00
|
|
|
if (hostos == 'mac' or hostos == 'darwin'):
|
2011-12-21 01:33:41 +04:00
|
|
|
localAutomation.IS_MAC = True
|
2011-02-24 22:45:42 +03:00
|
|
|
elif (hostos == 'linux' or hostos == 'linux2'):
|
2011-12-21 01:33:41 +04:00
|
|
|
localAutomation.IS_LINUX = True
|
|
|
|
localAutomation.UNIXISH = True
|
2011-02-24 22:45:42 +03:00
|
|
|
elif (hostos == 'win32' or hostos == 'win64'):
|
2011-12-21 01:33:41 +04:00
|
|
|
localAutomation.BIN_SUFFIX = ".exe"
|
|
|
|
localAutomation.IS_WIN32 = True
|
2010-06-24 13:32:01 +04:00
|
|
|
|
2017-02-14 22:50:56 +03:00
|
|
|
paths = [options.xrePath, localAutomation.DIST_BIN, self.automation._product,
|
|
|
|
os.path.join('..', self.automation._product)]
|
2010-06-24 13:32:01 +04:00
|
|
|
options.xrePath = self.findPath(paths)
|
2017-02-14 22:50:56 +03:00
|
|
|
if options.xrePath is None:
|
|
|
|
print ("ERROR: unable to find xulrunner path for %s, "
|
|
|
|
"please specify with --xre-path" % (os.name))
|
2012-06-13 22:20:43 +04:00
|
|
|
return 1
|
2010-06-24 13:32:01 +04:00
|
|
|
paths.append("bin")
|
|
|
|
paths.append(os.path.join("..", "bin"))
|
|
|
|
|
|
|
|
xpcshell = "xpcshell"
|
|
|
|
if (os.name == "nt"):
|
|
|
|
xpcshell += ".exe"
|
2012-08-10 22:25:20 +04:00
|
|
|
|
2010-06-24 13:32:01 +04:00
|
|
|
if (options.utilityPath):
|
|
|
|
paths.insert(0, options.utilityPath)
|
|
|
|
options.utilityPath = self.findPath(paths, xpcshell)
|
2017-02-14 22:50:56 +03:00
|
|
|
if options.utilityPath is None:
|
|
|
|
print ("ERROR: unable to find utility path for %s, "
|
|
|
|
"please specify with --utility-path" % (os.name))
|
2012-06-13 22:20:43 +04:00
|
|
|
return 1
|
2010-06-24 13:32:01 +04:00
|
|
|
|
|
|
|
options.serverProfilePath = tempfile.mkdtemp()
|
2010-09-18 04:18:06 +04:00
|
|
|
self.server = ReftestServer(localAutomation, options, self.scriptDir)
|
2012-06-13 22:20:43 +04:00
|
|
|
retVal = self.server.start()
|
|
|
|
if retVal:
|
|
|
|
return retVal
|
|
|
|
retVal = self.server.ensureReady(self.SERVER_STARTUP_TIMEOUT)
|
|
|
|
if retVal:
|
|
|
|
return retVal
|
2010-06-24 13:32:01 +04:00
|
|
|
|
|
|
|
options.xrePath = remoteXrePath
|
|
|
|
options.utilityPath = remoteUtilityPath
|
2012-06-13 22:20:43 +04:00
|
|
|
return 0
|
2012-08-10 22:25:20 +04:00
|
|
|
|
2010-06-24 13:32:01 +04:00
|
|
|
def stopWebServer(self, options):
|
|
|
|
self.server.stop()
|
2010-03-16 01:35:59 +03:00
|
|
|
|
2017-04-13 10:47:01 +03:00
|
|
|
def createReftestProfile(self, options, manifest):
|
2015-08-25 16:07:23 +03:00
|
|
|
profile = RefTest.createReftestProfile(self,
|
|
|
|
options,
|
|
|
|
manifest,
|
|
|
|
server=options.remoteWebServer,
|
|
|
|
port=options.httpPort)
|
2013-08-20 01:40:27 +04:00
|
|
|
profileDir = profile.profile
|
|
|
|
|
|
|
|
prefs = {}
|
2015-02-03 19:18:13 +03:00
|
|
|
prefs["app.update.url.android"] = ""
|
2013-08-20 01:40:27 +04:00
|
|
|
prefs["browser.firstrun.show.localepicker"] = False
|
|
|
|
prefs["reftest.remote"] = True
|
|
|
|
prefs["datareporting.policy.dataSubmissionPolicyBypassAcceptance"] = True
|
|
|
|
|
2013-11-17 16:24:09 +04:00
|
|
|
prefs["layout.css.devPixelsPerPx"] = "1.0"
|
2015-08-24 20:45:45 +03:00
|
|
|
# Because Fennec is a little wacky (see bug 1156817) we need to load the
|
|
|
|
# reftest pages at 1.0 zoom, rather than zooming to fit the CSS viewport.
|
|
|
|
prefs["apz.allow_zooming"] = False
|
2013-08-20 01:40:27 +04:00
|
|
|
|
|
|
|
# Set the extra prefs.
|
|
|
|
profile.set_preferences(prefs)
|
2011-10-18 17:16:24 +04:00
|
|
|
|
Bug 795496 - Make mozdevice raise exceptions on error;r=ahal,jmaher
It turns out that relying on the user to check return codes for every
command was non-intuitive and resulted in many hard to trace bugs.
Now most functinos just return "None", and raise a DMError when there's an
exception. The exception to this are functions like dirExists, which now return
booleans, and throw exceptions on error. This is a fairly major refactor,
and also involved the following internal changes:
* Removed FileError and AgentError exceptions, replaced with DMError
(having to manage three different types of exceptions was confusing,
all the more so when we're raising them)
* Docstrings updated to remove references to return values where no
longer relevant
* pushFile no longer will create a directory to accomodate the file
if it doesn't exist (this makes it consistent with devicemanagerADB)
* dmSUT we validate the file, but assume that we get something back
from the agent, instead of falling back to manual validation in the
case that we didn't
* isDir and dirExists had the same intention, but different
implementations for dmSUT. Replaced the dmSUT impl of getDirectory
with that of isDir's (which was much simpler). Removed
isDir from devicemanager.py, since it wasn't used externally
* killProcess modified to check for process existence before running
(since the actual internal kill command will throw an exception
if the process doesn't exist)
In addition to all this, more unit tests have been added to test these
changes for devicemanagerSUT.
2012-10-04 19:28:07 +04:00
|
|
|
try:
|
|
|
|
self._devicemanager.pushDir(profileDir, options.remoteProfile)
|
2016-01-10 02:40:17 +03:00
|
|
|
self._devicemanager.chmodDir(options.remoteProfile)
|
2016-02-10 00:19:44 +03:00
|
|
|
except mozdevice.DMError:
|
Bug 795496 - Make mozdevice raise exceptions on error;r=ahal,jmaher
It turns out that relying on the user to check return codes for every
command was non-intuitive and resulted in many hard to trace bugs.
Now most functinos just return "None", and raise a DMError when there's an
exception. The exception to this are functions like dirExists, which now return
booleans, and throw exceptions on error. This is a fairly major refactor,
and also involved the following internal changes:
* Removed FileError and AgentError exceptions, replaced with DMError
(having to manage three different types of exceptions was confusing,
all the more so when we're raising them)
* Docstrings updated to remove references to return values where no
longer relevant
* pushFile no longer will create a directory to accomodate the file
if it doesn't exist (this makes it consistent with devicemanagerADB)
* dmSUT we validate the file, but assume that we get something back
from the agent, instead of falling back to manual validation in the
case that we didn't
* isDir and dirExists had the same intention, but different
implementations for dmSUT. Replaced the dmSUT impl of getDirectory
with that of isDir's (which was much simpler). Removed
isDir from devicemanager.py, since it wasn't used externally
* killProcess modified to check for process existence before running
(since the actual internal kill command will throw an exception
if the process doesn't exist)
In addition to all this, more unit tests have been added to test these
changes for devicemanagerSUT.
2012-10-04 19:28:07 +04:00
|
|
|
print "Automation Error: Failed to copy profiledir to device"
|
|
|
|
raise
|
2010-03-16 01:35:59 +03:00
|
|
|
|
2013-08-20 01:40:27 +04:00
|
|
|
return profile
|
|
|
|
|
|
|
|
def copyExtraFilesToProfile(self, options, profile):
|
|
|
|
profileDir = profile.profile
|
|
|
|
RefTest.copyExtraFilesToProfile(self, options, profile)
|
Bug 795496 - Make mozdevice raise exceptions on error;r=ahal,jmaher
It turns out that relying on the user to check return codes for every
command was non-intuitive and resulted in many hard to trace bugs.
Now most functinos just return "None", and raise a DMError when there's an
exception. The exception to this are functions like dirExists, which now return
booleans, and throw exceptions on error. This is a fairly major refactor,
and also involved the following internal changes:
* Removed FileError and AgentError exceptions, replaced with DMError
(having to manage three different types of exceptions was confusing,
all the more so when we're raising them)
* Docstrings updated to remove references to return values where no
longer relevant
* pushFile no longer will create a directory to accomodate the file
if it doesn't exist (this makes it consistent with devicemanagerADB)
* dmSUT we validate the file, but assume that we get something back
from the agent, instead of falling back to manual validation in the
case that we didn't
* isDir and dirExists had the same intention, but different
implementations for dmSUT. Replaced the dmSUT impl of getDirectory
with that of isDir's (which was much simpler). Removed
isDir from devicemanager.py, since it wasn't used externally
* killProcess modified to check for process existence before running
(since the actual internal kill command will throw an exception
if the process doesn't exist)
In addition to all this, more unit tests have been added to test these
changes for devicemanagerSUT.
2012-10-04 19:28:07 +04:00
|
|
|
try:
|
|
|
|
self._devicemanager.pushDir(profileDir, options.remoteProfile)
|
2016-01-10 02:40:17 +03:00
|
|
|
self._devicemanager.chmodDir(options.remoteProfile)
|
2016-02-10 00:19:44 +03:00
|
|
|
except mozdevice.DMError:
|
Bug 795496 - Make mozdevice raise exceptions on error;r=ahal,jmaher
It turns out that relying on the user to check return codes for every
command was non-intuitive and resulted in many hard to trace bugs.
Now most functinos just return "None", and raise a DMError when there's an
exception. The exception to this are functions like dirExists, which now return
booleans, and throw exceptions on error. This is a fairly major refactor,
and also involved the following internal changes:
* Removed FileError and AgentError exceptions, replaced with DMError
(having to manage three different types of exceptions was confusing,
all the more so when we're raising them)
* Docstrings updated to remove references to return values where no
longer relevant
* pushFile no longer will create a directory to accomodate the file
if it doesn't exist (this makes it consistent with devicemanagerADB)
* dmSUT we validate the file, but assume that we get something back
from the agent, instead of falling back to manual validation in the
case that we didn't
* isDir and dirExists had the same intention, but different
implementations for dmSUT. Replaced the dmSUT impl of getDirectory
with that of isDir's (which was much simpler). Removed
isDir from devicemanager.py, since it wasn't used externally
* killProcess modified to check for process existence before running
(since the actual internal kill command will throw an exception
if the process doesn't exist)
In addition to all this, more unit tests have been added to test these
changes for devicemanagerSUT.
2012-10-04 19:28:07 +04:00
|
|
|
print "Automation Error: Failed to copy extra files to device"
|
|
|
|
raise
|
2010-06-24 13:32:01 +04:00
|
|
|
|
2013-06-25 04:15:40 +04:00
|
|
|
def printDeviceInfo(self, printLogcat=False):
|
|
|
|
try:
|
|
|
|
if printLogcat:
|
|
|
|
logcat = self._devicemanager.getLogcat(filterOutRegexps=fennecLogcatFilters)
|
|
|
|
print ''.join(logcat)
|
2015-02-27 23:15:00 +03:00
|
|
|
print "Device info:"
|
|
|
|
devinfo = self._devicemanager.getInfo()
|
|
|
|
for category in devinfo:
|
|
|
|
if type(devinfo[category]) is list:
|
|
|
|
print " %s:" % category
|
|
|
|
for item in devinfo[category]:
|
|
|
|
print " %s" % item
|
|
|
|
else:
|
|
|
|
print " %s: %s" % (category, devinfo[category])
|
2014-07-11 23:29:30 +04:00
|
|
|
print "Test root: %s" % self._devicemanager.deviceRoot
|
2016-02-10 00:19:44 +03:00
|
|
|
except mozdevice.DMError:
|
2013-06-25 04:15:40 +04:00
|
|
|
print "WARNING: Error getting device information"
|
|
|
|
|
2014-07-29 19:47:50 +04:00
|
|
|
def environment(self, **kwargs):
|
2015-02-27 23:15:00 +03:00
|
|
|
return self.automation.environment(**kwargs)
|
2014-07-29 19:47:50 +04:00
|
|
|
|
2015-05-08 03:49:15 +03:00
|
|
|
def buildBrowserEnv(self, options, profileDir):
|
|
|
|
browserEnv = RefTest.buildBrowserEnv(self, options, profileDir)
|
|
|
|
# remove desktop environment not used on device
|
|
|
|
if "XPCOM_MEM_BLOAT_LOG" in browserEnv:
|
|
|
|
del browserEnv["XPCOM_MEM_BLOAT_LOG"]
|
|
|
|
return browserEnv
|
|
|
|
|
2014-07-29 19:47:50 +04:00
|
|
|
def runApp(self, profile, binary, cmdargs, env,
|
|
|
|
timeout=None, debuggerInfo=None,
|
2015-09-28 13:01:42 +03:00
|
|
|
symbolsPath=None, options=None,
|
|
|
|
valgrindPath=None, valgrindArgs=None, valgrindSuppFiles=None):
|
2014-07-29 19:47:50 +04:00
|
|
|
status = self.automation.runApp(None, env,
|
|
|
|
binary,
|
|
|
|
profile.profile,
|
|
|
|
cmdargs,
|
|
|
|
utilityPath=options.utilityPath,
|
|
|
|
xrePath=options.xrePath,
|
|
|
|
debuggerInfo=debuggerInfo,
|
|
|
|
symbolsPath=symbolsPath,
|
|
|
|
timeout=timeout)
|
|
|
|
return status
|
|
|
|
|
2010-03-16 01:35:59 +03:00
|
|
|
def cleanup(self, profileDir):
|
2010-07-27 05:43:34 +04:00
|
|
|
# Pull results back from device
|
2012-10-15 18:15:19 +04:00
|
|
|
if self.remoteLogFile and \
|
|
|
|
self._devicemanager.fileExists(self.remoteLogFile):
|
|
|
|
self._devicemanager.getFile(self.remoteLogFile, self.localLogName)
|
|
|
|
else:
|
|
|
|
print "WARNING: Unable to retrieve log file (%s) from remote " \
|
|
|
|
"device" % self.remoteLogFile
|
2010-06-24 13:32:01 +04:00
|
|
|
self._devicemanager.removeDir(self.remoteProfile)
|
2010-03-16 01:35:59 +03:00
|
|
|
self._devicemanager.removeDir(self.remoteTestRoot)
|
|
|
|
RefTest.cleanup(self, profileDir)
|
2011-04-20 02:17:01 +04:00
|
|
|
if (self.pidFile != ""):
|
|
|
|
try:
|
|
|
|
os.remove(self.pidFile)
|
2011-05-12 20:47:38 +04:00
|
|
|
os.remove(self.pidFile + ".xpcshell.pid")
|
2011-04-20 02:17:01 +04:00
|
|
|
except:
|
2017-02-14 22:50:56 +03:00
|
|
|
print ("Warning: cleaning up pidfile '%s' was unsuccessful "
|
|
|
|
"from the test harness" % self.pidFile)
|
2010-03-16 01:35:59 +03:00
|
|
|
|
2016-09-13 16:26:09 +03:00
|
|
|
|
|
|
|
def run_test_harness(parser, options):
|
2016-09-13 16:07:05 +03:00
|
|
|
dm_args = {
|
|
|
|
'deviceRoot': options.remoteTestRoot,
|
|
|
|
'host': options.deviceIP,
|
|
|
|
'port': options.devicePort,
|
|
|
|
}
|
|
|
|
|
2017-03-21 21:20:01 +03:00
|
|
|
dm_args['adbPath'] = options.adb_path
|
|
|
|
if not dm_args['host']:
|
|
|
|
dm_args['deviceSerial'] = options.deviceSerial
|
2017-04-11 18:21:37 +03:00
|
|
|
if options.log_tbpl_level == 'debug' or options.log_mach_level == 'debug':
|
|
|
|
dm_args['logLevel'] = logging.DEBUG
|
2016-09-13 16:07:05 +03:00
|
|
|
|
2012-03-22 18:45:30 +04:00
|
|
|
try:
|
2017-03-21 21:20:01 +03:00
|
|
|
dm = mozdevice.DroidADB(**dm_args)
|
2016-02-10 00:19:44 +03:00
|
|
|
except mozdevice.DMError:
|
2016-09-13 16:07:05 +03:00
|
|
|
traceback.print_exc()
|
2017-02-14 22:50:56 +03:00
|
|
|
print ("Automation Error: exception while initializing devicemanager. "
|
|
|
|
"Most likely the device is not in a testable state.")
|
2012-06-13 22:20:43 +04:00
|
|
|
return 1
|
2012-03-22 18:45:30 +04:00
|
|
|
|
2015-10-15 00:20:20 +03:00
|
|
|
automation = RemoteAutomation(None)
|
2010-06-24 13:32:01 +04:00
|
|
|
automation.setDeviceManager(dm)
|
2010-03-16 01:35:59 +03:00
|
|
|
|
2016-09-13 16:07:05 +03:00
|
|
|
if options.remoteProductName:
|
2010-06-24 13:32:01 +04:00
|
|
|
automation.setProduct(options.remoteProductName)
|
2010-03-16 01:35:59 +03:00
|
|
|
|
2010-06-24 13:32:01 +04:00
|
|
|
# Set up the defaults and ensure options are set
|
2015-08-25 16:07:23 +03:00
|
|
|
parser.validate_remote(options, automation)
|
2011-02-23 22:38:59 +03:00
|
|
|
|
2015-09-02 23:20:01 +03:00
|
|
|
# Check that Firefox is installed
|
|
|
|
expected = options.app.split('/')[-1]
|
|
|
|
installed = dm.shellCheckOutput(['pm', 'list', 'packages', expected])
|
|
|
|
if expected not in installed:
|
|
|
|
print "%s is not installed on this device" % expected
|
|
|
|
return 1
|
|
|
|
|
2010-06-24 13:32:01 +04:00
|
|
|
automation.setAppName(options.app)
|
|
|
|
automation.setRemoteProfile(options.remoteProfile)
|
2010-09-18 04:18:06 +04:00
|
|
|
automation.setRemoteLog(options.remoteLogFile)
|
2010-03-16 01:35:59 +03:00
|
|
|
reftest = RemoteReftest(automation, dm, options, SCRIPT_DIRECTORY)
|
2015-08-25 16:07:23 +03:00
|
|
|
parser.validate(options, reftest)
|
2010-03-16 01:35:59 +03:00
|
|
|
|
2015-07-16 15:20:08 +03:00
|
|
|
if mozinfo.info['debug']:
|
|
|
|
print "changing timeout for remote debug reftests from %s to 600 seconds" % options.timeout
|
|
|
|
options.timeout = 600
|
|
|
|
|
2011-10-19 15:23:54 +04:00
|
|
|
# Hack in a symbolic link for jsreftest
|
|
|
|
os.system("ln -s ../jsreftest " + str(os.path.join(SCRIPT_DIRECTORY, "jsreftest")))
|
|
|
|
|
2011-10-19 13:35:05 +04:00
|
|
|
# Start the webserver
|
2012-06-13 22:20:43 +04:00
|
|
|
retVal = reftest.startWebServer(options)
|
|
|
|
if retVal:
|
|
|
|
return retVal
|
2010-11-05 03:01:13 +03:00
|
|
|
|
2011-02-23 22:38:56 +03:00
|
|
|
procName = options.app.split('/')[-1]
|
2017-04-12 18:15:53 +03:00
|
|
|
dm.killProcess(procName)
|
|
|
|
if dm.processExist(procName):
|
|
|
|
print "unable to kill %s before starting tests!" % procName
|
2011-02-23 22:38:56 +03:00
|
|
|
|
2015-10-15 00:20:20 +03:00
|
|
|
if options.printDeviceInfo:
|
|
|
|
reftest.printDeviceInfo()
|
2012-07-26 04:45:36 +04:00
|
|
|
|
2017-02-14 22:50:56 +03:00
|
|
|
# an example manifest name to use on the cli
|
|
|
|
# manifest = "http://" + options.remoteWebServer +
|
|
|
|
# "/reftests/layout/reftests/reftest-sanity/reftest.list"
|
2012-10-24 21:34:33 +04:00
|
|
|
retVal = 0
|
2011-09-26 15:41:19 +04:00
|
|
|
try:
|
2012-06-13 22:20:43 +04:00
|
|
|
dm.recordLogcat()
|
2015-08-25 16:07:23 +03:00
|
|
|
retVal = reftest.runTests(options.tests, options)
|
2011-09-26 15:41:19 +04:00
|
|
|
except:
|
2012-11-05 17:03:54 +04:00
|
|
|
print "Automation Error: Exception caught while running tests"
|
|
|
|
traceback.print_exc()
|
2012-10-24 21:34:33 +04:00
|
|
|
retVal = 1
|
2011-09-26 15:41:19 +04:00
|
|
|
|
2010-06-24 13:32:01 +04:00
|
|
|
reftest.stopWebServer(options)
|
2013-06-25 04:15:40 +04:00
|
|
|
|
2015-10-15 00:20:20 +03:00
|
|
|
if options.printDeviceInfo:
|
|
|
|
reftest.printDeviceInfo(printLogcat=True)
|
|
|
|
|
|
|
|
return retVal
|
|
|
|
|
2012-10-24 21:34:33 +04:00
|
|
|
|
2016-09-13 16:26:09 +03:00
|
|
|
if __name__ == "__main__":
|
2015-10-15 00:20:20 +03:00
|
|
|
parser = reftestcommandline.RemoteArgumentsParser()
|
|
|
|
options = parser.parse_args()
|
2016-09-13 16:26:09 +03:00
|
|
|
sys.exit(run_test_harness(parser, options))
|