Skip to content

Commit ce7ff26

Browse files
rmr167shuahkh
authored andcommitted
kunit: tool: add test counts to JSON output
Add the test counts to the JSON output from kunit.py. For example: ... "git_branch": "kselftest", "misc": { "tests": 2, "passed": 1. "failed": 1, "crashed": 0, "skipped": 0, "errors": 0, } ... To output the JSON using the following command: ./tools/testing/kunit/kunit.py run example --json This has been requested by KUnit users. The counts are in a "misc" field because the JSON output needs to be compliant with the KCIDB submission guide. There are no counts fields but there is a "misc" field in the guide. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rae Moar <[email protected]> Reviewed-by: David Gow <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent d208025 commit ce7ff26

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tools/testing/kunit/kunit_json.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,20 @@ def _get_group_json(test: Test, common_fields: JsonObj) -> JsonObj:
3939
status = _status_map.get(subtest.status, "FAIL")
4040
test_cases.append({"name": subtest.name, "status": status})
4141

42+
test_counts = test.counts
43+
counts_json = {
44+
"tests": test_counts.total(),
45+
"passed": test_counts.passed,
46+
"failed": test_counts.failed,
47+
"crashed": test_counts.crashed,
48+
"skipped": test_counts.skipped,
49+
"errors": test_counts.errors,
50+
}
4251
test_group = {
4352
"name": test.name,
4453
"sub_groups": sub_groups,
4554
"test_cases": test_cases,
55+
"misc": counts_json
4656
}
4757
test_group.update(common_fields)
4858
return test_group

0 commit comments

Comments
 (0)