예제 #1
0
def verifySubmission(dirname):
    summary = parseRunSummary(os.path.join(dirname, "cts-run-summary.xml"))
    allOk = True

    # Check Conformant attribute
    if not summary.isConformant:
        print "FAIL: Runner reported conformance failure (Conformant=\"False\" in <Summary>)"

    # Verify config list
    if not verifyConfigFile(os.path.join(dirname, summary.configLogFilename),
                            summary.type):
        allOk = False

    # Verify that all run files passed
    for runFilename in summary.runLogFilenames:
        print "Verifying %s" % runFilename

        logParser = BatchResultParser()
        batchResult = logParser.parseFile(os.path.join(dirname, runFilename))

        for result in batchResult:
            if not isStatusCodeOk(result.statusCode):
                print "FAIL: %s" % str(result)
                allOk = False

    return allOk
예제 #2
0
def verifySubmission (dirname):
	summary	= parseRunSummary(os.path.join(dirname, "cts-run-summary.xml"))
	allOk	= True

	# Check Conformant attribute
	if not summary.isConformant:
		print "FAIL: Runner reported conformance failure (Conformant=\"False\" in <Summary>)"

	# Verify config list
	if not verifyConfigFile(os.path.join(dirname, summary.configLogFilename), summary.type):
		allOk = False

	# Verify that all run files passed
	for runFilename in summary.runLogFilenames:
		print "Verifying %s" % runFilename

		logParser	= BatchResultParser()
		batchResult	= logParser.parseFile(os.path.join(dirname, runFilename))

		for result in batchResult:
			if not isStatusCodeOk(result.statusCode):
				print "FAIL: %s" % str(result)
				allOk = False

	return allOk
def printTimes(inFile, resultCount):
    #Test section
    parser = BatchResultParser()
    results = parser.parseFile(inFile)
    handler = XMLLogHandlerTests()
    errHandler = LogErrorHandler()
    for result in results:
        xml.sax.parseString(result.log, handler, errHandler)
    handler.bottleneck(resultCount)

    #Group section
    startRecordLines = False
    lines = ""
    f = open(inFile, 'rb')
    for line in f:
        if "#endTestsCasesTime" in line:
            break
        if startRecordLines:
            lines += line
        if "#beginTestsCasesTime" in line:
            startRecordLines = True
    f.close()
    handlerGroups = XMLLogHandlerGroups(handler.list)
    xml.sax.parseString(lines, handlerGroups, errHandler)
    handlerGroups.bottleneck(resultCount)
예제 #4
0
def printTimes (inFile, resultCount) :
	#Test section
	parser	= BatchResultParser()
	results	= parser.parseFile(inFile)
	handler		= XMLLogHandlerTests()
	errHandler	= LogErrorHandler()
	for result in results :
		xml.sax.parseString(result.log, handler, errHandler)
	handler.bottleneck(resultCount)

	#Group section
	startRecordLines = False
	lines = ""
	f = open(inFile, 'rb')
	for line in f :
		if "#endTestsCasesTime" in line :
			break
		if startRecordLines :
			lines += line
		if "#beginTestsCasesTime" in line :
			startRecordLines = True
	f.close()
	handlerGroups = XMLLogHandlerGroups(handler.list)
	xml.sax.parseString(lines, handlerGroups, errHandler)
	handlerGroups.bottleneck(resultCount)
예제 #5
0
def logToXml(inFile, outFile):
    parser = BatchResultParser()
    results = parser.parseFile(inFile)

    dstDoc = xml.dom.minidom.Document()
    batchResultNode = dstDoc.createElement('BatchResult')
    batchResultNode.setAttribute("FileName", os.path.basename(inFile))

    dstDoc.appendChild(batchResultNode)

    for result in results:
        # Normalize log to valid XML
        rootNodes = normalizeToXml(result, dstDoc)
        for node in rootNodes:
            batchResultNode.appendChild(node)

    # Summary
    countByStatusCode = {}
    for code in StatusCode.STATUS_CODES:
        countByStatusCode[code] = 0

    for result in results:
        countByStatusCode[result.statusCode] += 1

    summaryElem = dstDoc.createElement('ResultTotals')
    for code in StatusCode.STATUS_CODES:
        summaryElem.setAttribute(code, "%d" % countByStatusCode[code])
    summaryElem.setAttribute('All', "%d" % len(results))
    batchResultNode.appendChild(summaryElem)

    text = dstDoc.toprettyxml()

    out = codecs.open(outFile, "wb", encoding="utf-8")

    # Write custom headers
    out.write("<?xml version=\"1.0\"?>\n")
    out.write("<?xml-stylesheet href=\"%s\" type=\"text/xsl\"?>\n" %
              STYLESHEET_FILENAME)

    for line in text.splitlines()[1:]:
        out.write(line)
        out.write("\n")

    out.close()
