diff mbox series

[v3,2/2] kunit: tool: add test to check parsing late test plan

Message ID 20250313192714.1380005-2-rmoar@google.com (mailing list archive)
State New
Delegated to: Brendan Higgins
Headers show
Series [v3,1/2] kunit: tool: Fix bug in parsing test plan | expand

Commit Message

Rae Moar March 13, 2025, 7:27 p.m. UTC
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

Signed-off-by: Rae Moar <rmoar@google.com>
---
Changes since v2:
- Adds this patch to add a test for this behavior

 tools/testing/kunit/kunit_tool_test.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

David Gow March 14, 2025, 5:37 a.m. UTC | #1
On Fri, 14 Mar 2025 at 03:27, Rae Moar <rmoar@google.com> wrote:
>
> 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
>
> Signed-off-by: Rae Moar <rmoar@google.com>
> ---

Reviewed-by: David Gow <davidgow@google.com>

Cheers,
-- David
diff mbox series

Patch

diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py
index 0bcb0cc002f8..5ff4f6ffd873 100755
--- a/tools/testing/kunit/kunit_tool_test.py
+++ b/tools/testing/kunit/kunit_tool_test.py
@@ -363,6 +363,17 @@  class KUnitParserTest(unittest.TestCase):
 		self.print_mock.assert_any_call(StrContains('  Indented more.'))
 		self.noPrintCallContains('not ok 1 test1')
 
+	def test_parse_late_test_plan(self):
+		output = """
+		TAP version 13
+		ok 4 test4
+		1..4
+		"""
+		result = kunit_parser.parse_run_tests(output.splitlines(), stdout)
+		# Missing test results after test plan should alert a suspected test crash.
+		self.assertEqual(kunit_parser.TestStatus.TEST_CRASHED, result.status)
+		self.assertEqual(result.counts, kunit_parser.TestCounts(passed=1, crashed=1, errors=1))
+
 def line_stream_from_strs(strs: Iterable[str]) -> kunit_parser.LineStream:
 	return kunit_parser.LineStream(enumerate(strs, start=1))