Skip to content

Commit 1d4c06d

Browse files
rmr167Shuah Khan
authored andcommitted
kunit: tool: Fix bug in parsing test plan
A bug was identified where the KTAP below caused an infinite loop: TAP version 13 ok 4 test_case 1..4 The infinite loop was caused by the parser not parsing a test plan if following a test result line. Fix this bug by parsing test plan line to avoid the infinite loop. 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 c104c16 commit 1d4c06d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

tools/testing/kunit/kunit_parser.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ def parse_test(lines: LineStream, expected_num: int, log: List[str], is_subtest:
759759
# If parsing the main/top-level test, parse KTAP version line and
760760
# test plan
761761
test.name = "main"
762-
ktap_line = parse_ktap_header(lines, test, printer)
762+
parse_ktap_header(lines, test, printer)
763763
test.log.extend(parse_diagnostic(lines))
764764
parse_test_plan(lines, test)
765765
parent_test = True
@@ -768,13 +768,12 @@ def parse_test(lines: LineStream, expected_num: int, log: List[str], is_subtest:
768768
# the KTAP version line and/or subtest header line
769769
ktap_line = parse_ktap_header(lines, test, printer)
770770
subtest_line = parse_test_header(lines, test)
771+
test.log.extend(parse_diagnostic(lines))
772+
parse_test_plan(lines, test)
771773
parent_test = (ktap_line or subtest_line)
772774
if parent_test:
773-
# If KTAP version line and/or subtest header is found, attempt
774-
# to parse test plan and print test header
775-
test.log.extend(parse_diagnostic(lines))
776-
parse_test_plan(lines, test)
777775
print_test_header(test, printer)
776+
778777
expected_count = test.expected_count
779778
subtests = []
780779
test_num = 1

0 commit comments

Comments
 (0)