summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorglider@chromium.org <glider@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-12 15:28:27 +0000
committerglider@chromium.org <glider@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-12 15:28:27 +0000
commitedbc470a9e1fdf84ab8bf094cbf76647d8163ec3 (patch)
treeb96ad07b1c978e44de7d47035511c23cb104cf92 /tools
parentc54b100126df3d5c8ff0e0910278c73c8e683140 (diff)
downloadchromium_src-edbc470a9e1fdf84ab8bf094cbf76647d8163ec3.zip
chromium_src-edbc470a9e1fdf84ab8bf094cbf76647d8163ec3.tar.gz
chromium_src-edbc470a9e1fdf84ab8bf094cbf76647d8163ec3.tar.bz2
Make the heapheck runner recognize the sanity tests.
TBR=willchan,thestig Review URL: http://codereview.chromium.org/596085 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38895 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rwxr-xr-xtools/heapcheck/chrome_tests.py4
-rw-r--r--tools/heapcheck/heapcheck_test.py42
2 files changed, 32 insertions, 14 deletions
diff --git a/tools/heapcheck/chrome_tests.py b/tools/heapcheck/chrome_tests.py
index e9c1e8f..a66d805 100755
--- a/tools/heapcheck/chrome_tests.py
+++ b/tools/heapcheck/chrome_tests.py
@@ -247,7 +247,7 @@ class ChromeTests(object):
# Sets LD_LIBRARY_PATH to the build folder so external libraries can be
# loaded.
os.putenv("LD_LIBRARY_PATH", self._options.build_dir)
- return heapcheck_test.RunTool(cmd, supp)
+ return heapcheck_test.RunTool(cmd, supp, module)
def TestBase(self):
return self.SimpleTest("base", "base_unittests")
@@ -349,7 +349,7 @@ class ChromeTests(object):
cmd.extend(["--"])
cmd.extend(script_cmd)
supp = self.Suppressions()
- return heapcheck_test.RunTool(cmd, supp)
+ return heapcheck_test.RunTool(cmd, supp, "layout")
def TestLayout(self):
'''Runs the layout tests.'''
diff --git a/tools/heapcheck/heapcheck_test.py b/tools/heapcheck/heapcheck_test.py
index b1c6b16..80bd37c 100644
--- a/tools/heapcheck/heapcheck_test.py
+++ b/tools/heapcheck/heapcheck_test.py
@@ -19,6 +19,7 @@ import suppressions
class HeapcheckWrapper(object):
TMP_FILE = 'heapcheck.log'
+ SANITY_TEST_SUPPRESSION = "Heapcheck sanity test"
def __init__(self, supp_files):
self._mode = 'strict'
@@ -58,21 +59,30 @@ class HeapcheckWrapper(object):
# the purify_test.py script.)
return True
- def Analyze(self, log_lines):
+ def Analyze(self, log_lines, check_sanity=False):
"""Analyzes the app's output and applies suppressions to the reports.
Analyze() searches the logs for leak reports and tries to apply
suppressions to them. Unsuppressed reports and other log messages are
dumped as is.
+ If |check_sanity| is True, the list of suppressed reports is searched for a
+ report starting with SANITY_TEST_SUPPRESSION. If there isn't one, Analyze
+ returns 2 regardless of the unsuppressed reports.
+
Args:
- log_lines: An iterator over the app's log lines.
+ log_lines: An iterator over the app's log lines.
+ check_sanity: A flag that determines whether we should check the tool's
+ sanity.
Returns:
- 1, if unsuppressed reports remain in the output, 0 otherwise.
+ 2, if the sanity check fails,
+ 1, if unsuppressed reports remain in the output and the sanity check
+ passes,
+ 0, if all the errors are suppressed and the sanity check passes.
"""
leak_report = re.compile(
'Leak of ([0-9]*) bytes in ([0-9]*) objects allocated from:')
- stack_line = re.compile('\s*@\s*0x[0-9a-fA-F]*\s*(\S*)')
+ stack_line = re.compile('\s*@\s*[0-9a-fA-F]*\s*(\S*)')
return_code = 0
# leak signature: [number of bytes, number of objects]
cur_leak_signature = None
@@ -122,6 +132,7 @@ class HeapcheckWrapper(object):
else:
print line
# Print the list of suppressions used.
+ is_sane = False
if used_suppressions:
print
print '-----------------------------------------------------'
@@ -129,6 +140,8 @@ class HeapcheckWrapper(object):
print ' count bytes objects name'
histo = {}
for description in used_suppressions:
+ if description.startswith(HeapcheckWrapper.SANITY_TEST_SUPPRESSION):
+ is_sane = True
hits, bytes, objects = used_suppressions[description]
line = '%8d %8d %8d %s' % (hits, bytes, objects, description)
if hits in histo:
@@ -141,21 +154,24 @@ class HeapcheckWrapper(object):
for line in histo[count]:
print line
print '-----------------------------------------------------'
+ if is_sane:
+ return return_code
+ else:
+ logging.error("Sanity check failed")
+ return 2
- return return_code
-
- def RunTestsAndAnalyze(self):
+ def RunTestsAndAnalyze(self, check_sanity):
self.Execute()
log_file = file(self.TMP_FILE, 'r')
- ret = self.Analyze(log_file)
+ ret = self.Analyze(log_file, check_sanity)
log_file.close()
return ret
- def Main(self, args):
+ def Main(self, args, check_sanity=False):
self._args = args
start = datetime.datetime.now()
retcode = -1
- retcode = self.RunTestsAndAnalyze()
+ retcode = self.RunTestsAndAnalyze(check_sanity)
end = datetime.datetime.now()
seconds = (end - start).seconds
hours = seconds / 3600
@@ -166,6 +182,8 @@ class HeapcheckWrapper(object):
return retcode
-def RunTool(args, supp_files):
+def RunTool(args, supp_files, module):
tool = HeapcheckWrapper(supp_files)
- return tool.Main(args[1:])
+ MODULES_TO_SANITY_CHECK = ["base"]
+ check_sanity = module in MODULES_TO_SANITY_CHECK
+ return tool.Main(args[1:], check_sanity)