Skip to content

Commit

Permalink
kunit: add sub-cases
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
kuba-moo committed Jun 7, 2024
1 parent 3345aea commit e54e2fc
Showing 1 changed file with 38 additions and 16 deletions.
54 changes: 38 additions & 16 deletions contest/remote/kunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,32 +80,54 @@ def load_expected(config):
if words[1] not in grp:
grp[words[1]] = {}
grp[words[1]] = str_to_code[words[2]]
return expected
return expected


def summary_result(expected, got, link, sub_path=""):
def summary_flat(expected, got, sub_path=""):
if sub_path:
sub_path += '.'

overall_code = 0
results = []
bad_tests = []
for case in got["test_cases"]:
code = str_to_code[case["status"]]
overall_code = max(code, overall_code)

exp = expected.get(got["name"], {}).get(case["name"])
if exp and exp == code:
continue

results.append({'test': sub_path + case["name"],
'result': code_to_str[code]})
if code:
bad_tests.append(f"{got['name']} {case['name']} {case['status']}")

for sub_group in got["sub_groups"]:
for case in sub_group["test_cases"]:
code = str_to_code[case["status"]]
ov, bt, res = summary_flat(expected, sub_group, sub_path + sub_group["name"])
overall_code = max(ov, overall_code)
results += res
bad_tests += bt

exp = expected.get(sub_group["name"], {}).get(case["name"])
if exp and exp == code:
continue
return overall_code, bad_tests, results

results.append({'test': case["name"],
'group': sub_path + sub_group["name"],
'result': code_to_str[code], 'link': link})
if code:
bad_tests.append(f"{sub_group['name']} {case['name']} {case['status']}")
for grp in sub_group["sub_groups"]:
bt, res = summary_result(expected, grp, link, sub_path + grp["name"])
results += res
bad_tests += bt

def summary_result(expected, got, link, sub_path=""):
results = []
bad_tests = []
for sub_group in got["sub_groups"]:
code, bt, res = summary_flat(expected, sub_group)

data = {
'test': sub_group["name"],
'group': 'kunit',
'result': code_to_str[code],
'results': res,
'link': link
}
results.append(data)

bad_tests += bt

return bad_tests, results

Expand Down

0 comments on commit e54e2fc

Please sign in to comment.