Commit a9c36213 authored by norvell's avatar norvell
Browse files

Sort results in full report by FORMATS and CATEGORIES

parent 0523efaa
Loading
Loading
Loading
Loading
Loading
+18 −13
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ Parse a junit report and create a summary report.
PROPERTIES = ["MLD", "MAXIMUM ABS DIFF", "MIN_SSNR"]

FORMATS = {'Stereo':r'stereo', 'ISM':r'ISM', 'Multichannel':r'Multi-channel',
            'OSBA':r'OSBA', 'OMASA':r'OMASA','MASA':r'MASA','SBA':r'SBA', 'Renderer':r'renderer'}
            'MASA':r'(?<!O)MASA','SBA':r'(?<!O)SBA', 'OSBA':r'OSBA', 'OMASA':r'OMASA', 'Renderer':r'renderer'}

CATEGORIES = {'Normal operation':r'.*', 'DTX':r'DTX', 'PLC':r'%', 'Bitrate switching':r'br sw|bitrate switching', 'JBM':r'JBM' }

@@ -41,11 +41,14 @@ if __name__ == "__main__":
    testsuite = tree.find(".//testsuite")
    testcases = tree.findall(".//testcase")
    
    results_unsorted = {}
    # Prepare result structure
    results = {}
    for fmt in FORMATS:
        results[fmt] = {}
        for cat in CATEGORIES:
            results[fmt][cat] = {}
    count = {'PASS':0,'FAIL':0,'ERROR':0}



    for testcase in testcases:
        if testcase.find(".//skipped") is None:
            if testcase.get("file") is None:
@@ -80,20 +83,22 @@ if __name__ == "__main__":

            # For ERROR cases, both a FAIL and an ERROR result is generated. 
            # Here, a FAIL would be overwritten with an ERROR result since it has the same name.
            results_unsorted[fulltestname] = {'Format':fmt, 'Category':cat, 'Result':testresult}
            results[fmt][cat][fulltestname] = {'Result':testresult}
            for propertyname, propertyvalue in zip(PROPERTIES, properties_values):
                results_unsorted[fulltestname][propertyname] = propertyvalue
                results[fmt][cat][fulltestname][propertyname] = propertyvalue

    results_sorted = dict(sorted(results_unsorted.items()))
    keys = list(results_sorted[list(results_unsorted.keys())[0]].keys())
    header = ["testcase","Format","Category","Result"] + PROPERTIES

    # Write CSV file
    with open(csv_file, "w") as outfile:
        headerline = ";".join(["testcase"] + keys) + "\n"
        headerline = ";".join(header) + "\n"
        outfile.write(headerline)
        for test in results_sorted:
            count[results_sorted[test]["Result"]] += 1
            line = ";".join([test] + list(results_sorted[test].values())) + "\n"
        for fmt in FORMATS:
            for cat in CATEGORIES:
                results[fmt][cat] = dict(sorted(results[fmt][cat].items()))
                for test in results[fmt][cat]:
                    count[results[fmt][cat][test]["Result"]] += 1
                    line = ";".join([test, fmt, cat] + list(results[fmt][cat][test].values())) + "\n"
                    outfile.write(line)

    print(