Parsing a log where every test is skipped exits with status 1, even
though the summary reports no failures. This can cause a CI job that
parses results collected separately to fail solely because all tests
were skipped. The run and exec commands already treat this outcome as
success.
Reuse _map_to_overall_status() in parse_tests() so the parse command
handles skipped results consistently with exec_tests(). Keep failures,
crashes and missing test results unsuccessful.
Add command-line regression coverage using the existing log fixtures.
Fixes: 5acaf6031f53 ("kunit: tool: Support skipped tests in kunit_tool")
Signed-off-by: Rowan Vale <[email protected]>
---
Validation: all 94 kunit_tool_test.py tests pass on Python 3.12.14.
The added all-skipped regression fails before the fix. CLI checks keep
failed, crashed and missing-test logs unsuccessful, and preserve skipped
counts in JSON and JUnit exports. Only the Python tool was tested; no
full kernel build or hardware run was performed.
tools/testing/kunit/kunit.py | 6 ++----
tools/testing/kunit/kunit_tool_test.py | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py
index 91d234ac3..eb660b46c 100755
--- a/tools/testing/kunit/kunit.py
+++ b/tools/testing/kunit/kunit.py
@@ -277,10 +277,8 @@ def parse_tests(request: KunitParseRequest,
metadata: kunit_json.Metadata, input
kunit_junit.write_junit_result(test=test,filename=request.junit)
stdout.print_with_timestamp(f"Test results stored in
{os.path.abspath(request.junit)}")
- if test.status != kunit_parser.TestStatus.SUCCESS:
- return KunitResult(KunitStatus.TEST_FAILURE, parse_time), test
-
- return KunitResult(KunitStatus.SUCCESS, parse_time), test
+ kunit_status = _map_to_overall_status(test.status)
+ return KunitResult(kunit_status, parse_time), test
def run_tests(linux: kunit_kernel.LinuxSourceTree,
request: KunitRequest) -> KunitResult:
diff --git a/tools/testing/kunit/kunit_tool_test.py
b/tools/testing/kunit/kunit_tool_test.py
index 85ae21754..1e65b36d4 100755
--- a/tools/testing/kunit/kunit_tool_test.py
+++ b/tools/testing/kunit/kunit_tool_test.py
@@ -747,6 +747,26 @@ class KUnitMainTest(unittest.TestCase):
self.assertEqual(self.linux_source_mock.build_reconfig.call_count, 1)
self.assertEqual(self.linux_source_mock.run_kernel.call_count,
0)
+ def test_parse_skipped_all_tests(self):
+ kunit.main(['parse',
_test_data_path('test_skip_all_tests.log')])
+ self.print_mock.assert_any_call(StrContains('skipped: 5'))
+
+ def test_parse_passed_tests(self):
+ for log in ('test_is_test_passed-all_passed.log',
+ 'test_skip_tests.log'):
+ with self.subTest(log=log):
+ kunit.main(['parse', _test_data_path(log)])
+
+ def test_parse_failed_tests(self):
+ for log in ('test_is_test_passed-failure.log',
+ 'test_kernel_panic_interrupt.log',
+ 'test_is_test_passed-no_tests_run_with_header.log',
+ 'test_is_test_passed-no_tests_run_no_header.log'):
+ with self.subTest(log=log):
+ with self.assertRaises(SystemExit) as e:
+ kunit.main(['parse',
_test_data_path(log)])
+ self.assertEqual(e.exception.code, 1)
+
def test_build_passes_args_pass(self):
kunit.main(['build'])
self.assertEqual(self.linux_source_mock.build_reconfig.call_count, 1)
base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907
--
2.51.1