2012-05-21 11:12:37 +00: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 17:51:17 +00:00
|
|
|
|
2010-03-15 22:35:59 +00:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import time
|
2010-06-24 09:32:01 +00:00
|
|
|
import tempfile
|
2012-11-05 13:03:54 +00:00
|
|
|
import traceback
|
2010-03-15 22:35:59 +00:00
|
|
|
|
2010-06-24 09:32:01 +00:00
|
|
|
# We need to know our current directory so that we can serve our test files from it.
|
2010-03-15 22:35:59 +00:00
|
|
|
SCRIPT_DIRECTORY = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
|
|
|
|
|
|
|
|
from runreftest import RefTest
|
|
|
|
from runreftest import ReftestOptions
|
|
|
|
from automation import Automation
|
2013-05-03 17:37:59 +00:00
|
|
|
import devicemanager
|
|
|
|
import droid
|
2012-11-12 21:57:13 +00:00
|
|
|
from remoteautomation import RemoteAutomation, fennecLogcatFilters
|
2010-03-15 22:35:59 +00:00
|
|
|
|
|
|
|
class RemoteOptions(ReftestOptions):
|
|
|
|
def __init__(self, automation):
|
|
|
|
ReftestOptions.__init__(self, automation)
|
|
|
|
|
|
|
|
defaults = {}
|
|
|
|
defaults["logFile"] = "reftest.log"
|
|
|
|
# app, xrePath and utilityPath variables are set in main function
|
|
|
|
defaults["app"] = ""
|
|
|
|
defaults["xrePath"] = ""
|
|
|
|
defaults["utilityPath"] = ""
|
|
|
|
|
2010-06-24 09:32:01 +00:00
|
|
|
self.add_option("--remote-app-path", action="store",
|
|
|
|
type = "string", dest = "remoteAppPath",
|
|
|
|
help = "Path to remote executable relative to device root using only forward slashes. Either this or app must be specified, but not both.")
|
|
|
|
defaults["remoteAppPath"] = None
|
|
|
|
|
|
|
|
self.add_option("--deviceIP", action="store",
|
|
|
|
type = "string", dest = "deviceIP",
|
2010-03-15 22:35:59 +00:00
|
|
|
help = "ip address of remote device to test")
|
2010-06-24 09:32:01 +00:00
|
|
|
defaults["deviceIP"] = None
|
2010-03-15 22:35:59 +00:00
|
|
|
|
|
|
|
self.add_option("--devicePort", action="store",
|
|
|
|
type = "string", dest = "devicePort",
|
|
|
|
help = "port of remote device to test")
|
2010-06-24 09:32:01 +00:00
|
|
|
defaults["devicePort"] = 20701
|
2010-03-15 22:35:59 +00:00
|
|
|
|
2010-06-24 09:32:01 +00:00
|
|
|
self.add_option("--remote-product-name", action="store",
|
2010-03-15 22:35:59 +00:00
|
|
|
type = "string", dest = "remoteProductName",
|
2010-06-24 09:32:01 +00:00
|
|
|
help = "Name of product to test - either fennec or firefox, defaults to fennec")
|
2010-03-15 22:35:59 +00:00
|
|
|
defaults["remoteProductName"] = "fennec"
|
|
|
|
|
|
|
|
self.add_option("--remote-webserver", action="store",
|
|
|
|
type = "string", dest = "remoteWebServer",
|
|
|
|
help = "IP Address of the webserver hosting the reftest content")
|
2012-08-10 18:25:20 +00:00
|
|
|
defaults["remoteWebServer"] = automation.getLanIp()
|
2010-06-24 09:32:01 +00:00
|
|
|
|
|
|
|
self.add_option("--http-port", action = "store",
|
|
|
|
type = "string", dest = "httpPort",
|
|
|
|
help = "port of the web server for http traffic")
|
|
|
|
defaults["httpPort"] = automation.DEFAULT_HTTP_PORT
|
|
|
|
|
|
|
|
self.add_option("--ssl-port", action = "store",
|
|
|
|
type = "string", dest = "sslPort",
|
|
|
|
help = "Port for https traffic to the web server")
|
|
|
|
defaults["sslPort"] = automation.DEFAULT_SSL_PORT
|
|
|
|
|
|
|
|
self.add_option("--remote-logfile", action="store",
|
|
|
|
type = "string", dest = "remoteLogFile",
|
|
|
|
help = "Name of log file on the device relative to device root. PLEASE USE ONLY A FILENAME.")
|
2010-07-27 01:43:34 +00:00
|
|
|
defaults["remoteLogFile"] = None
|
2011-04-19 22:17:01 +00:00
|
|
|
|
2011-04-19 22:17:02 +00:00
|
|
|
self.add_option("--enable-privilege", action="store_true", dest = "enablePrivilege",
|
|
|
|
help = "add webserver and port to the user.js file for remote script access and universalXPConnect")
|
|
|
|
defaults["enablePrivilege"] = False
|
|
|
|
|
2011-04-19 22:17:01 +00:00
|
|
|
self.add_option("--pidfile", action = "store",
|
|
|
|
type = "string", dest = "pidFile",
|
|
|
|
help = "name of the pidfile to generate")
|
|
|
|
defaults["pidFile"] = ""
|
|
|
|
|
2011-12-20 21:33:41 +00:00
|
|
|
self.add_option("--bootstrap", action="store_true", dest = "bootstrap",
|
|
|
|
help = "test with a bootstrap addon required for native Fennec")
|
|
|
|
defaults["bootstrap"] = False
|
|
|
|
|
2011-05-06 22:17:55 +00:00
|
|
|
self.add_option("--dm_trans", action="store",
|
|
|
|
type = "string", dest = "dm_trans",
|
|
|
|
help = "the transport to use to communicate with device: [adb|sut]; default=sut")
|
|
|
|
defaults["dm_trans"] = "sut"
|
|
|
|
|
2012-12-20 16:11:11 +00:00
|
|
|
self.add_option("--remoteTestRoot", action = "store",
|
|
|
|
type = "string", dest = "remoteTestRoot",
|
|
|
|
help = "remote directory to use as test root (eg. /mnt/sdcard/tests or /data/local/tests)")
|
|
|
|
defaults["remoteTestRoot"] = None
|
|
|
|
|
2013-06-27 03:42:46 +00:00
|
|
|
self.add_option("--httpd-path", action = "store",
|
|
|
|
type = "string", dest = "httpdPath",
|
|
|
|
help = "path to the httpd.js file")
|
|
|
|
defaults["httpdPath"] = None
|
|
|
|
|
2010-07-27 01:43:34 +00:00
|
|
|
defaults["localLogName"] = None
|
2010-03-15 22:35:59 +00:00
|
|
|
|
|
|
|
self.set_defaults(**defaults)
|
|
|
|
|
2010-06-24 09:32:01 +00:00
|
|
|
def verifyRemoteOptions(self, options):
|
|
|
|
# Ensure our defaults are set properly for everything we can infer
|
2012-12-20 16:11:11 +00:00
|
|
|
if not options.remoteTestRoot:
|
|
|
|
options.remoteTestRoot = self._automation._devicemanager.getDeviceRoot() + '/reftest'
|
2010-06-24 09:32:01 +00:00
|
|
|
options.remoteProfile = options.remoteTestRoot + "/profile"
|
|
|
|
|
2010-07-27 01:43:34 +00:00
|
|
|
# Verify that our remotewebserver is set properly
|
|
|
|
if (options.remoteWebServer == None or
|
|
|
|
options.remoteWebServer == '127.0.0.1'):
|
|
|
|
print "ERROR: Either you specified the loopback for the remote webserver or ",
|
|
|
|
print "your local IP cannot be detected. Please provide the local ip in --remote-webserver"
|
|
|
|
return None
|
|
|
|
|
2010-06-24 09:32:01 +00:00
|
|
|
# One of remoteAppPath (relative path to application) or the app (executable) must be
|
|
|
|
# set, but not both. If both are set, we destroy the user's selection for app
|
|
|
|
# so instead of silently destroying a user specificied setting, we error.
|
|
|
|
if (options.remoteAppPath and options.app):
|
|
|
|
print "ERROR: You cannot specify both the remoteAppPath and the app"
|
|
|
|
return None
|
|
|
|
elif (options.remoteAppPath):
|
|
|
|
options.app = options.remoteTestRoot + "/" + options.remoteAppPath
|
|
|
|
elif (options.app == None):
|
|
|
|
# Neither remoteAppPath nor app are set -- error
|
|
|
|
print "ERROR: You must specify either appPath or app"
|
|
|
|
return None
|
2012-08-10 18:25:20 +00:00
|
|
|
|
2010-06-24 09:32:01 +00:00
|
|
|
if (options.xrePath == None):
|
|
|
|
print "ERROR: You must specify the path to the controller xre directory"
|
|
|
|
return None
|
2010-07-27 01:43:34 +00:00
|
|
|
else:
|
|
|
|
# Ensure xrepath is a full path
|
|
|
|
options.xrePath = os.path.abspath(options.xrePath)
|
2012-08-10 18:25:20 +00:00
|
|
|
|
2010-07-27 01:43:34 +00:00
|
|
|
# Default to <deviceroot>/reftest/reftest.log
|
|
|
|
if (options.remoteLogFile == None):
|
|
|
|
options.remoteLogFile = 'reftest.log'
|
|
|
|
|
|
|
|
options.localLogName = options.remoteLogFile
|
|
|
|
options.remoteLogFile = options.remoteTestRoot + '/' + options.remoteLogFile
|
2012-08-10 18:25:20 +00:00
|
|
|
|
2010-07-27 01:43:34 +00:00
|
|
|
# Ensure that the options.logfile (which the base class uses) is set to
|
2012-08-10 18:25:20 +00:00
|
|
|
# the remote setting when running remote. Also, if the user set the
|
2010-07-27 01:43:34 +00:00
|
|
|
# log file name there, use that instead of reusing the remotelogfile as above.
|
|
|
|
if (options.logFile):
|
|
|
|
# If the user specified a local logfile name use that
|
|
|
|
options.localLogName = options.logFile
|
|
|
|
|
|
|
|
options.logFile = options.remoteLogFile
|
2010-06-24 09:32:01 +00:00
|
|
|
|
2011-04-19 22:17:01 +00:00
|
|
|
if (options.pidFile != ""):
|
|
|
|
f = open(options.pidFile, 'w')
|
|
|
|
f.write("%s" % os.getpid())
|
|
|
|
f.close()
|
|
|
|
|
2013-06-27 03:42:46 +00:00
|
|
|
# httpd-path is specified by standard makefile targets and may be specified
|
|
|
|
# on the command line to select a particular version of httpd.js. If not
|
|
|
|
# specified, try to select the one from hostutils.zip, as required in bug 882932.
|
|
|
|
if not options.httpdPath:
|
|
|
|
options.httpdPath = os.path.join(options.utilityPath, "components")
|
|
|
|
|
2010-06-24 09:32:01 +00:00
|
|
|
# TODO: Copied from main, but I think these are no longer used in a post xulrunner world
|
|
|
|
#options.xrePath = options.remoteTestRoot + self._automation._product + '/xulrunner'
|
|
|
|
#options.utilityPath = options.testRoot + self._automation._product + '/bin'
|
|
|
|
return options
|
|
|
|
|
2010-06-24 09:32:01 +00: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 01:43:34 +00:00
|
|
|
Bug 581257 has been filed to refactor this wrapper around httpd.js into
|
2010-06-24 09:32:01 +00:00
|
|
|
it's own class and use it in both remote and non-remote testing. """
|
|
|
|
|
2010-09-18 00:18:06 +00:00
|
|
|
def __init__(self, automation, options, scriptDir):
|
2010-06-24 09:32:01 +00:00
|
|
|
self._automation = automation
|
|
|
|
self._utilityPath = options.utilityPath
|
|
|
|
self._xrePath = options.xrePath
|
|
|
|
self._profileDir = options.serverProfilePath
|
|
|
|
self.webServer = options.remoteWebServer
|
|
|
|
self.httpPort = options.httpPort
|
2010-09-18 00:18:06 +00:00
|
|
|
self.scriptDir = scriptDir
|
2011-05-12 16:47:38 +00:00
|
|
|
self.pidFile = options.pidFile
|
2013-06-29 02:20:08 +00:00
|
|
|
self._httpdPath = os.path.abspath(options.httpdPath)
|
2010-06-24 09:32:01 +00:00
|
|
|
self.shutdownURL = "http://%(server)s:%(port)s/server/shutdown" % { "server" : self.webServer, "port" : self.httpPort }
|
|
|
|
|
|
|
|
def start(self):
|
|
|
|
"Run the Refest server, returning the process ID of the server."
|
2012-08-10 18:25:20 +00:00
|
|
|
|
2010-06-24 09:32:01 +00:00
|
|
|
env = self._automation.environment(xrePath = self._xrePath)
|
|
|
|
env["XPCOM_DEBUG_BREAK"] = "warn"
|
|
|
|
if self._automation.IS_WIN32:
|
|
|
|
env["PATH"] = env["PATH"] + ";" + self._xrePath
|
|
|
|
|
|
|
|
args = ["-g", self._xrePath,
|
|
|
|
"-v", "170",
|
2013-06-27 03:42:46 +00:00
|
|
|
"-f", os.path.join(self._httpdPath, "httpd.js"),
|
2012-08-10 18:25:20 +00:00
|
|
|
"-e", "const _PROFILE_PATH = '%(profile)s';const _SERVER_PORT = '%(port)s'; const _SERVER_ADDR ='%(server)s';" %
|
2010-06-24 09:32:01 +00:00
|
|
|
{"profile" : self._profileDir.replace('\\', '\\\\'), "port" : self.httpPort, "server" : self.webServer },
|
2010-09-18 00:18:06 +00:00
|
|
|
"-f", os.path.join(self.scriptDir, "server.js")]
|
2010-06-24 09:32:01 +00:00
|
|
|
|
|
|
|
xpcshell = os.path.join(self._utilityPath,
|
|
|
|
"xpcshell" + self._automation.BIN_SUFFIX)
|
2013-01-04 01:37:26 +00:00
|
|
|
|
|
|
|
if not os.access(xpcshell, os.F_OK):
|
|
|
|
raise Exception('xpcshell not found at %s' % xpcshell)
|
|
|
|
if self._automation.elf_arm(xpcshell):
|
|
|
|
raise Exception('xpcshell at %s is an ARM binary; please use '
|
|
|
|
'the --utility-path argument to specify the path '
|
|
|
|
'to a desktop version.' % xpcshell)
|
|
|
|
|
2010-06-24 09:32:01 +00:00
|
|
|
self._process = self._automation.Process([xpcshell] + args, env = env)
|
|
|
|
pid = self._process.pid
|
|
|
|
if pid < 0:
|
|
|
|
print "Error starting server."
|
2012-06-13 18:20:43 +00:00
|
|
|
return 2
|
2010-06-24 09:32:01 +00:00
|
|
|
self._automation.log.info("INFO | remotereftests.py | Server pid: %d", pid)
|
|
|
|
|
2011-05-12 16:47:38 +00:00
|
|
|
if (self.pidFile != ""):
|
|
|
|
f = open(self.pidFile + ".xpcshell.pid", 'w')
|
|
|
|
f.write("%s" % pid)
|
|
|
|
f.close()
|
|
|
|
|
2010-06-24 09:32:01 +00: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:
|
|
|
|
print "Timed out while waiting for server startup."
|
|
|
|
self.stop()
|
2012-06-13 18:20:43 +00:00
|
|
|
return 1
|
2010-06-24 09:32:01 +00:00
|
|
|
|
|
|
|
def stop(self):
|
2012-08-10 18:25:20 +00:00
|
|
|
if hasattr(self, '_process'):
|
|
|
|
try:
|
|
|
|
c = urllib2.urlopen(self.shutdownURL)
|
|
|
|
c.read()
|
|
|
|
c.close()
|
2010-06-24 09:32:01 +00:00
|
|
|
|
2012-08-10 18:25:20 +00:00
|
|
|
rtncode = self._process.poll()
|
|
|
|
if (rtncode == None):
|
|
|
|
self._process.terminate()
|
|
|
|
except:
|
|
|
|
self._process.kill()
|
2010-06-24 09:32:01 +00:00
|
|
|
|
2010-03-15 22:35:59 +00:00
|
|
|
class RemoteReftest(RefTest):
|
|
|
|
remoteApp = ''
|
|
|
|
|
|
|
|
def __init__(self, automation, devicemanager, options, scriptDir):
|
|
|
|
RefTest.__init__(self, automation)
|
|
|
|
self._devicemanager = devicemanager
|
|
|
|
self.scriptDir = scriptDir
|
|
|
|
self.remoteApp = options.app
|
2010-06-24 09:32:01 +00:00
|
|
|
self.remoteProfile = options.remoteProfile
|
2010-06-24 09:32:01 +00:00
|
|
|
self.remoteTestRoot = options.remoteTestRoot
|
2010-07-27 01:43:34 +00:00
|
|
|
self.remoteLogFile = options.remoteLogFile
|
|
|
|
self.localLogName = options.localLogName
|
2011-04-19 22:17:01 +00:00
|
|
|
self.pidFile = options.pidFile
|
2010-06-24 09:32:01 +00:00
|
|
|
if self.automation.IS_DEBUG_BUILD:
|
|
|
|
self.SERVER_STARTUP_TIMEOUT = 180
|
|
|
|
else:
|
|
|
|
self.SERVER_STARTUP_TIMEOUT = 90
|
2013-05-16 20:32:52 +00:00
|
|
|
self.automation.deleteANRs()
|
2010-06-24 09:32:01 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
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 19:45:42 +00:00
|
|
|
localAutomation.IS_WIN32 = False
|
|
|
|
localAutomation.IS_LINUX = False
|
|
|
|
localAutomation.IS_MAC = False
|
|
|
|
localAutomation.UNIXISH = False
|
|
|
|
hostos = sys.platform
|
|
|
|
if (hostos == 'mac' or hostos == 'darwin'):
|
2011-12-20 21:33:41 +00:00
|
|
|
localAutomation.IS_MAC = True
|
2011-02-24 19:45:42 +00:00
|
|
|
elif (hostos == 'linux' or hostos == 'linux2'):
|
2011-12-20 21:33:41 +00:00
|
|
|
localAutomation.IS_LINUX = True
|
|
|
|
localAutomation.UNIXISH = True
|
2011-02-24 19:45:42 +00:00
|
|
|
elif (hostos == 'win32' or hostos == 'win64'):
|
2011-12-20 21:33:41 +00:00
|
|
|
localAutomation.BIN_SUFFIX = ".exe"
|
|
|
|
localAutomation.IS_WIN32 = True
|
2010-06-24 09:32:01 +00:00
|
|
|
|
|
|
|
paths = [options.xrePath, localAutomation.DIST_BIN, self.automation._product, os.path.join('..', self.automation._product)]
|
|
|
|
options.xrePath = self.findPath(paths)
|
|
|
|
if options.xrePath == None:
|
|
|
|
print "ERROR: unable to find xulrunner path for %s, please specify with --xre-path" % (os.name)
|
2012-06-13 18:20:43 +00:00
|
|
|
return 1
|
2010-06-24 09:32:01 +00:00
|
|
|
paths.append("bin")
|
|
|
|
paths.append(os.path.join("..", "bin"))
|
|
|
|
|
|
|
|
xpcshell = "xpcshell"
|
|
|
|
if (os.name == "nt"):
|
|
|
|
xpcshell += ".exe"
|
2012-08-10 18:25:20 +00:00
|
|
|
|
2010-06-24 09:32:01 +00:00
|
|
|
if (options.utilityPath):
|
|
|
|
paths.insert(0, options.utilityPath)
|
|
|
|
options.utilityPath = self.findPath(paths, xpcshell)
|
|
|
|
if options.utilityPath == None:
|
|
|
|
print "ERROR: unable to find utility path for %s, please specify with --utility-path" % (os.name)
|
2012-06-13 18:20:43 +00:00
|
|
|
return 1
|
2010-06-24 09:32:01 +00:00
|
|
|
|
|
|
|
options.serverProfilePath = tempfile.mkdtemp()
|
2010-09-18 00:18:06 +00:00
|
|
|
self.server = ReftestServer(localAutomation, options, self.scriptDir)
|
2012-06-13 18:20:43 +00:00
|
|
|
retVal = self.server.start()
|
|
|
|
if retVal:
|
|
|
|
return retVal
|
|
|
|
retVal = self.server.ensureReady(self.SERVER_STARTUP_TIMEOUT)
|
|
|
|
if retVal:
|
|
|
|
return retVal
|
2010-06-24 09:32:01 +00:00
|
|
|
|
|
|
|
options.xrePath = remoteXrePath
|
|
|
|
options.utilityPath = remoteUtilityPath
|
2012-06-13 18:20:43 +00:00
|
|
|
return 0
|
2012-08-10 18:25:20 +00:00
|
|
|
|
2010-06-24 09:32:01 +00:00
|
|
|
def stopWebServer(self, options):
|
|
|
|
self.server.stop()
|
2010-03-15 22:35:59 +00:00
|
|
|
|
2011-12-20 21:33:41 +00:00
|
|
|
def createReftestProfile(self, options, profileDir, reftestlist):
|
|
|
|
RefTest.createReftestProfile(self, options, profileDir, reftestlist, server=options.remoteWebServer)
|
2010-03-15 22:35:59 +00:00
|
|
|
|
2011-10-18 13:16:24 +00:00
|
|
|
# Turn off the locale picker screen
|
|
|
|
fhandle = open(os.path.join(profileDir, "user.js"), 'a')
|
|
|
|
fhandle.write("""
|
|
|
|
user_pref("browser.firstrun.show.localepicker", false);
|
2011-11-24 02:48:24 +00:00
|
|
|
user_pref("font.size.inflation.emPerLine", 0);
|
|
|
|
user_pref("font.size.inflation.minTwips", 0);
|
2011-12-20 21:33:41 +00:00
|
|
|
user_pref("reftest.remote", true);
|
2013-01-02 15:31:10 +00:00
|
|
|
// Set a future policy version to avoid the telemetry prompt.
|
|
|
|
user_pref("toolkit.telemetry.prompted", 999);
|
|
|
|
user_pref("toolkit.telemetry.notifiedOptOut", 999);
|
2011-12-20 21:33:41 +00:00
|
|
|
user_pref("reftest.uri", "%s");
|
2013-01-12 03:05:35 +00:00
|
|
|
user_pref("datareporting.policy.dataSubmissionPolicyBypassAcceptance", true);
|
2013-05-17 15:20:00 +00:00
|
|
|
|
|
|
|
// Point the url-classifier to the local testing server for fast failures
|
|
|
|
user_pref("browser.safebrowsing.gethashURL", "http://127.0.0.1:8888/safebrowsing-dummy/gethash");
|
|
|
|
user_pref("browser.safebrowsing.keyURL", "http://127.0.0.1:8888/safebrowsing-dummy/newkey");
|
|
|
|
user_pref("browser.safebrowsing.updateURL", "http://127.0.0.1:8888/safebrowsing-dummy/update");
|
|
|
|
// Point update checks to the local testing server for fast failures
|
|
|
|
user_pref("extensions.update.url", "http://127.0.0.1:8888/extensions-dummy/updateURL");
|
|
|
|
user_pref("extensions.update.background.url", "http://127.0.0.1:8888/extensions-dummy/updateBackgroundURL");
|
|
|
|
user_pref("extensions.blocklist.url", "http://127.0.0.1:8888/extensions-dummy/blocklistURL");
|
|
|
|
user_pref("extensions.hotfix.url", "http://127.0.0.1:8888/extensions-dummy/hotfixURL");
|
|
|
|
// Turn off extension updates so they don't bother tests
|
|
|
|
user_pref("extensions.update.enabled", false);
|
|
|
|
// Make sure opening about:addons won't hit the network
|
|
|
|
user_pref("extensions.webservice.discoverURL", "http://127.0.0.1:8888/extensions-dummy/discoveryURL");
|
|
|
|
// Make sure AddonRepository won't hit the network
|
|
|
|
user_pref("extensions.getAddons.maxResults", 0);
|
|
|
|
user_pref("extensions.getAddons.get.url", "http://127.0.0.1:8888/extensions-dummy/repositoryGetURL");
|
|
|
|
user_pref("extensions.getAddons.getWithPerformance.url", "http://127.0.0.1:8888/extensions-dummy/repositoryGetWithPerformanceURL");
|
|
|
|
user_pref("extensions.getAddons.search.browseURL", "http://127.0.0.1:8888/extensions-dummy/repositoryBrowseURL");
|
|
|
|
user_pref("extensions.getAddons.search.url", "http://127.0.0.1:8888/extensions-dummy/repositorySearchURL");
|
|
|
|
// Make sure that opening the plugins check page won't hit the network
|
|
|
|
user_pref("plugins.update.url", "http://127.0.0.1:8888/plugins-dummy/updateCheckURL");
|
|
|
|
|
2011-12-20 21:33:41 +00:00
|
|
|
""" % reftestlist)
|
2011-10-18 13:16:24 +00:00
|
|
|
|
2011-04-19 22:17:02 +00:00
|
|
|
#workaround for jsreftests.
|
|
|
|
if options.enablePrivilege:
|
2011-12-20 21:33:41 +00:00
|
|
|
fhandle.write("""
|
2011-12-30 17:35:38 +00:00
|
|
|
user_pref("capability.principal.codebase.p2.granted", "UniversalXPConnect");
|
2011-04-19 22:17:02 +00:00
|
|
|
user_pref("capability.principal.codebase.p2.id", "http://%s:%s");
|
|
|
|
""" % (options.remoteWebServer, options.httpPort))
|
2011-10-18 13:16:24 +00:00
|
|
|
|
|
|
|
# Close the file
|
|
|
|
fhandle.close()
|
|
|
|
|
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 15:28:07 +00:00
|
|
|
try:
|
|
|
|
self._devicemanager.pushDir(profileDir, options.remoteProfile)
|
|
|
|
except devicemanager.DMError:
|
|
|
|
print "Automation Error: Failed to copy profiledir to device"
|
|
|
|
raise
|
2010-03-15 22:35:59 +00:00
|
|
|
|
|
|
|
def copyExtraFilesToProfile(self, options, profileDir):
|
|
|
|
RefTest.copyExtraFilesToProfile(self, options, profileDir)
|
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 15:28:07 +00:00
|
|
|
try:
|
|
|
|
self._devicemanager.pushDir(profileDir, options.remoteProfile)
|
|
|
|
except devicemanager.DMError:
|
|
|
|
print "Automation Error: Failed to copy extra files to device"
|
|
|
|
raise
|
2010-06-24 09:32:01 +00:00
|
|
|
|
2010-03-15 22:35:59 +00:00
|
|
|
def getManifestPath(self, path):
|
|
|
|
return path
|
|
|
|
|
2013-06-25 00:15:40 +00:00
|
|
|
def printDeviceInfo(self, printLogcat=False):
|
|
|
|
try:
|
|
|
|
if printLogcat:
|
|
|
|
logcat = self._devicemanager.getLogcat(filterOutRegexps=fennecLogcatFilters)
|
|
|
|
print ''.join(logcat)
|
|
|
|
print "Device info: %s" % self._devicemanager.getInfo()
|
|
|
|
print "Test root: %s" % self._devicemanager.getDeviceRoot()
|
|
|
|
except devicemanager.DMError:
|
|
|
|
print "WARNING: Error getting device information"
|
|
|
|
|
2010-03-15 22:35:59 +00:00
|
|
|
def cleanup(self, profileDir):
|
2010-07-27 01:43:34 +00:00
|
|
|
# Pull results back from device
|
2012-10-15 14:15:19 +00: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 09:32:01 +00:00
|
|
|
self._devicemanager.removeDir(self.remoteProfile)
|
2010-03-15 22:35:59 +00:00
|
|
|
self._devicemanager.removeDir(self.remoteTestRoot)
|
|
|
|
RefTest.cleanup(self, profileDir)
|
2011-04-19 22:17:01 +00:00
|
|
|
if (self.pidFile != ""):
|
|
|
|
try:
|
|
|
|
os.remove(self.pidFile)
|
2011-05-12 16:47:38 +00:00
|
|
|
os.remove(self.pidFile + ".xpcshell.pid")
|
2011-04-19 22:17:01 +00:00
|
|
|
except:
|
|
|
|
print "Warning: cleaning up pidfile '%s' was unsuccessful from the test harness" % self.pidFile
|
2010-03-15 22:35:59 +00:00
|
|
|
|
2012-06-13 18:20:43 +00:00
|
|
|
def main(args):
|
2012-03-16 22:36:28 +00:00
|
|
|
automation = RemoteAutomation(None)
|
2010-03-15 22:35:59 +00:00
|
|
|
parser = RemoteOptions(automation)
|
|
|
|
options, args = parser.parse_args()
|
|
|
|
|
2010-06-24 09:32:01 +00:00
|
|
|
if (options.deviceIP == None):
|
2010-03-15 22:35:59 +00:00
|
|
|
print "Error: you must provide a device IP to connect to via the --device option"
|
2012-06-13 18:20:43 +00:00
|
|
|
return 1
|
2010-03-15 22:35:59 +00:00
|
|
|
|
2012-03-22 14:45:30 +00:00
|
|
|
try:
|
|
|
|
if (options.dm_trans == "adb"):
|
|
|
|
if (options.deviceIP):
|
2013-05-03 17:37:59 +00:00
|
|
|
dm = droid.DroidADB(options.deviceIP, options.devicePort, deviceRoot=options.remoteTestRoot)
|
2012-03-22 14:45:30 +00:00
|
|
|
else:
|
2013-05-03 17:37:59 +00:00
|
|
|
dm = droid.DroidADB(None, None, deviceRoot=options.remoteTestRoot)
|
2011-05-06 22:17:55 +00:00
|
|
|
else:
|
2013-05-03 17:37:59 +00:00
|
|
|
dm = droid.DroidSUT(options.deviceIP, options.devicePort, deviceRoot=options.remoteTestRoot)
|
2012-03-22 14:45:30 +00:00
|
|
|
except devicemanager.DMError:
|
|
|
|
print "Error: exception while initializing devicemanager. Most likely the device is not in a testable state."
|
2012-06-13 18:20:43 +00:00
|
|
|
return 1
|
2012-03-22 14:45:30 +00:00
|
|
|
|
2010-06-24 09:32:01 +00:00
|
|
|
automation.setDeviceManager(dm)
|
2010-03-15 22:35:59 +00:00
|
|
|
|
2010-06-24 09:32:01 +00:00
|
|
|
if (options.remoteProductName != None):
|
|
|
|
automation.setProduct(options.remoteProductName)
|
2010-03-15 22:35:59 +00:00
|
|
|
|
2010-06-24 09:32:01 +00:00
|
|
|
# Set up the defaults and ensure options are set
|
|
|
|
options = parser.verifyRemoteOptions(options)
|
|
|
|
if (options == None):
|
|
|
|
print "ERROR: Invalid options specified, use --help for a list of valid options"
|
2012-06-13 18:20:43 +00:00
|
|
|
return 1
|
2010-06-24 09:32:01 +00:00
|
|
|
|
2011-07-12 22:10:10 +00:00
|
|
|
if not options.ignoreWindowSize:
|
|
|
|
parts = dm.getInfo('screen')['screen'][0].split()
|
|
|
|
width = int(parts[0].split(':')[1])
|
|
|
|
height = int(parts[1].split(':')[1])
|
|
|
|
if (width < 1050 or height < 1050):
|
|
|
|
print "ERROR: Invalid screen resolution %sx%s, please adjust to 1366x1050 or higher" % (width, height)
|
2012-06-13 18:20:43 +00:00
|
|
|
return 1
|
2011-02-23 19:38:59 +00:00
|
|
|
|
2010-06-24 09:32:01 +00:00
|
|
|
automation.setAppName(options.app)
|
|
|
|
automation.setRemoteProfile(options.remoteProfile)
|
2010-09-18 00:18:06 +00:00
|
|
|
automation.setRemoteLog(options.remoteLogFile)
|
2010-03-15 22:35:59 +00:00
|
|
|
reftest = RemoteReftest(automation, dm, options, SCRIPT_DIRECTORY)
|
2013-01-04 01:37:26 +00:00
|
|
|
options = parser.verifyCommonOptions(options, reftest)
|
2010-03-15 22:35:59 +00:00
|
|
|
|
2011-10-19 11:23:54 +00:00
|
|
|
# Hack in a symbolic link for jsreftest
|
|
|
|
os.system("ln -s ../jsreftest " + str(os.path.join(SCRIPT_DIRECTORY, "jsreftest")))
|
|
|
|
|
2011-02-26 18:19:56 +00:00
|
|
|
# Dynamically build the reftest URL if possible, beware that args[0] should exist 'inside' the webroot
|
2010-11-05 00:01:13 +00:00
|
|
|
manifest = args[0]
|
2011-02-26 18:19:56 +00:00
|
|
|
if os.path.exists(os.path.join(SCRIPT_DIRECTORY, args[0])):
|
2010-11-05 00:01:13 +00:00
|
|
|
manifest = "http://" + str(options.remoteWebServer) + ":" + str(options.httpPort) + "/" + args[0]
|
2011-02-26 18:19:56 +00:00
|
|
|
elif os.path.exists(args[0]):
|
|
|
|
manifestPath = os.path.abspath(args[0]).split(SCRIPT_DIRECTORY)[1].strip('/')
|
|
|
|
manifest = "http://" + str(options.remoteWebServer) + ":" + str(options.httpPort) + "/" + manifestPath
|
2011-10-19 09:35:05 +00:00
|
|
|
else:
|
|
|
|
print "ERROR: Could not find test manifest '%s'" % manifest
|
2012-06-13 18:20:43 +00:00
|
|
|
return 1
|
2011-10-19 09:35:05 +00:00
|
|
|
|
|
|
|
# Start the webserver
|
2012-06-13 18:20:43 +00:00
|
|
|
retVal = reftest.startWebServer(options)
|
|
|
|
if retVal:
|
|
|
|
return retVal
|
2010-11-05 00:01:13 +00:00
|
|
|
|
2011-02-23 19:38:56 +00:00
|
|
|
procName = options.app.split('/')[-1]
|
|
|
|
if (dm.processExist(procName)):
|
2011-12-20 21:33:41 +00:00
|
|
|
dm.killProcess(procName)
|
2011-02-23 19:38:56 +00:00
|
|
|
|
2013-06-25 00:15:40 +00:00
|
|
|
reftest.printDeviceInfo()
|
2012-07-26 00:45:36 +00:00
|
|
|
|
2010-03-15 22:35:59 +00:00
|
|
|
#an example manifest name to use on the cli
|
|
|
|
# manifest = "http://" + options.remoteWebServer + "/reftests/layout/reftests/reftest-sanity/reftest.list"
|
2012-10-24 17:34:33 +00:00
|
|
|
retVal = 0
|
2011-09-26 11:41:19 +00:00
|
|
|
try:
|
2011-12-20 21:33:41 +00:00
|
|
|
cmdlineArgs = ["-reftest", manifest]
|
|
|
|
if options.bootstrap:
|
|
|
|
cmdlineArgs = []
|
2012-06-13 18:20:43 +00:00
|
|
|
dm.recordLogcat()
|
2012-11-20 15:24:27 +00:00
|
|
|
retVal = reftest.runTests(manifest, options, cmdlineArgs)
|
2011-09-26 11:41:19 +00:00
|
|
|
except:
|
2012-11-05 13:03:54 +00:00
|
|
|
print "Automation Error: Exception caught while running tests"
|
|
|
|
traceback.print_exc()
|
2012-10-24 17:34:33 +00:00
|
|
|
retVal = 1
|
2011-09-26 11:41:19 +00:00
|
|
|
|
2010-06-24 09:32:01 +00:00
|
|
|
reftest.stopWebServer(options)
|
2013-06-25 00:15:40 +00:00
|
|
|
|
|
|
|
reftest.printDeviceInfo(printLogcat=True)
|
2012-10-24 17:34:33 +00:00
|
|
|
|
|
|
|
return retVal
|
2010-03-15 22:35:59 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2012-06-13 18:20:43 +00:00
|
|
|
sys.exit(main(sys.argv[1:]))
|
|
|
|
|