Bug 469518 - Enable Reftest leak log in tinderbox (log); (Ev1) Parse the log and support a leak threshold; r=jwalden+bmo

This commit is contained in:
Serge Gautherie 2009-04-05 15:03:46 +02:00
Родитель fd18eecc3c
Коммит b723e4b111
2 изменённых файлов: 51 добавлений и 23 удалений

Просмотреть файл

@ -68,6 +68,7 @@ __all__ = [
"DEFAULT_APP",
"CERTS_SRC_DIR",
"environment",
"dumpLeakLog",
]
# These are generated in mozilla/build/Makefile.in
@ -430,8 +431,35 @@ def checkForCrashes(profileDir, symbolsPath):
# RUN THE APP #
###############
def processLeakLog(leakLogFile, leakThreshold):
"Process the leak log."
def dumpLeakLog(leakLogFile, filter = False):
"""Process the leak log, without parsing it.
Use this function if you want the raw log only.
Use it preferably with the |XPCOM_MEM_LEAK_LOG| environment variable.
"""
# Don't warn (nor "info") if the log file is not there.
if not os.path.exists(leakLogFile):
return
leaks = open(leakLogFile, "r")
leakReport = leaks.read()
leaks.close()
# Only |XPCOM_MEM_LEAK_LOG| reports can be actually filtered out.
# Only check whether an actual leak was reported.
if filter and not "0 TOTAL " in leakReport:
return
# Simply copy the log.
log.info(leakReport.rstrip("\n"))
def processLeakLog(leakLogFile, leakThreshold = 0):
"""Process the leak log, parsing it.
Use this function if you want an additional PASS/FAIL summary.
It must be used with the |XPCOM_MEM_BLOAT_LOG| environment variable.
"""
if not os.path.exists(leakLogFile):
log.info("WARNING refcount logging is off, so leaks can't be detected!")

Просмотреть файл

@ -40,7 +40,6 @@
Runs the reftest test harness.
"""
import logging
import sys, shutil, os, os.path
SCRIPT_DIRECTORY = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
sys.path.append(SCRIPT_DIRECTORY)
@ -92,6 +91,14 @@ def main():
action = "store", type = "string", dest = "symbolsPath",
default = automation.SYMBOLS_PATH,
help = "absolute path to directory containing breakpad symbols")
parser.add_option("--leak-threshold",
action = "store", type = "int", dest = "leakThreshold",
default = 0,
help = "fail if the number of bytes leaked through "
"refcounted objects (or bytes in classes with "
"MOZ_COUNT_CTOR and MOZ_COUNT_DTOR) is greater "
"than the given number")
options, args = parser.parse_args()
if len(args) != 1:
@ -129,38 +136,31 @@ Are you executing $objdir/_tests/reftest/runreftest.py?""" \
browserEnv["MOZILLA_FIVE_HOME"] = options.xrePath
browserEnv["GNOME_DISABLE_CRASH_DIALOG"] = "1"
# Retrieve the logger where to report the leaks to.
log = logging.getLogger()
# Enable leaks (only) detection to its own log file.
# Enable leaks detection to its own log file.
leakLogFile = os.path.join(profileDir, "runreftest_leaks.log")
browserEnv["XPCOM_MEM_LEAK_LOG"] = leakLogFile
def processLeakLog():
"Process the leak log."
# For the time being, don't warn (nor "info") if the log file is not there. (Bug 469518)
if os.path.exists(leakLogFile):
leaks = open(leakLogFile, "r")
# For the time being, simply copy the log. (Bug 469518)
log.info(leaks.read().rstrip())
leaks.close()
browserEnv["XPCOM_MEM_BLOAT_LOG"] = leakLogFile
# run once with -silent to let the extension manager do its thing
# and then exit the app
log.info("REFTEST INFO | runreftest.py | Performing extension manager registration: start.\n")
automation.log.info("REFTEST INFO | runreftest.py | Performing extension manager registration: start.\n")
status = automation.runApp(None, browserEnv, options.app, profileDir,
extraArgs = ["-silent"],
symbolsPath=options.symbolsPath)
# We don't care to call |processLeakLog()| for this step.
log.info("\nREFTEST INFO | runreftest.py | Performing extension manager registration: end.")
# We don't care to call |automation.processLeakLog()| for this step.
automation.log.info("\nREFTEST INFO | runreftest.py | Performing extension manager registration: end.")
# 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(leakLogFile):
os.remove(leakLogFile)
# then again to actually run reftest
log.info("REFTEST INFO | runreftest.py | Running tests: start.\n")
automation.log.info("REFTEST INFO | runreftest.py | Running tests: start.\n")
reftestlist = getFullPath(args[0])
status = automation.runApp(None, browserEnv, options.app, profileDir,
extraArgs = ["-reftest", reftestlist])
processLeakLog()
log.info("\nREFTEST INFO | runreftest.py | Running tests: end.")
automation.processLeakLog(leakLogFile, options.leakThreshold)
automation.log.info("\nREFTEST INFO | runreftest.py | Running tests: end.")
finally:
if profileDir is not None:
shutil.rmtree(profileDir)