From e54e2fccd05f368c175186d196489a0e63034830 Mon Sep 17 00:00:00 2001 From: Jakub Kicinski <kuba@kernel.org> Date: Fri, 7 Jun 2024 13:29:23 -0700 Subject: [PATCH] kunit: add sub-cases Signed-off-by: Jakub Kicinski <kuba@kernel.org> --- contest/remote/kunit.py | 54 +++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/contest/remote/kunit.py b/contest/remote/kunit.py index 6b26e63..88edb84 100755 --- a/contest/remote/kunit.py +++ b/contest/remote/kunit.py @@ -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