From ca359818f69b81cfbf31c21f6a80eaaabaf60a5e Mon Sep 17 00:00:00 2001 From: Serge Gautherie Date: Wed, 16 Sep 2009 17:50:03 +0200 Subject: [PATCH] Bug 469523 - xpcshell-tests: enable leak log in tinderbox (log); (Hv1) Use automationutils.dumpLeakLog(), fix/update automationutils.processLeakLog() log messages r=ted.mielczarek --- build/automationutils.py | 14 +++++++------- testing/xpcshell/runxpcshelltests.py | 28 +++++++--------------------- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/build/automationutils.py b/build/automationutils.py index e870f6be8f..d8516140c9 100644 --- a/build/automationutils.py +++ b/build/automationutils.py @@ -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() diff --git a/testing/xpcshell/runxpcshelltests.py b/testing/xpcshell/runxpcshelltests.py index 87a390f41a..141ee2eab9 100644 --- a/testing/xpcshell/runxpcshelltests.py +++ b/testing/xpcshell/runxpcshelltests.py @@ -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() -- 2.11.4.GIT