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

kunit: tool: fix count of tests if late test plan

Fix test count with late test plan.

For example,
TAP version 13
ok 1 test1
1..4

Returns a count of 1 passed, 1 crashed (because it expects tests after
the test plan): returning the total count of 2 tests

Change this to be 1 passed, 1 error: total count of 1 test

Link: https://lore.kernel.org/r/20250319223351.1517262-1-rmoar@google.com
Signed-off-by: Rae Moar <rmoar@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <shuah@kernel.org>

authored by

Rae Moar and committed by
Shuah Khan
14e594a1 0af2f6be

+6 -2
+4
tools/testing/kunit/kunit_parser.py
··· 809 809 test.log.extend(parse_diagnostic(lines)) 810 810 if test.name != "" and not peek_test_name_match(lines, test): 811 811 test.add_error(printer, 'missing subtest result line!') 812 + elif not lines: 813 + print_log(test.log, printer) 814 + test.status = TestStatus.NO_TESTS 815 + test.add_error(printer, 'No more test results!') 812 816 else: 813 817 parse_test_result(lines, test, expected_num, printer) 814 818
+2 -2
tools/testing/kunit/kunit_tool_test.py
··· 371 371 """ 372 372 result = kunit_parser.parse_run_tests(output.splitlines(), stdout) 373 373 # Missing test results after test plan should alert a suspected test crash. 374 - self.assertEqual(kunit_parser.TestStatus.TEST_CRASHED, result.status) 375 - self.assertEqual(result.counts, kunit_parser.TestCounts(passed=1, crashed=1, errors=1)) 374 + self.assertEqual(kunit_parser.TestStatus.SUCCESS, result.status) 375 + self.assertEqual(result.counts, kunit_parser.TestCounts(passed=1, errors=2)) 376 376 377 377 def line_stream_from_strs(strs: Iterable[str]) -> kunit_parser.LineStream: 378 378 return kunit_parser.LineStream(enumerate(strs, start=1))