[asterisk-commits] sgriepentrog: branch sgriepentrog/testsuite-valgrind r4356 - in /asterisk/tea...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Nov 22 14:09:35 CST 2013
Author: sgriepentrog
Date: Fri Nov 22 14:09:33 2013
New Revision: 4356
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4356
Log:
Suppression support including auto generation
Improved startup sequence
Patched around issue of reactor not shutting down with exception in deferred list
Added:
asterisk/team/sgriepentrog/testsuite-valgrind/configs/valgrind.supp (with props)
Modified:
asterisk/team/sgriepentrog/testsuite-valgrind/lib/python/asterisk/TestCase.py
asterisk/team/sgriepentrog/testsuite-valgrind/lib/python/asterisk/TestRunner.py
asterisk/team/sgriepentrog/testsuite-valgrind/lib/python/asterisk/asterisk.py
asterisk/team/sgriepentrog/testsuite-valgrind/runtests.py
Added: asterisk/team/sgriepentrog/testsuite-valgrind/configs/valgrind.supp
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/sgriepentrog/testsuite-valgrind/configs/valgrind.supp?view=auto&rev=4356
==============================================================================
--- asterisk/team/sgriepentrog/testsuite-valgrind/configs/valgrind.supp (added)
+++ asterisk/team/sgriepentrog/testsuite-valgrind/configs/valgrind.supp Fri Nov 22 14:09:33 2013
@@ -1,0 +1,54 @@
+
+{
+ <insert_a_suppression_name_here>
+ Memcheck:Cond
+ fun:_ast_sockaddr_port
+ fun:ast_find_ourip
+ fun:load_module
+ fun:start_resource
+ fun:load_resource_list
+ fun:load_modules
+ fun:main
+}
+
+{
+ <insert_a_suppression_name_here>
+ Memcheck:Cond
+ fun:_ast_sockaddr_port
+ fun:ast_find_ourip
+ fun:load_module
+ fun:start_resource
+ fun:load_resource_list
+ fun:load_modules
+ fun:main
+}
+
+{
+ <insert_a_suppression_name_here>
+ Memcheck:Cond
+ fun:speex_decode_int
+ fun:speextolin_framein
+ fun:framein
+ fun:calc_cost
+ fun:__ast_register_translator
+ fun:load_module
+ fun:start_resource
+ fun:load_resource_list
+ fun:load_modules
+ fun:main
+}
+
+{
+ <insert_a_suppression_name_here>
+ Memcheck:Cond
+ fun:speex_decode_int
+ fun:speextolin_framein
+ fun:framein
+ fun:calc_cost
+ fun:__ast_register_translator
+ fun:load_module
+ fun:start_resource
+ fun:load_resource_list
+ fun:load_modules
+ fun:main
+}
Propchange: asterisk/team/sgriepentrog/testsuite-valgrind/configs/valgrind.supp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/sgriepentrog/testsuite-valgrind/configs/valgrind.supp
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/sgriepentrog/testsuite-valgrind/configs/valgrind.supp
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: asterisk/team/sgriepentrog/testsuite-valgrind/lib/python/asterisk/TestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/sgriepentrog/testsuite-valgrind/lib/python/asterisk/TestCase.py?view=diff&rev=4356&r1=4355&r2=4356
==============================================================================
--- asterisk/team/sgriepentrog/testsuite-valgrind/lib/python/asterisk/TestCase.py (original)
+++ asterisk/team/sgriepentrog/testsuite-valgrind/lib/python/asterisk/TestCase.py Fri Nov 22 14:09:33 2013
@@ -98,6 +98,7 @@
self._stop_callbacks = []
self._ami_callbacks = []
self._pcap_callbacks = []
+ self.valgrind = False
""" Pull additional configuration from YAML config if possible """
if test_config and 'reactor-timeout' in test_config:
@@ -125,6 +126,17 @@
self.__setup_conditions()
logger.info("Executing " + self.test_name)
+
+ if None != self.test_config.valgrind:
+ self.valgrind = self.test_config.valgrind
+ elif os.getenv("VALGRIND") == "true":
+ self.valgrind = True
+ if True == self.valgrind:
+ self.reactor_timeout *= 5
+ logger.info("Adjusting reactor timeout to %d for valgrind" % self.reactor_timeout)
+ if TestSuiteUtils.which('valgrind') is None:
+ logger.error("VALGRIND IS NOT INSTALLED - running test without it")
+ self.valgrind = False
# Enable twisted logging
observer = log.PythonLoggingObserver()
@@ -183,22 +195,11 @@
"""
- valgrind = False
- if None != self.test_config.valgrind:
- valgrind = self.test_config.valgrind
- elif os.getenv("VALGRIND") == "true":
- valgrind = True
- if True == valgrind:
- if TestSuiteUtils.which('valgrind') is None:
- # this would be better done elsewhere and stop
- logger.error("Valgrind is not installed")
- valgrind = False
-
for c in range(count):
logger.info("Creating Asterisk instance %d" % (c + 1))
host = "127.0.0.%d" % (c + 1)
self.ast.append(Asterisk(base=self.base, host=host))
- self.ast[c].valgrind = valgrind
+ self.ast[c].valgrind = self.valgrind
""" If a base configuration for this Asterisk instance has been
provided, install it first"""
@@ -391,12 +392,15 @@
# Something stopped it between our checks - at least we're stopped
pass
return result
+
if not self._stopping:
self._stopping = True
df = self.__stop_asterisk()
for callback in self._stop_callbacks:
df.addCallback(callback)
df.addCallback(__stop_reactor)
+ # in case of error in Deferred stack prevent lockup
+ reactor.callLater(60,reactor.stop)
def __reactor_timeout(self):
"""
@@ -631,3 +635,4 @@
if self.connect_agi:
self.create_fastagi_factory(count=self.asterisk_instances)
+# vim:sw=4:ts=4:expandtab:textwidth=79
Modified: asterisk/team/sgriepentrog/testsuite-valgrind/lib/python/asterisk/TestRunner.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/sgriepentrog/testsuite-valgrind/lib/python/asterisk/TestRunner.py?view=diff&rev=4356&r1=4355&r2=4356
==============================================================================
--- asterisk/team/sgriepentrog/testsuite-valgrind/lib/python/asterisk/TestRunner.py (original)
+++ asterisk/team/sgriepentrog/testsuite-valgrind/lib/python/asterisk/TestRunner.py Fri Nov 22 14:09:33 2013
@@ -328,3 +328,4 @@
if __name__ == '__main__':
sys.exit(main() or 0)
+# vim:sw=4:ts=4:expandtab:textwidth=79
Modified: asterisk/team/sgriepentrog/testsuite-valgrind/lib/python/asterisk/asterisk.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/sgriepentrog/testsuite-valgrind/lib/python/asterisk/asterisk.py?view=diff&rev=4356&r1=4355&r2=4356
==============================================================================
--- asterisk/team/sgriepentrog/testsuite-valgrind/lib/python/asterisk/asterisk.py (original)
+++ asterisk/team/sgriepentrog/testsuite-valgrind/lib/python/asterisk/asterisk.py Fri Nov 22 14:09:33 2013
@@ -322,7 +322,7 @@
"--gen-suppressions=all",
] + self.cmd
- print "Asterisk binary command [%s]" % (self.cmd)
+ logger.info("Executing: %s" % (self.cmd))
# Make the start/stop deferreds - this method will return
# the start deferred, and pass the stop deferred to the AsteriskProtocol
Modified: asterisk/team/sgriepentrog/testsuite-valgrind/runtests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/sgriepentrog/testsuite-valgrind/runtests.py?view=diff&rev=4356&r1=4355&r2=4356
==============================================================================
--- asterisk/team/sgriepentrog/testsuite-valgrind/runtests.py (original)
+++ asterisk/team/sgriepentrog/testsuite-valgrind/runtests.py Fri Nov 22 14:09:33 2013
@@ -181,7 +181,9 @@
if os.path.exists(src_dir+"/valgrind.xml"):
hardlink_or_copy(src_dir + "/valgrind.xml", dest_dir +
"/valgrind.xml")
- print "Examine errors in %s/valgrind.xml" % dest_dir
+ if os.path.exists(src_dir+"/valgrind.supp"):
+ hardlink_or_copy(src_dir + "/valgrind.supp", dest_dir +
+ "/valgrind.supp")
except Exception, e:
print "Exception occurred valgrind logs from %s to %s: %s" % (
src_dir, dest_dir, e
@@ -190,11 +192,12 @@
break
i += 1
- def __parse_valgrind_xml_doc(self, xmldoc):
+ def __parse_valgrind_xml_doc(self, xmldoc, i):
count_bytes_leaked = 0
count_errors_found = 0
count_error_kinds = {}
code = {}
+ supp = []
try:
error_list = xmldoc.getElementsByTagName('error')
count_errors_found = len(error_list)
@@ -207,6 +210,14 @@
if node.nodeType == node.TEXT_NODE:
text.append(str(node.data))
return ''.join(text)
+ def getData(nodelist):
+ data = []
+ for node in nodelist:
+ if node.nodeType == node.ELEMENT_NODE:
+ data.append(getData(node.childNodes))
+ if node.nodeType == node.CDATA_SECTION_NODE:
+ data.append(str(node.data))
+ return ''.join(data)
def arrange_frames_by_code(tree, frames, error):
frame = frames[0]
@@ -259,17 +270,28 @@
count_error_kinds[kind] = 0
count_error_kinds[kind] += 1
+ suppression = error.getElementsByTagName('suppression')[0]
+ rawtext = getData(suppression.getElementsByTagName('rawtext'))
+ if rawtext != "":
+ supp.append(rawtext)
+
except Exception, e:
print "Exception checking elements valgrind XML: %s" % (e)
self.passed = False
def dump_code_errors(tree, depth):
- for msg, branch in tree.items():
- print ' ' * depth + msg
+ for text, branch in tree.items():
+ msg = ' ' * depth + text
+ self.stdout += msg + "\n"
+ print msg
if len(branch):
dump_code_errors(branch, depth+1)
- dump_code_errors(code, 0)
+ if len(code):
+ msg = "Valgrind output from ast%d:" % i
+ self.stdout += msg + "\n"
+ print msg
+ dump_code_errors(code, 0)
for kind, count in count_error_kinds.iteritems():
msg = "Valgrind found %d errors of type %s" % (count, kind)
@@ -286,6 +308,14 @@
print msg
self.passed = False
+ if len(supp):
+ ast_dir = "%s/%s/ast%d/" % (Asterisk.test_suite_root,
+ self.test_name.lstrip("tests/"), i)
+ supp_file = "%s/valgrind.supp" % ast_dir
+ print "Writing example suppression file to %s" % supp_file
+ with open(supp_file, "w") as supp_file_handle:
+ supp_file_handle.write(''.join(supp))
+
def __parse_valgrind_xml(self):
#Parse valgrind XML and calculate number of bytes definately lost
@@ -296,7 +326,7 @@
ast_dir = "%s/ast%d/" % (ast_directories, i)
xml_file = ast_dir+"/valgrind.xml"
if os.path.exists(xml_file):
- print "Found the valgrind XML in %s " % ast_dir
+ print "Parsing %s " % xml_file
try:
xmldoc = xml.dom.minidom.parse(xml_file)
except Exception, e:
@@ -313,7 +343,7 @@
i += 1
continue
- self.__parse_valgrind_xml_doc(xmldoc)
+ self.__parse_valgrind_xml_doc(xmldoc, i)
else:
break
i += 1
More information about the asterisk-commits
mailing list