* [PATCH] kunit: tool: fix count of tests if late test plan
@ 2025-03-19 22:33 Rae Moar
2025-03-20 10:08 ` David Gow
0 siblings, 1 reply; 2+ messages in thread
From: Rae Moar @ 2025-03-19 22:33 UTC (permalink / raw)
To: shuah, davidgow
Cc: jackmanb, linux-kselftest, kunit-dev, linux-kernel, Rae Moar
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
Signed-off-by: Rae Moar <rmoar@google.com>
---
tools/testing/kunit/kunit_parser.py | 4 ++++
tools/testing/kunit/kunit_tool_test.py | 4 ++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/testing/kunit/kunit_parser.py b/tools/testing/kunit/kunit_parser.py
index da53a709773a..c176487356e6 100644
--- a/tools/testing/kunit/kunit_parser.py
+++ b/tools/testing/kunit/kunit_parser.py
@@ -809,6 +809,10 @@ def parse_test(lines: LineStream, expected_num: int, log: List[str], is_subtest:
test.log.extend(parse_diagnostic(lines))
if test.name != "" and not peek_test_name_match(lines, test):
test.add_error(printer, 'missing subtest result line!')
+ elif not lines:
+ print_log(test.log, printer)
+ test.status = TestStatus.NO_TESTS
+ test.add_error(printer, 'No more test results!')
else:
parse_test_result(lines, test, expected_num, printer)
diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py
index 5ff4f6ffd873..bbba921e0eac 100755
--- a/tools/testing/kunit/kunit_tool_test.py
+++ b/tools/testing/kunit/kunit_tool_test.py
@@ -371,8 +371,8 @@ class KUnitParserTest(unittest.TestCase):
"""
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))
+ self.assertEqual(kunit_parser.TestStatus.SUCCESS, result.status)
+ self.assertEqual(result.counts, kunit_parser.TestCounts(passed=1, errors=2))
def line_stream_from_strs(strs: Iterable[str]) -> kunit_parser.LineStream:
return kunit_parser.LineStream(enumerate(strs, start=1))
base-commit: 2e0cf2b32f72b20b0db5cc665cd8465d0f257278
--
2.49.0.395.g12beb8f557-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] kunit: tool: fix count of tests if late test plan
2025-03-19 22:33 [PATCH] kunit: tool: fix count of tests if late test plan Rae Moar
@ 2025-03-20 10:08 ` David Gow
0 siblings, 0 replies; 2+ messages in thread
From: David Gow @ 2025-03-20 10:08 UTC (permalink / raw)
To: Rae Moar; +Cc: shuah, jackmanb, linux-kselftest, kunit-dev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2625 bytes --]
On Thu, 20 Mar 2025 at 06:33, Rae Moar <rmoar@google.com> wrote:
>
> 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
>
> Signed-off-by: Rae Moar <rmoar@google.com>
> ---
Thanks!
Reviewed-by: David Gow <davidgow@google.com>
Cheers,
-- David
> tools/testing/kunit/kunit_parser.py | 4 ++++
> tools/testing/kunit/kunit_tool_test.py | 4 ++--
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/kunit/kunit_parser.py b/tools/testing/kunit/kunit_parser.py
> index da53a709773a..c176487356e6 100644
> --- a/tools/testing/kunit/kunit_parser.py
> +++ b/tools/testing/kunit/kunit_parser.py
> @@ -809,6 +809,10 @@ def parse_test(lines: LineStream, expected_num: int, log: List[str], is_subtest:
> test.log.extend(parse_diagnostic(lines))
> if test.name != "" and not peek_test_name_match(lines, test):
> test.add_error(printer, 'missing subtest result line!')
> + elif not lines:
> + print_log(test.log, printer)
> + test.status = TestStatus.NO_TESTS
> + test.add_error(printer, 'No more test results!')
> else:
> parse_test_result(lines, test, expected_num, printer)
>
> diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py
> index 5ff4f6ffd873..bbba921e0eac 100755
> --- a/tools/testing/kunit/kunit_tool_test.py
> +++ b/tools/testing/kunit/kunit_tool_test.py
> @@ -371,8 +371,8 @@ class KUnitParserTest(unittest.TestCase):
> """
> 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))
> + self.assertEqual(kunit_parser.TestStatus.SUCCESS, result.status)
> + self.assertEqual(result.counts, kunit_parser.TestCounts(passed=1, errors=2))
>
> def line_stream_from_strs(strs: Iterable[str]) -> kunit_parser.LineStream:
> return kunit_parser.LineStream(enumerate(strs, start=1))
>
> base-commit: 2e0cf2b32f72b20b0db5cc665cd8465d0f257278
> --
> 2.49.0.395.g12beb8f557-goog
>
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5281 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-20 10:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-19 22:33 [PATCH] kunit: tool: fix count of tests if late test plan Rae Moar
2025-03-20 10:08 ` David Gow
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox