Skip to content

Commit 2e0cf2b

Browse files
rmr167Shuah Khan
authored andcommitted
kunit: tool: add test to check parsing late test plan
Add test to check for the infinite loop caused by the inability to parse a late test plan. The test parses the following output: TAP version 13 ok 4 test4 1..4 Link: https://lore.kernel.org/r/20250313192714.1380005-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>
1 parent 1d4c06d commit 2e0cf2b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tools/testing/kunit/kunit_tool_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,17 @@ def test_show_test_output_on_failure(self):
363363
self.print_mock.assert_any_call(StrContains(' Indented more.'))
364364
self.noPrintCallContains('not ok 1 test1')
365365

366+
def test_parse_late_test_plan(self):
367+
output = """
368+
TAP version 13
369+
ok 4 test4
370+
1..4
371+
"""
372+
result = kunit_parser.parse_run_tests(output.splitlines(), stdout)
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))
376+
366377
def line_stream_from_strs(strs: Iterable[str]) -> kunit_parser.LineStream:
367378
return kunit_parser.LineStream(enumerate(strs, start=1))
368379

0 commit comments

Comments
 (0)