def runSerialTests(self, testPath, options, cmdlineArgs = None): debuggerInfo = getDebuggerInfo(self.oldcwd, options.debugger, options.debuggerArgs, options.debuggerInteractive); profileDir = None try: reftestlist = self.getManifestPath(testPath) if cmdlineArgs == None: cmdlineArgs = ['-reftest', reftestlist] profile = self.createReftestProfile(options, reftestlist) profileDir = profile.profile # name makes more sense # browser environment browserEnv = self.buildBrowserEnv(options, profileDir) self.automation.log.info("REFTEST INFO | runreftest.py | Running tests: start.\n") status = self.automation.runApp(None, browserEnv, options.app, profileDir, cmdlineArgs, utilityPath = options.utilityPath, xrePath=options.xrePath, debuggerInfo=debuggerInfo, symbolsPath=options.symbolsPath, # give the JS harness 30 seconds to deal # with its own timeouts timeout=options.timeout + 30.0) processLeakLog(self.leakLogFile, options.leakThreshold) self.automation.log.info("\nREFTEST INFO | runreftest.py | Running tests: end.") finally: self.cleanup(profileDir) return status
def runTests(self, options, onLaunch=None): """ Prepare, configure, run tests and cleanup """ debuggerInfo = getDebuggerInfo(self.oldcwd, options.debugger, options.debuggerArgs, options.debuggerInteractive); self.leak_report_file = os.path.join(options.profilePath, "runtests_leaks.log") browserEnv = self.buildBrowserEnv(options) if browserEnv is None: return 1 manifest = self.buildProfile(options) if manifest is None: return 1 self.startWebServer(options) self.startWebSocketServer(options, debuggerInfo) testURL = self.buildTestPath(options) self.buildURLOptions(options, browserEnv) if len(self.urlOpts) > 0: testURL += "?" + "&".join(self.urlOpts) if options.webapprtContent: options.browserArgs.extend(('-test-mode', testURL)) testURL = None if options.immersiveMode: options.browserArgs.extend(('-firefoxpath', options.app)) options.app = self.immersiveHelperPath # Remove the leak detection file so it can't "leak" to the tests run. # The file is not there if leak logging was not enabled in the application build. if os.path.exists(self.leak_report_file): os.remove(self.leak_report_file) # then again to actually run mochitest if options.timeout: timeout = options.timeout + 30 elif options.debugger or not options.autorun: timeout = None else: timeout = 330.0 # default JS harness timeout is 300 seconds if options.vmwareRecording: self.startVMwareRecording(options); log.info("runtests.py | Running tests: start.\n") try: status = self.automation.runApp(testURL, browserEnv, options.app, options.profilePath, options.browserArgs, runSSLTunnel=self.runSSLTunnel, utilityPath=options.utilityPath, xrePath=options.xrePath, certPath=options.certPath, debuggerInfo=debuggerInfo, symbolsPath=options.symbolsPath, timeout=timeout, onLaunch=onLaunch) except KeyboardInterrupt: log.info("runtests.py | Received keyboard interrupt.\n"); status = -1 except: traceback.print_exc() log.error("runtests.py | Received unexpected exception while running application\n") status = 1 if options.vmwareRecording: self.stopVMwareRecording(); self.stopWebServer(options) self.stopWebSocketServer(options) processLeakLog(self.leak_report_file, options.leakThreshold) log.info("runtests.py | Running tests: end.") if manifest is not None: self.cleanup(manifest, options) return status
def runTests(self, options, onLaunch=None): """ Prepare, configure, run tests and cleanup """ debuggerInfo = getDebuggerInfo(self.oldcwd, options.debugger, options.debuggerArgs, options.debuggerInteractive) self.leak_report_file = os.path.join(options.profilePath, "runtests_leaks.log") browserEnv = self.buildBrowserEnv(options) if browserEnv is None: return 1 manifest = self.buildProfile(options) if manifest is None: return 1 self.startWebServer(options) self.startWebSocketServer(options, debuggerInfo) testURL = self.buildTestPath(options) self.buildURLOptions(options, browserEnv) if len(self.urlOpts) > 0: testURL += "?" + "&".join(self.urlOpts) if options.webapprtContent: options.browserArgs.extend(('-test-mode', testURL)) testURL = None if options.immersiveMode: options.browserArgs.extend(('-firefoxpath', options.app)) options.app = self.immersiveHelperPath # Remove the leak detection file so it can't "leak" to the tests run. # The file is not there if leak logging was not enabled in the application build. if os.path.exists(self.leak_report_file): os.remove(self.leak_report_file) # then again to actually run mochitest if options.timeout: timeout = options.timeout + 30 elif options.debugger or not options.autorun: timeout = None else: timeout = 330.0 # default JS harness timeout is 300 seconds if options.vmwareRecording: self.startVMwareRecording(options) log.info("runtests.py | Running tests: start.\n") try: status = self.automation.runApp(testURL, browserEnv, options.app, options.profilePath, options.browserArgs, runSSLTunnel=self.runSSLTunnel, utilityPath=options.utilityPath, xrePath=options.xrePath, certPath=options.certPath, debuggerInfo=debuggerInfo, symbolsPath=options.symbolsPath, timeout=timeout, onLaunch=onLaunch) except KeyboardInterrupt: log.info("runtests.py | Received keyboard interrupt.\n") status = -1 except: traceback.print_exc() log.error( "runtests.py | Received unexpected exception while running application\n" ) status = 1 if options.vmwareRecording: self.stopVMwareRecording() self.stopWebServer(options) self.stopWebSocketServer(options) processLeakLog(self.leak_report_file, options.leakThreshold) log.info("runtests.py | Running tests: end.") if manifest is not None: self.cleanup(manifest, options) return status
class EasyServer(SocketServer.TCPServer): allow_reuse_address = True if __name__ == '__main__': from optparse import OptionParser automation = Automation() parser = OptionParser() addCommonOptions(parser) options, args = parser.parse_args() debuggerInfo = getDebuggerInfo(".", options.debugger, options.debuggerArgs, options.debuggerInteractive) httpd = EasyServer(("", PORT), SimpleHTTPServer.SimpleHTTPRequestHandler) t = threading.Thread(target=httpd.serve_forever) t.setDaemon(True) # don't hang on exit t.start() automation.setServerInfo("localhost", PORT) automation.initializeProfile(PROFILE_DIRECTORY) browserEnv = automation.environment() browserEnv["XPCOM_DEBUG_BREAK"] = "warn" browserEnv["MOZ_JAR_LOG_DIR"] = MOZ_JAR_LOG_DIR url = "http://localhost:%d/index.html" % PORT appPath = os.path.join(SCRIPT_DIR, automation.DEFAULT_APP) status = automation.runApp(
def runBrowser(): parser = OptionParser() # we want to pass down everything from automation.__all__ parser.add_option("--valgrind", action="store_true", dest="valgrind", default=False, help="use valgrind with the options given in --vgargs") parser.add_option("--vgargs", action="store", dest="vgargs", default=None, help="space-separated arguments to give to valgrind") parser.add_option("--symbols-dir", action="store", dest="symbolsDir", default=None) parser.add_option("--leak-log-file", action="store", dest="leakLogFile", default=None) parser.add_option("--background", action="store_true", dest="background", default=False) options, args = parser.parse_args(sys.argv) reftestScriptDir = args[1] utilityDir = args[2] profileDir = args[3] url = args[4] sys.path.append(reftestScriptDir) sys.path.append(os.path.join(reftestScriptDir, "..", "mozbase", "mozinfo")) sys.path.append(os.path.join(reftestScriptDir, "..", "mozbase", "mozfile")) try: from automation import Automation except ImportError: # The first time running from a local objdir, I get "ImportError: No module named mozcrash". # The correct fix is to use virtualenv: https://bugzilla.mozilla.org/show_bug.cgi?id=903616#c12 # For now, just try again. from automation import Automation import automationutils automation = Automation() theapp = os.path.join(reftestScriptDir, automation.DEFAULT_APP) if not os.path.exists(theapp): print "RUNBROWSER ERROR | runbrowser.py | Application %s doesn't exist." % theapp sys.exit(1) print "theapp: " + theapp xrePath = os.path.dirname(theapp) if options.valgrind: print "About to use valgrind" debuggerInfoVG = automationutils.getDebuggerInfo(oldcwd, "valgrind", "", False) debuggerInfoVG["args"] = options.vgargs.split(" ") if automation.IS_MAC: debuggerInfoVG["args"].append("--dsymutil=yes") slowness = 3.0 else: debuggerInfoVG = None slowness = 1.0 # browser environment browserEnv = automation.environment(xrePath=xrePath) gatherAssertionStacks = not automation.IS_WIN32 # bug 573306 browserEnv["XPCOM_DEBUG_BREAK"] = "stack" if gatherAssertionStacks else "warn" browserEnv["MOZ_GDB_SLEEP"] = "2" # seconds if not options.valgrind and "-asan" not in theapp: browserEnv["MallocScribble"] = "1" browserEnv["MallocPreScribble"] = "1" if options.valgrind and automation.IS_LINUX: browserEnv["G_SLICE"] = "always-malloc" if automation.IS_DEBUG_BUILD and not options.valgrind and options.leakLogFile: browserEnv["XPCOM_MEM_LEAK_LOG"] = options.leakLogFile browserEnv["MOZ_DISABLE_SAFE_MODE_KEY"] = "1" # Defeat Lion's misguided attempt to stop Firefox from crashing repeatedly. # (I suspect "restorecount.txt" is the most important file to remove.) removeDirIfExists(os.path.expanduser("~/Library/Saved Application State/org.mozilla.nightly.savedState")) removeDirIfExists(os.path.expanduser("~/Library/Saved Application State/org.mozilla.nightlydebug.savedState")) cmdLineArgs = [] if "#fuzz=" in url: cmdLineArgs.append("-fuzzinject") cmdLineArgs.append(url) print "RUNBROWSER INFO | runbrowser.py | runApp: start." print "RUNBROWSER INFO | runbrowser.py | " + url if options.background: automation.buildCommandLine = stripForegroundArg(automation.buildCommandLine) status = automation.runApp(None, browserEnv, theapp, profileDir, cmdLineArgs, utilityPath=utilityDir, xrePath=xrePath, symbolsPath=options.symbolsDir, debuggerInfo=debuggerInfoVG, maxTime=400.0 * slowness, timeout=200.0 * slowness) print "RUNBROWSER INFO | runbrowser.py | runApp: exited with status " + str(status)
MOZ_JAR_LOG_DIR = os.path.abspath(os.path.join(os.path.join(os.getenv("OBJDIR"), "dist"), "jarlog")) os.chdir(SCRIPT_DIR) class EasyServer(SocketServer.TCPServer): allow_reuse_address = True if __name__ == '__main__': from optparse import OptionParser automation = Automation() parser = OptionParser() addCommonOptions(parser) options, args = parser.parse_args() debuggerInfo = getDebuggerInfo(".", options.debugger, options.debuggerArgs, options.debuggerInteractive) httpd = EasyServer(("", PORT), SimpleHTTPServer.SimpleHTTPRequestHandler) t = threading.Thread(target=httpd.serve_forever) t.setDaemon(True) # don't hang on exit t.start() automation.setServerInfo("localhost", PORT) automation.initializeProfile(PROFILE_DIRECTORY) browserEnv = automation.environment() browserEnv["XPCOM_DEBUG_BREAK"] = "warn" browserEnv["MOZ_JAR_LOG_DIR"] = MOZ_JAR_LOG_DIR url = "http://localhost:%d/index.html" % PORT appPath = os.path.join(SCRIPT_DIR, automation.DEFAULT_APP) status = automation.runApp(url, browserEnv, appPath, PROFILE_DIRECTORY, {},
def runBrowser(): parser = OptionParser() # we want to pass down everything from automation.__all__ parser.add_option("--valgrind", action="store_true", dest="valgrind", default=False, help="use valgrind with the options given in --vgargs") parser.add_option("--vgargs", action="store", dest="vgargs", default=None, help="space-separated arguments to give to valgrind") parser.add_option("--symbols-dir", action="store", dest="symbolsDir", default=None) parser.add_option("--leak-log-file", action="store", dest="leakLogFile", default=None) parser.add_option("--background", action="store_true", dest="background", default=False) options, args = parser.parse_args(sys.argv) reftestScriptDir = args[1] utilityDir = args[2] profileDir = args[3] url = args[4] sys.path.append(reftestScriptDir) sys.path.append(os.path.join(reftestScriptDir, "..", "mozbase", "mozinfo")) sys.path.append(os.path.join(reftestScriptDir, "..", "mozbase", "mozfile")) try: from automation import Automation except ImportError: # The first time running from a local objdir, I get "ImportError: No module named mozcrash". # The correct fix is to use virtualenv: https://bugzilla.mozilla.org/show_bug.cgi?id=903616#c12 # For now, just try again. from automation import Automation import automationutils automation = Automation() theapp = os.path.join(reftestScriptDir, automation.DEFAULT_APP) if not os.path.exists(theapp): print "RUNBROWSER ERROR | runbrowser.py | Application %s doesn't exist." % theapp sys.exit(1) print "theapp: " + theapp xrePath = os.path.dirname(theapp) if options.valgrind: print "About to use valgrind" debuggerInfoVG = automationutils.getDebuggerInfo( oldcwd, "valgrind", "", False) debuggerInfoVG["args"] = options.vgargs.split(" ") if automation.IS_MAC: debuggerInfoVG["args"].append("--dsymutil=yes") slowness = 3.0 else: debuggerInfoVG = None slowness = 1.0 # browser environment browserEnv = automation.environment(xrePath=xrePath) gatherAssertionStacks = not automation.IS_WIN32 # bug 573306 browserEnv[ "XPCOM_DEBUG_BREAK"] = "stack" if gatherAssertionStacks else "warn" browserEnv["MOZ_GDB_SLEEP"] = "2" # seconds if not options.valgrind and "-asan" not in theapp: browserEnv["MallocScribble"] = "1" browserEnv["MallocPreScribble"] = "1" if options.valgrind and automation.IS_LINUX: browserEnv["G_SLICE"] = "always-malloc" if automation.IS_DEBUG_BUILD and not options.valgrind and options.leakLogFile: browserEnv["XPCOM_MEM_LEAK_LOG"] = options.leakLogFile browserEnv["MOZ_DISABLE_SAFE_MODE_KEY"] = "1" # Defeat Lion's misguided attempt to stop Firefox from crashing repeatedly. # (I suspect "restorecount.txt" is the most important file to remove.) removeDirIfExists( os.path.expanduser( "~/Library/Saved Application State/org.mozilla.nightly.savedState") ) removeDirIfExists( os.path.expanduser( "~/Library/Saved Application State/org.mozilla.nightlydebug.savedState" )) cmdLineArgs = [] if "#fuzz=" in url: cmdLineArgs.append("-fuzzinject") cmdLineArgs.append(url) print "RUNBROWSER INFO | runbrowser.py | runApp: start." print "RUNBROWSER INFO | runbrowser.py | " + url if options.background: automation.buildCommandLine = stripForegroundArg( automation.buildCommandLine) status = automation.runApp(None, browserEnv, theapp, profileDir, cmdLineArgs, utilityPath=utilityDir, xrePath=xrePath, symbolsPath=options.symbolsDir, debuggerInfo=debuggerInfoVG, maxTime=400.0 * slowness, timeout=200.0 * slowness) print "RUNBROWSER INFO | runbrowser.py | runApp: exited with status " + str( status)