diff --git a/build/pgo/automation.py.in b/build/pgo/automation.py.in index 704fe59d2db..5e11f5b143f 100644 --- a/build/pgo/automation.py.in +++ b/build/pgo/automation.py.in @@ -65,7 +65,6 @@ __all__ = [ "initializeProfile", "DIST_BIN", "DEFAULT_APP", - "CERTS_SRC_DIR", "environment", ] @@ -84,6 +83,7 @@ IS_CYGWIN = False UNIXISH = not IS_WIN32 and not IS_MAC #expand DEFAULT_APP = "./" + __BROWSER_PATH__ +#expand PROFILE_DIR = __PROFILE_DIR__ #expand CERTS_SRC_DIR = __CERTS_SRC_DIR__ #expand IS_TEST_BUILD = __IS_TEST_BUILD__ #expand IS_DEBUG_BUILD = __IS_DEBUG_BUILD__ @@ -318,7 +318,8 @@ user_pref("camino.use_system_proxy_settings", false); // Camino-only, harmless t prefsFile.write("".join(prefs)) prefsFile.close() -def fillCertificateDB(profileDir, certPath, utilityPath, xrePath): +def fillCertificateDB(profileDir): + pwfilePath = os.path.join(profileDir, ".crtdbpw") pwfile = open(pwfilePath, "w") @@ -326,11 +327,11 @@ def fillCertificateDB(profileDir, certPath, utilityPath, xrePath): pwfile.close() # Create head of the ssltunnel configuration file - sslTunnelConfigPath = os.path.join(profileDir, "ssltunnel.cfg") + sslTunnelConfigPath = os.path.join(PROFILE_DIR, "ssltunnel.cfg") sslTunnelConfig = open(sslTunnelConfigPath, "w") sslTunnelConfig.write("httpproxy:1\n") - sslTunnelConfig.write("certdbdir:%s\n" % certPath) + sslTunnelConfig.write("certdbdir:%s\n" % CERTS_SRC_DIR) sslTunnelConfig.write("forward:127.0.0.1:8888\n") sslTunnelConfig.write("listen:*:4443:pgo server certificate\n") @@ -357,47 +358,41 @@ def fillCertificateDB(profileDir, certPath, utilityPath, xrePath): sslTunnelConfig.close() # Pre-create the certification database for the profile - env = environment(xrePath = xrePath) - certutil = os.path.join(utilityPath, "certutil" + BIN_SUFFIX) - pk12util = os.path.join(utilityPath, "pk12util" + BIN_SUFFIX) + certutil = DIST_BIN + "/certutil" + BIN_SUFFIX + pk12util = DIST_BIN + "/pk12util" + BIN_SUFFIX - status = Process([certutil, "-N", "-d", profileDir, "-f", pwfilePath], env = env).wait() + status = Process([certutil, "-N", "-d", profileDir, "-f", pwfilePath], env = environment()).wait() if status != 0: return status # Walk the cert directory and add custom CAs and client certs - files = os.listdir(certPath) + files = os.listdir(CERTS_SRC_DIR) for item in files: root, ext = os.path.splitext(item) if ext == ".ca": trustBits = "CT,," if root.endswith("-object"): trustBits = "CT,,CT" - Process([certutil, "-A", "-i", os.path.join(certPath, item), + Process([certutil, "-A", "-i", os.path.join(CERTS_SRC_DIR, item), "-d", profileDir, "-f", pwfilePath, "-n", root, "-t", trustBits], - env = env).wait() + env = environment()).wait() if ext == ".client": - Process([pk12util, "-i", os.path.join(certPath, item), "-w", + Process([pk12util, "-i", os.path.join(CERTS_SRC_DIR, item), "-w", pwfilePath, "-d", profileDir], - env = env).wait() + env = environment()).wait() os.unlink(pwfilePath) return 0 -def environment(env = None, xrePath = DIST_BIN): +def environment(env = None): if env == None: env = dict(os.environ) - ldLibraryPath = os.path.abspath(os.path.join(SCRIPT_DIR, xrePath)) - if UNIXISH or IS_MAC: - envVar = "LD_LIBRARY_PATH" - if IS_MAC: - envVar = "DYLD_LIBRARY_PATH" - if envVar in env: - ldLibraryPath = ldLibraryPath + ":" + env[envVar] - env[envVar] = ldLibraryPath - elif IS_WIN32: - env["PATH"] = env["PATH"] + ";" + ldLibraryPath + if UNIXISH: + ldLibraryPath = os.path.join(SCRIPT_DIR, DIST_BIN) + if "LD_LIBRARY_PATH" in env: + ldLibraryPath = ldLibraryPath + ":" + env["LD_LIBRARY_PATH"] + env["LD_LIBRARY_PATH"] = ldLibraryPath return env @@ -405,18 +400,18 @@ def environment(env = None, xrePath = DIST_BIN): # RUN THE APP # ############### -def runApp(testURL, env, app, profileDir, extraArgs, utilityPath = DIST_BIN, xrePath = DIST_BIN, certPath = CERTS_SRC_DIR): +def runApp(testURL, env, app, profileDir, extraArgs): "Run the app, returning a tuple containing the status code and the time at which it was started." if (IS_TEST_BUILD): # create certificate database for the profile - certificateStatus = fillCertificateDB(profileDir, certPath, utilityPath, xrePath) + certificateStatus = fillCertificateDB(profileDir) if certificateStatus != 0: log.info("ERROR FAIL Certificate integration") return certificateStatus # start ssltunnel to provide https:// URLs capability - ssltunnel = os.path.join(utilityPath, "ssltunnel" + BIN_SUFFIX) - ssltunnelProcess = Process([ssltunnel, os.path.join(profileDir, "ssltunnel.cfg")], env = environment(xrePath = xrePath)) + ssltunnel = DIST_BIN + "/ssltunnel" + BIN_SUFFIX + ssltunnelProcess = Process([ssltunnel, os.path.join(PROFILE_DIR, "ssltunnel.cfg")], env = environment()) log.info("SSL tunnel pid: %d", ssltunnelProcess.pid) "Run the app, returning the time at which it was started." diff --git a/testing/mochitest/runtests.py.in b/testing/mochitest/runtests.py.in index 24f7b63a9d8..e99ff42155a 100644 --- a/testing/mochitest/runtests.py.in +++ b/testing/mochitest/runtests.py.in @@ -49,7 +49,6 @@ import os.path import re import sys import time -import shutil from urllib import quote_plus as encodeURIComponent import urllib2 import commands @@ -107,23 +106,7 @@ class MochitestOptions(optparse.OptionParser): self.add_option("--appname", action = "store", type = "string", dest = "app", help = "absolute path to application, overriding default") - defaults["app"] = os.path.join(SCRIPT_DIRECTORY, automation.DEFAULT_APP) - - self.add_option("--xre-path", - action = "store", type = "string", dest = "xrePath", - help = "absolute path to directory containing XRE (probably xulrunner)") - # we'll default this to the directory of app below - defaults["xrePath"] = None - - self.add_option("--utility-path", - action = "store", type = "string", dest = "utilityPath", - help = "absolute path to directory containing utility programs (xpcshell, ssltunnel, certutil)") - defaults["utilityPath"] = automation.DIST_BIN - - self.add_option("--certificate-path", - action = "store", type = "string", dest = "certPath", - help = "absolute path to directory containing certificate store to use testing profile") - defaults["certPath"] = automation.CERTS_SRC_DIR + defaults["app"] = automation.DEFAULT_APP self.add_option("--log-file", action = "store", type = "string", @@ -201,11 +184,6 @@ class MochitestOptions(optparse.OptionParser): "(requires a debug build to be effective)") defaults["fatalAssertions"] = False - self.add_option("--extra-profile-file", - action = "append", dest = "extraProfileFiles", - help = "copy specified files/dirs to testing profile") - defaults["extraProfileFiles"] = [] - # -h, --help are automatically handled by OptionParser self.set_defaults(**defaults) @@ -229,29 +207,21 @@ class MochitestServer: def __init__(self, options): self._closeWhenDone = options.closeWhenDone - self._utilityPath = options.utilityPath - self._xrePath = options.xrePath def start(self): "Run the Mochitest server, returning the process ID of the server." env = dict(os.environ) if automation.UNIXISH: - env["LD_LIBRARY_PATH"] = self._xrePath - env["MOZILLA_FIVE_HOME"] = self._xrePath + env["LD_LIBRARY_PATH"] = automation.DIST_BIN + env["MOZILLA_FIVE_HOME"] = automation.DIST_BIN env["XPCOM_DEBUG_BREAK"] = "warn" - if automation.IS_MAC: - env["DYLD_LIBRARY_PATH"] = self._xrePath - elif automation.IS_WIN32: - env["PATH"] = env["PATH"] + ";" + self._xrePath - args = ["-g", self._xrePath, - "-v", "170", + args = ["-v", "170", "-f", "./" + "httpd.js", "-f", "./" + "server.js"] - xpcshell = os.path.join(self._utilityPath, - "xpcshell" + automation.BIN_SUFFIX) + xpcshell = automation.DIST_BIN + "/" + "xpcshell"; self._process = automation.Process([xpcshell] + args, env = env) pid = self._process.pid if pid < 0: @@ -263,7 +233,7 @@ class MochitestServer: def ensureReady(self, timeout): assert timeout >= 0 - aliveFile = os.path.join(PROFILE_DIRECTORY, "server_alive.txt") + aliveFile = PROFILE_DIRECTORY + "/" + "server_alive.txt" i = 0 while i < timeout: if os.path.exists(aliveFile): @@ -284,9 +254,6 @@ class MochitestServer: except: self._process.kill() -def getFullPath(path): - "Get an absolute path relative to oldcwd." - return os.path.normpath(os.path.join(oldcwd, os.path.expanduser(path))) ################# # MAIN FUNCTION # @@ -302,7 +269,6 @@ def main(): # enforced, just pass an explicit --leak-threshold=N to prevent the override. maybeForceLeakThreshold(options) - options.app = getFullPath(options.app) if not os.path.exists(options.app): msg = """\ Error: Path %(app)s doesn't exist. @@ -310,16 +276,6 @@ Are you executing $objdir/_tests/testing/mochitest/runtests.py?""" print msg % {"app": options.app} sys.exit(1) - # default xrePath to the app path if not provided - if options.xrePath is None: - options.xrePath = os.path.dirname(options.app) - else: - # allow relative paths - options.xrePath = getFullPath(options.xrePath) - - options.utilityPath = getFullPath(options.utilityPath) - options.certPath = getFullPath(options.certPath) - # browser environment browserEnv = dict(os.environ) @@ -327,10 +283,9 @@ Are you executing $objdir/_tests/testing/mochitest/runtests.py?""" # via the commandline at your own risk. browserEnv["NO_EM_RESTART"] = "1" browserEnv["XPCOM_DEBUG_BREAK"] = "warn" - appDir = os.path.dirname(options.app) if automation.UNIXISH: - browserEnv["LD_LIBRARY_PATH"] = appDir - browserEnv["MOZILLA_FIVE_HOME"] = appDir + browserEnv["LD_LIBRARY_PATH"] = automation.DIST_BIN + browserEnv["MOZILLA_FIVE_HOME"] = automation.DIST_BIN browserEnv["GNOME_DISABLE_CRASH_DIALOG"] = "1" for v in options.environment: @@ -342,7 +297,6 @@ Are you executing $objdir/_tests/testing/mochitest/runtests.py?""" automation.initializeProfile(PROFILE_DIRECTORY) manifest = addChromeToProfile(options) - copyExtraFilesToProfile(options) server = MochitestServer(options) server.start() @@ -379,7 +333,8 @@ Are you executing $objdir/_tests/testing/mochitest/runtests.py?""" # allow relative paths for logFile if options.logFile: - options.logFile = getFullPath(options.logFile) + logpath = os.path.join(oldcwd, os.path.expanduser(options.logFile)) + options.logFile = os.path.normpath(logpath) if options.browserChrome: makeTestConfig(options) else: @@ -401,10 +356,7 @@ Are you executing $objdir/_tests/testing/mochitest/runtests.py?""" browserEnv["XPCOM_DEBUG_BREAK"] = "stack-and-abort" (status, start) = automation.runApp(testURL, browserEnv, options.app, - PROFILE_DIRECTORY, options.browserArgs, - utilityPath=options.utilityPath, - xrePath=options.xrePath, - certPath=options.certPath) + PROFILE_DIRECTORY, options.browserArgs) # Server's no longer needed, and perhaps more importantly, anything it might # spew to console shouldn't disrupt the leak information table we print next. @@ -542,7 +494,7 @@ def makeTestConfig(options): "logPath": logFile, "testPath": testPath} - config = open(os.path.join(PROFILE_DIRECTORY, "testConfig.js"), "w") + config = open(PROFILE_DIRECTORY + "/" + "testConfig.js", "w") config.write(content) config.close() @@ -550,7 +502,7 @@ def makeTestConfig(options): def addChromeToProfile(options): "Adds MochiKit chrome tests to the profile." - chromedir = os.path.join(PROFILE_DIRECTORY, "chrome") + chromedir = PROFILE_DIRECTORY + "/" + "chrome" os.mkdir(chromedir) chrome = [] @@ -570,7 +522,7 @@ toolbar#nav-bar { # write userChrome.css - chromeFile = open(os.path.join(PROFILE_DIRECTORY, "userChrome.css"), "a") + chromeFile = open(PROFILE_DIRECTORY + "/" + "userChrome.css", "a") chromeFile.write("".join(chrome)) chromeFile.close() @@ -582,7 +534,7 @@ toolbar#nav-bar { (path, leaf) = os.path.split(options.app) - manifest = os.path.join(path, "chrome", "mochikit.manifest") + manifest = path + "/" + "chrome/mochikit.manifest" manifestFile = open(manifest, "w") manifestFile.write("content mochikit " + chrometestDir + " contentaccessible=yes\n") if options.browserChrome: @@ -593,16 +545,6 @@ toolbar#nav-bar { return manifest -def copyExtraFilesToProfile(options): - "Copy extra files or dirs specified on the command line to the testing profile." - for f in options.extraProfileFiles: - abspath = getFullPath(f) - dest = os.path.join(PROFILE_DIRECTORY, os.path.basename(abspath)) - if os.path.isdir(abspath): - shutil.copytree(abspath, dest) - else: - shutil.copy(abspath, dest) - ######### # DO IT # ######### diff --git a/testing/mochitest/server.js b/testing/mochitest/server.js index 8efc54171da..26a68338a34 100644 --- a/testing/mochitest/server.js +++ b/testing/mochitest/server.js @@ -134,7 +134,15 @@ var serverBasePath; // function runServer() { - serverBasePath = __LOCATION__.parent; + serverBasePath = Cc["@mozilla.org/file/local;1"] + .createInstance(Ci.nsILocalFile); + var procDir = Cc["@mozilla.org/file/directory_service;1"] + .getService(Ci.nsIProperties).get("CurProcD", Ci.nsIFile); + serverBasePath.initWithPath(procDir.parent.parent.path); + serverBasePath.append("_tests"); + serverBasePath.append("testing"); + serverBasePath.append("mochitest"); + server = createMochitestServer(serverBasePath); server.start(SERVER_PORT);