예제 #6
0
def logToXml (inFile, outFile):
	parser	= BatchResultParser()
	results	= parser.parseFile(inFile)

	dstDoc			= xml.dom.minidom.Document()
	batchResultNode	= dstDoc.createElement('BatchResult')
	batchResultNode.setAttribute("FileName", os.path.basename(inFile))

	dstDoc.appendChild(batchResultNode)

	for result in results:
		# Normalize log to valid XML
		rootNodes = normalizeToXml(result, dstDoc)
		for node in rootNodes:
			batchResultNode.appendChild(node)

	# Summary
	countByStatusCode = {}
	for code in StatusCode.STATUS_CODES:
		countByStatusCode[code] = 0

	for result in results:
		countByStatusCode[result.statusCode] += 1

	summaryElem = dstDoc.createElement('ResultTotals')
	for code in StatusCode.STATUS_CODES:
		summaryElem.setAttribute(code, "%d" % countByStatusCode[code])
	summaryElem.setAttribute('All', "%d" % len(results))
	batchResultNode.appendChild(summaryElem)

	text = dstDoc.toprettyxml()

	out = codecs.open(outFile, "wb", encoding="utf-8")

	# Write custom headers
	out.write("<?xml version=\"1.0\"?>\n")
	out.write("<?xml-stylesheet href=\"%s\" type=\"text/xsl\"?>\n" % STYLESHEET_FILENAME)

	for line in text.splitlines()[1:]:
		out.write(line)
		out.write("\n")

	out.close()
예제 #7
0
def verifyConfigFile (filename, type):
	caseName = getConfigCaseName(type)

	print "Verifying %s in %s" % (caseName, filename)

	parser		= BatchResultParser()
	results		= parser.parseFile(filename)
	caseResult	= None

	for result in results:
		if result.name == caseName:
			caseResult = result
			break

	if caseResult == None:
		print "FAIL: %s not found" % caseName
                return False

	if not isStatusCodeOk(caseResult.statusCode):
		print "FAIL: %s" % caseResult
                return False

	return True
예제 #8
0
def verifyConfigFile(filename, type):
    caseName = getConfigCaseName(type)

    print "Verifying %s in %s" % (caseName, filename)

    parser = BatchResultParser()
    results = parser.parseFile(filename)
    caseResult = None

    for result in results:
        if result.name == caseName:
            caseResult = result
            break

    if caseResult == None:
        print "FAIL: %s not found" % caseName
        return False

    if not isStatusCodeOk(caseResult.statusCode):
        print "FAIL: %s" % caseResult
        return False

    return True
예제 #9
0
def logToXml(logFilePath, outFilePath):
    # Initialize Xml Document
    dstDoc = xml.dom.minidom.Document()
    batchResultNode = dstDoc.createElement('BatchResult')
    batchResultNode.setAttribute("FileName", os.path.basename(logFilePath))
    dstDoc.appendChild(batchResultNode)

    # Initialize dictionary for counting status codes
    countByStatusCode = {}
    for code in StatusCode.STATUS_CODES:
        countByStatusCode[code] = 0

    # Write custom headers
    out = codecs.open(outFilePath, "wb", encoding="utf-8")
    out.write("<?xml version=\"1.0\"?>\n")
    out.write("<?xml-stylesheet href=\"%s\" type=\"text/xsl\"?>\n" %
              STYLESHEET_FILENAME)

    summaryElem = dstDoc.createElement('ResultTotals')
    batchResultNode.appendChild(summaryElem)

    # Print the first line manually <BatchResult FileName=something.xml>
    out.write(dstDoc.toprettyxml().splitlines()[1])
    out.write("\n")

    parser = BatchResultParser()
    parser.init(logFilePath)
    logFile = open(logFilePath, 'rb')

    result = parser.getNextTestCaseResult(logFile)
    while result is not None:

        countByStatusCode[result.statusCode] += 1
        rootNodes = normalizeToXml(result, dstDoc)

        for node in rootNodes:

            # Do not append TestResults to dstDoc to save memory.
            # Instead print them directly to the file and add tabs manually.
            for line in node.toprettyxml().splitlines():
                out.write("\t" + line + "\n")

        result = parser.getNextTestCaseResult(logFile)

    # Calculate the totals to add at the end of the Xml file
    for code in StatusCode.STATUS_CODES:
        summaryElem.setAttribute(code, "%d" % countByStatusCode[code])
    summaryElem.setAttribute('All', "%d" % sum(countByStatusCode.values()))

    # Print the test totals and finish the Xml Document"
    for line in dstDoc.toprettyxml().splitlines()[2:]:
        out.write(line + "\n")

    out.close()
    logFile.close()
예제 #10
0
def batchResultToCsv(filename):
    parser = BatchResultParser()
    results = parser.parseFile(filename)

    for result in results:
        print("%s,%s" % (result.name, result.statusCode))
예제 #11
0
def readTestLog (filename):
	parser = BatchResultParser()
	return parser.parseFile(filename)
예제 #12
0
파일: verify.py 프로젝트: eth0047/VK-GL-CTS
def readTestLog (filename):
	parser = BatchResultParser()
	return parser.parseFile(filename)
def batchResultToCsv (filename):
	parser = BatchResultParser()
	results = parser.parseFile(filename)

	for result in results:
		print "%s,%s" % (result.name, result.statusCode)