Bug 1076969 - processLeakLog should come up with reasonable defaults itself. r=jmaher

Instead of grabbing attributes off options at every call site, pass
in the options object to processLeakLog, and attempt to get the attributes
there. If not present, use a restrictive default value.

This will prevent silent harness failures if one of the many ways to invoke
processLeakLog fails to set up these options, and makes it so they
don't have to set it up if they don't care.
This commit is contained in:
Andrew McCreight 2014-10-06 14:23:17 -07:00
Родитель 3ba19a1445
Коммит f3d650b7c0
6 изменённых файлов: 14 добавлений и 13 удалений

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

@ -309,7 +309,7 @@ def processSingleLeakFile(leakLogFileName, processType, leakThreshold, ignoreMis
log.info("%s | leakcheck | %s %d bytes leaked (%s)"
% (prefix, processString, totalBytesLeaked, leakedObjectSummary))
def processLeakLog(leakLogFile, leakThresholds, ignoreMissingLeaks):
def processLeakLog(leakLogFile, options):
"""Process the leak log, including separate leak logs created
by child processes.
@ -325,15 +325,25 @@ def processLeakLog(leakLogFile, leakThresholds, ignoreMissingLeaks):
All other file names are treated as being for default processes.
The options argument is checked for two optional attributes,
leakThresholds and ignoreMissingLeaks.
leakThresholds should be a dict mapping process types to leak thresholds,
in bytes. If a process type is not present in the dict the threshold
will be 0.
ignoreMissingLeaks should be a list of process types. If a process
creates a leak log without a TOTAL, then we report an error if it isn't
in the list ignoreMissingLeaks.
"""
if not os.path.exists(leakLogFile):
log.info("WARNING | leakcheck | refcount logging is off, so leaks can't be detected!")
return
leakThresholds = getattr(options, 'leakThresholds', {})
ignoreMissingLeaks = getattr(options, 'ignoreMissingLeaks', [])
# This list is based on kGeckoProcessTypeString. ipdlunittest processes likely
# are not going to produce leak logs we will ever see.
knownProcessTypes = ["default", "plugin", "tab", "geckomediaplugin"]

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

@ -162,10 +162,6 @@ class RemoteOptions(ReftestOptions):
if not options.httpdPath:
options.httpdPath = os.path.join(options.utilityPath, "components")
# Android does not run leak tests, but set some reasonable defaults to avoid errors.
options.leakThresholds = {}
options.ignoreMissingLeaks = []
# TODO: Copied from main, but I think these are no longer used in a post xulrunner world
#options.xrePath = options.remoteTestRoot + self.automation._product + '/xulrunner'
#options.utilityPath = options.testRoot + self.automation._product + '/bin'

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

@ -344,7 +344,7 @@ class RefTest(object):
# give the JS harness 30 seconds to deal
# with its own timeouts
timeout=options.timeout + 30.0)
processLeakLog(self.leakLogFile, options.leakThresholds, options.ignoreMissingLeaks)
processLeakLog(self.leakLogFile, options)
self.automation.log.info("\nREFTEST INFO | runreftest.py | Running tests: end.")
finally:
self.cleanup(profileDir)
@ -512,7 +512,6 @@ class ReftestOptions(OptionParser):
self.error("cannot specify a debugger with parallel tests")
options.leakThresholds = {"default": options.defaultLeakThreshold}
options.ignoreMissingLeaks = []
return options

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

@ -203,10 +203,6 @@ class B2GOptions(ReftestOptions):
if not options.httpdPath:
options.httpdPath = os.path.join(options.xrePath, "components")
# B2G reftests do not do leak checking, but set some reasonable defaults to avoid errors.
options.leakThresholds = {}
options.ignoreMissingLeaks = []
return options

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

@ -1845,7 +1845,7 @@ class Mochitest(MochitestUtilsMixin):
self.stopVMwareRecording();
self.stopServers()
processLeakLog(self.leak_report_file, options.leakThresholds, options.ignoreMissingLeaks)
processLeakLog(self.leak_report_file, options)
if self.nsprLogs:
with zipfile.ZipFile("%s/nsprlog.zip" % browserEnv["MOZ_UPLOAD_DIR"], "w", zipfile.ZIP_DEFLATED) as logzip:

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

@ -202,7 +202,7 @@ class B2GMochitest(MochitestUtilsMixin):
self.app_ctx.dm.getFile(self.leak_report_file, local_leak_file.name)
self.app_ctx.dm.removeFile(self.leak_report_file)
processLeakLog(local_leak_file.name, options.leakThresholds, options.ignoreMissingLeaks)
processLeakLog(local_leak_file.name, options)
except KeyboardInterrupt:
self.log.info("runtests.py | Received keyboard interrupt.\n");
status = -1