This shows you the differences between two versions of the page.
| — |
tips:valgrind-to-xunit-xml-converter [31.08.2011 11:10] (current) vergo created |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Valgrind to xUnit XML converter ====== | ||
| + | This Python script converts the XML file output of Valgrind to xUnit XML format that can then be used for example in [[http:// | ||
| + | |||
| + | <code python valgrind2xunit.py> | ||
| + | # | ||
| + | |||
| + | import xml.etree.ElementTree as ET | ||
| + | doc = ET.parse(' | ||
| + | errors = doc.findall('// | ||
| + | |||
| + | out = open(" | ||
| + | out.write('<? | ||
| + | out.write('< | ||
| + | errorcount=0 | ||
| + | for error in errors: | ||
| + | errorcount=errorcount+1 | ||
| + | |||
| + | kind = error.find(' | ||
| + | what = error.find(' | ||
| + | if what == None: | ||
| + | what = error.find(' | ||
| + | |||
| + | stack = error.find(' | ||
| + | frames = stack.findall(' | ||
| + | |||
| + | for frame in frames: | ||
| + | fi = frame.find(' | ||
| + | li = frame.find(' | ||
| + | if fi != None and li != None: | ||
| + | break | ||
| + | |||
| + | if fi != None and li != None: | ||
| + | out.write(' | ||
| + | else: | ||
| + | out.write(' | ||
| + | out.write(' | ||
| + | out.write(' | ||
| + | |||
| + | for frame in frames: | ||
| + | ip = frame.find(' | ||
| + | fn = frame.find(' | ||
| + | fi = frame.find(' | ||
| + | li = frame.find(' | ||
| + | bodytext = fn.text | ||
| + | bodytext = bodytext.replace("&","& | ||
| + | bodytext = bodytext.replace("<","& | ||
| + | bodytext = bodytext.replace(">","& | ||
| + | if fi != None and li != None: | ||
| + | out.write(' | ||
| + | else: | ||
| + | out.write(' | ||
| + | |||
| + | out.write(' | ||
| + | out.write(' | ||
| + | out.write('</ | ||
| + | out.close() | ||
| + | </ | ||