Skip to content

Commit 9a6bb30

Browse files
dlatypovshuahkh
authored andcommitted
kunit: tool: fix --json output for skipped tests
Currently, KUnit will report SKIPPED tests as having failed if one uses --json. Add the missing if statement to set the appropriate status ("SKIP"). See https://api.kernelci.org/schema-test-case.html: "status": { "type": "string", "description": "The status of the execution of this test case", "enum": ["PASS", "FAIL", "SKIP", "ERROR"], "default": "PASS" }, with this, we now can properly produce all four of the statuses. Fixes: 5acaf60 ("kunit: tool: Support skipped tests in kunit_tool") Signed-off-by: Daniel Latypov <[email protected]> Reviewed-by: David Gow <[email protected]> Reviewed-by: Brendan Higgins <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent fa55b7d commit 9a6bb30

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

tools/testing/kunit/kunit_json.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def _get_group_json(test: Test, def_config: str,
3030
test_case = {"name": subtest.name, "status": "FAIL"}
3131
if subtest.status == TestStatus.SUCCESS:
3232
test_case["status"] = "PASS"
33+
elif subtest.status == TestStatus.SKIPPED:
34+
test_case["status"] = "SKIP"
3335
elif subtest.status == TestStatus.TEST_CRASHED:
3436
test_case["status"] = "ERROR"
3537
test_cases.append(test_case)

tools/testing/kunit/kunit_tool_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,12 @@ def test_crashed_test_json(self):
383383
{'name': 'example_simple_test', 'status': 'ERROR'},
384384
result["sub_groups"][1]["test_cases"][0])
385385

386+
def test_skipped_test_json(self):
387+
result = self._json_for('test_skip_tests.log')
388+
self.assertEqual(
389+
{'name': 'example_skip_test', 'status': 'SKIP'},
390+
result["sub_groups"][1]["test_cases"][1])
391+
386392
def test_no_tests_json(self):
387393
result = self._json_for('test_is_test_passed-no_tests_run_with_header.log')
388394
self.assertEqual(0, len(result['sub_groups']))

0 commit comments

Comments
 (0)