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

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: 5acaf6031f53 ("kunit: tool: Support skipped tests in kunit_tool")
Signed-off-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Daniel Latypov and committed by
Shuah Khan
9a6bb30a fa55b7dc

+8
+2
tools/testing/kunit/kunit_json.py
··· 30 30 test_case = {"name": subtest.name, "status": "FAIL"} 31 31 if subtest.status == TestStatus.SUCCESS: 32 32 test_case["status"] = "PASS" 33 + elif subtest.status == TestStatus.SKIPPED: 34 + test_case["status"] = "SKIP" 33 35 elif subtest.status == TestStatus.TEST_CRASHED: 34 36 test_case["status"] = "ERROR" 35 37 test_cases.append(test_case)
+6
tools/testing/kunit/kunit_tool_test.py
··· 383 383 {'name': 'example_simple_test', 'status': 'ERROR'}, 384 384 result["sub_groups"][1]["test_cases"][0]) 385 385 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 + 386 392 def test_no_tests_json(self): 387 393 result = self._json_for('test_is_test_passed-no_tests_run_with_header.log') 388 394 self.assertEqual(0, len(result['sub_groups']))