Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/20250516201615.1237037-1-rmoar@google.com
Signed-off-by: Rae Moar <rmoar@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Rae Moar and committed by
Shuah Khan
ce7ff266 d208025d

+10
+10
tools/testing/kunit/kunit_json.py
··· 39 39 status = _status_map.get(subtest.status, "FAIL") 40 40 test_cases.append({"name": subtest.name, "status": status}) 41 41 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 + } 42 51 test_group = { 43 52 "name": test.name, 44 53 "sub_groups": sub_groups, 45 54 "test_cases": test_cases, 55 + "misc": counts_json 46 56 } 47 57 test_group.update(common_fields) 48 58 return test_group