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

Configure Feed

Select the types of activity you want to include in your feed.

kunit: tool: Don't overwrite test status based on subtest counts

If a subtest itself reports success, but the outer testcase fails,
the whole testcase should be reported as a failure. However the status
is recalculated based on the test counts, overwriting the outer test
result. Synthesize a failed test in this case to make sure the failure
is not swallowed.

Link: https://lore.kernel.org/r/20251230-kunit-nested-failure-v1-2-98cfbeb87823@linutronix.de
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Thomas Weißschuh and committed by
Shuah Khan
85aff81b 0c5b86c6

+7
+3
tools/testing/kunit/kunit_parser.py
··· 689 689 elif test.counts.get_status() == TestStatus.TEST_CRASHED: 690 690 test.status = TestStatus.TEST_CRASHED 691 691 692 + if status == TestStatus.FAILURE and test.counts.get_status() == TestStatus.SUCCESS: 693 + counts.add_status(status) 694 + 692 695 def parse_test(lines: LineStream, expected_num: int, log: List[str], is_subtest: bool, printer: Printer) -> Test: 693 696 """ 694 697 Finds next test to parse in LineStream, creates new Test object,
+1
tools/testing/kunit/kunit_tool_test.py
··· 172 172 self.assertEqual(kunit_parser.TestStatus.FAILURE, result.status) 173 173 self.assertEqual(result.counts.failed, 2) 174 174 self.assertEqual(kunit_parser.TestStatus.FAILURE, result.subtests[0].status) 175 + self.assertEqual(kunit_parser.TestStatus.SUCCESS, result.subtests[0].subtests[0].status) 175 176 self.assertEqual(kunit_parser.TestStatus.FAILURE, result.subtests[1].status) 176 177 self.assertEqual(kunit_parser.TestStatus.FAILURE, result.subtests[1].subtests[0].status) 177 178
+3
tools/testing/kunit/test_data/test_is_test_passed-failure-nested.log
··· 1 1 KTAP version 1 2 2 1..2 3 + KTAP version 1 4 + 1..1 5 + ok 1 test 1 3 6 not ok 1 subtest 1 4 7 KTAP version 1 5 8 1..1