mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 04:38:02 +00:00
Bug 469523 - xpcshell-tests: enable leak log in tinderbox (log); (Hv1) Use automationutils.dumpLeakLog(), fix/update automationutils.processLeakLog() log messages
r=ted.mielczarek
This commit is contained in:
parent
dea07412a1
commit
bd635f12a4
@ -118,7 +118,7 @@ def processLeakLog(leakLogFile, leakThreshold = 0):
|
||||
"""
|
||||
|
||||
if not os.path.exists(leakLogFile):
|
||||
log.info("WARNING refcount logging is off, so leaks can't be detected!")
|
||||
log.info("WARNING | automationutils.processLeakLog() | refcount logging is off, so leaks can't be detected!")
|
||||
return
|
||||
|
||||
# Per-Inst Leaked Total Rem ...
|
||||
@ -150,7 +150,7 @@ def processLeakLog(leakLogFile, leakThreshold = 0):
|
||||
bytesLeaked = int(matches.group("bytesLeaked"))
|
||||
numLeaked = int(matches.group("numLeaked"))
|
||||
if size < 0 or bytesLeaked < 0 or numLeaked < 0:
|
||||
log.info("TEST-UNEXPECTED-FAIL | runtests-leaks | negative leaks caught!")
|
||||
log.info("TEST-UNEXPECTED-FAIL | automationutils.processLeakLog() | negative leaks caught!")
|
||||
if name == "TOTAL":
|
||||
seenTotal = True
|
||||
elif name == "TOTAL":
|
||||
@ -158,13 +158,13 @@ def processLeakLog(leakLogFile, leakThreshold = 0):
|
||||
# Check for leaks.
|
||||
if bytesLeaked < 0 or bytesLeaked > leakThreshold:
|
||||
prefix = "TEST-UNEXPECTED-FAIL"
|
||||
leakLog = "TEST-UNEXPECTED-FAIL | runtests-leaks | leaked" \
|
||||
leakLog = "TEST-UNEXPECTED-FAIL | automationutils.processLeakLog() | leaked" \
|
||||
" %d bytes during test execution" % bytesLeaked
|
||||
elif bytesLeaked > 0:
|
||||
leakLog = "TEST-PASS | runtests-leaks | WARNING leaked" \
|
||||
leakLog = "TEST-PASS | automationutils.processLeakLog() | WARNING leaked" \
|
||||
" %d bytes during test execution" % bytesLeaked
|
||||
else:
|
||||
leakLog = "TEST-PASS | runtests-leaks | no leaks detected!"
|
||||
leakLog = "TEST-PASS | automationutils.processLeakLog() | no leaks detected!"
|
||||
# Remind the threshold if it is not 0, which is the default/goal.
|
||||
if leakThreshold != 0:
|
||||
leakLog += " (threshold set at %d bytes)" % leakThreshold
|
||||
@ -178,7 +178,7 @@ def processLeakLog(leakLogFile, leakThreshold = 0):
|
||||
else:
|
||||
instance = "instance"
|
||||
rest = ""
|
||||
log.info("%(prefix)s | runtests-leaks | leaked %(numLeaked)d %(instance)s of %(name)s "
|
||||
log.info("%(prefix)s | automationutils.processLeakLog() | leaked %(numLeaked)d %(instance)s of %(name)s "
|
||||
"with size %(size)s bytes%(rest)s" %
|
||||
{ "prefix": prefix,
|
||||
"numLeaked": numLeaked,
|
||||
@ -187,5 +187,5 @@ def processLeakLog(leakLogFile, leakThreshold = 0):
|
||||
"size": matches.group("size"),
|
||||
"rest": rest })
|
||||
if not seenTotal:
|
||||
log.info("TEST-UNEXPECTED-FAIL | runtests-leaks | missing output line for total leaks!")
|
||||
log.info("TEST-UNEXPECTED-FAIL | automationutils.processLeakLog() | missing output line for total leaks!")
|
||||
leaks.close()
|
||||
|
@ -44,7 +44,7 @@ from optparse import OptionParser
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
from tempfile import mkdtemp
|
||||
|
||||
from automationutils import addCommonOptions, checkForCrashes
|
||||
from automationutils import addCommonOptions, checkForCrashes, dumpLeakLog
|
||||
|
||||
# Init logging
|
||||
log = logging.getLogger()
|
||||
@ -107,23 +107,6 @@ def runTests(xpcshell, testdirs=[], xrePath=None, testPath=None,
|
||||
leakLogFile = os.path.join(tempfile.gettempdir(), "runxpcshelltests_leaks.log")
|
||||
env["XPCOM_MEM_LEAK_LOG"] = leakLogFile
|
||||
|
||||
def processLeakLog(leakLogFile):
|
||||
"""Process the leak log."""
|
||||
# For the time being, don't warn (nor "info") if the log file is not there. (Bug 469523)
|
||||
if not os.path.exists(leakLogFile):
|
||||
return None
|
||||
|
||||
leaks = open(leakLogFile, "r")
|
||||
leakReport = leaks.read()
|
||||
leaks.close()
|
||||
|
||||
# Only check whether an actual leak was reported.
|
||||
if "0 TOTAL " in leakReport:
|
||||
# For the time being, simply copy the log. (Bug 469523)
|
||||
print leakReport.rstrip("\n")
|
||||
|
||||
return leakReport
|
||||
|
||||
if xrePath is None:
|
||||
xrePath = os.path.dirname(xpcshell)
|
||||
else:
|
||||
@ -249,14 +232,17 @@ def runTests(xpcshell, testdirs=[], xrePath=None, testPath=None,
|
||||
print "TEST-PASS | %s | test passed" % test
|
||||
passCount += 1
|
||||
|
||||
leakReport = processLeakLog(leakLogFile)
|
||||
dumpLeakLog(leakLogFile, True)
|
||||
|
||||
if stdout is not None:
|
||||
try:
|
||||
f = open(test + '.log', 'w')
|
||||
f.write(stdout)
|
||||
if leakReport:
|
||||
f.write(leakReport)
|
||||
|
||||
if os.path.exists(leakLogFile):
|
||||
leaks = open(leakLogFile, "r")
|
||||
f.write(leaks.read())
|
||||
leaks.close()
|
||||
finally:
|
||||
if f:
|
||||
f.close()
|
||||
|
Loading…
x
Reference in New Issue
Block a user