def _result_xml_to_string(self, xml): return util.xml_to_string(xml, 'result', RESULT_XML_PUBLIC_ID, RESULT_XML_SYSTEM_ID)
def main(argv=None): if argv is None: argv = sys.argv if len(argv) < 3: sys.exit('Usage: ' + argv[0] + ' <results-xml> [<witness-xml>]* [--no-overwrite-status].\n') resultFile = argv[1] witnessFiles = [] isOverwrite = True for i in range(2, len(argv)): if len(argv) > i and not argv[i].startswith('--'): witnessFiles.append(argv[i]) if argv[i] == '--no-overwrite-status': isOverwrite = False if not os.path.exists(resultFile) or not os.path.isfile(resultFile): sys.exit('File {0} does not exist.'.format(repr(resultFile))) resultXML = ET.ElementTree().parse(resultFile) witnessSets = [] for witnessFile in witnessFiles: if not os.path.exists(witnessFile) or not os.path.isfile(witnessFile): sys.exit('File {0} does not exist.'.format(repr(witnessFile))) witnessXML = ET.ElementTree().parse(witnessFile) witnessSets.append(getWitnesses(witnessXML)) resultXML.set( 'options', '' + resultXML.get('options', default='') + ' [[ ' + witnessXML.get('options', default='') + ' ]]') resultXML.set( 'date', '' + resultXML.get('date', default='') + ' [[ ' + witnessXML.get('date', default='') + ' ]]') for result in resultXML.findall('run'): run = result.get('name') basename = os.path.basename(run) if ('false-unreach-call' in basename or 'false-no-overflow' in basename or 'false-valid-' in basename) \ and 'correct' == result.findall('column[@title="category"]')[0].get('value'): statusVer = result.findall('column[@title="status"]')[0] categoryVer = result.findall('column[@title="category"]')[0] result.append( ET.Element( 'column', { 'title': 'void-status', 'value': statusVer.get('value'), 'hidden': statusVer.get('hidden', 'false') })) result.append( ET.Element( 'column', { 'title': 'void-category', 'value': categoryVer.get('value'), 'hidden': categoryVer.get('hidden', 'false') })) statusWit, categoryWit = (None, None) i = 0 for witnessSet in witnessSets: i = i + 1 witness = witnessSet.get(run, None) # copy data from witness if witness is not None: for column in witness: newColumn = ET.Element( 'column', { 'title': 'wit' + str(i) + '_' + column.get('title'), 'value': column.get('value'), 'hidden': column.get('hidden', 'false') }) result.append(newColumn) witnessSet.pop(run) statusWitNew, categoryWitNew = getWitnessResult(witness) if statusWitNew.startswith('false(') or statusWit is None: statusWit, categoryWit = (statusWitNew, categoryWitNew) # Overwrite status with status from witness if isOverwrite: result.findall('column[@title="status"]')[0].set( 'value', statusWit) result.findall('column[@title="category"]')[0].set( 'value', categoryWit) print(' ' + resultFile + '.merged.xml') XMLFile = FileWriter( resultFile + '.merged.xml', Util.xml_to_string(resultXML).replace(' \n', '').replace(' \n', ''))