aboutsummaryrefslogtreecommitdiff
path: root/ldcg-onednn-benchmarks/convert-onednn-test-to-result.py
blob: e7d4ec88cf597e6ec8cd0b20cb1590d234f0220f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python3

import sys

testname = sys.argv[1] #takes testname as input
workspace = sys.argv[2] #takes WORKSPACE root dir as input


#opens the textfile corresponding to the testname from the tmp directory and saves it to pippo
with open(workspace + "/oneDNN-results/" + testname + "-output.txt", 'r') as handle:
    pippo = handle.readlines()

#reads through each line of the testname and checks for PASS/FAIL results proving that the test has been completed correctly. If they exist then it adds them to a res_{testname}.txt file in SQUAD format.
with open(workspace + "/oneDNN-results/res_" + testname + "-output.txt", 'w+') as whandle:
    TestSuccess = False
    TestFailed = False
    for i in range(0,len(pippo)-2):
        line = pippo[i]
        line = line[2:]
        if 'FAILED' in pippo[i]:
            TestSuccess = True
            TestFailed = True
            break
        elif 'PASSED' in pippo[i]:
            if TestSuccess == False:
                TestSuccess = True

    #if no PASS/FAIL results only writes "{testname} : fail" to the result.
    if TestSuccess == False or TestFailed == True:
        whandle.write("\"" + testname + "\"" + ": " + "\"" + "fail" + "\"")
    elif TestSuccess == True:
        whandle.write("\"" + testname + "\"" + ": " + "\"" + "pass" + "\"")