build/leaktest.py.in

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 #literal #!/usr/bin/python
michael@0 2 #
michael@0 3 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 6
michael@0 7 import SimpleHTTPServer
michael@0 8 import SocketServer
michael@0 9 import threading
michael@0 10 import os
michael@0 11 import sys
michael@0 12 import logging
michael@0 13 from getopt import getopt
michael@0 14 from automation import Automation
michael@0 15
michael@0 16 PORT = 8888
michael@0 17 SCRIPT_DIR = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
michael@0 18 PROFILE_DIRECTORY = os.path.abspath(os.path.join(SCRIPT_DIR, "./leakprofile"))
michael@0 19 os.chdir(SCRIPT_DIR)
michael@0 20
michael@0 21 class EasyServer(SocketServer.TCPServer):
michael@0 22 allow_reuse_address = True
michael@0 23
michael@0 24 if __name__ == '__main__':
michael@0 25 automation = Automation()
michael@0 26 DIST_BIN = os.path.join(SCRIPT_DIR, automation.DIST_BIN)
michael@0 27 opts, extraArgs = getopt(sys.argv[1:], 'l:')
michael@0 28 if len(opts) > 0:
michael@0 29 try:
michael@0 30 automation.log.addHandler(logging.FileHandler(opts[0][1], "w"))
michael@0 31 except:
michael@0 32 automation.log.info("Unable to open logfile " + opts[0][1] + \
michael@0 33 "ONLY logging to stdout.")
michael@0 34
michael@0 35 httpd = EasyServer(("", PORT), SimpleHTTPServer.SimpleHTTPRequestHandler)
michael@0 36 t = threading.Thread(target=httpd.serve_forever)
michael@0 37 t.setDaemon(True)
michael@0 38 t.start()
michael@0 39
michael@0 40 automation.setServerInfo("localhost", PORT)
michael@0 41
michael@0 42 # keep a profile reference so that it is not cleaned up immediately via __del__
michael@0 43 profile = automation.initializeProfile(PROFILE_DIRECTORY)
michael@0 44
michael@0 45 browserEnv = automation.environment()
michael@0 46
michael@0 47 if not "XPCOM_DEBUG_BREAK" in browserEnv:
michael@0 48 browserEnv["XPCOM_DEBUG_BREAK"] = "stack"
michael@0 49 url = "http://localhost:%d/bloatcycle.html" % PORT
michael@0 50 appPath = os.path.join(SCRIPT_DIR, automation.DEFAULT_APP)
michael@0 51 status = automation.runApp(url, browserEnv, appPath, PROFILE_DIRECTORY,
michael@0 52 extraArgs, timeout=1800)
michael@0 53 sys.exit(status)

mercurial