linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kunit: tool: tweak error message when no KTAP found
@ 2022-11-11  3:18 Daniel Latypov
  2022-11-19  8:32 ` David Gow
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Latypov @ 2022-11-11  3:18 UTC (permalink / raw)
  To: brendanhiggins, davidgow
  Cc: rmoar, linux-kernel, kunit-dev, linux-kselftest, skhan, Daniel Latypov

We currently tell people we "couldn't find any KTAP output" with no
indication as to what this might mean.

After this patch, we get:

$ ./tools/testing/kunit/kunit.py parse /dev/null
============================================================
[ERROR] Test: <missing>: Could not find any KTAP output. Did any KUnit tests run?
============================================================
Testing complete. Ran 0 tests: errors: 1

Note: we could try and generate a more verbose message like
> Please check .kunit/test.log to see the raw kernel output.
or the like, but we'd need to know what the build dir was to know where
test.log actually lives.

This patch tries to make a more minimal improvement.

Signed-off-by: Daniel Latypov <dlatypov@google.com>
---
 tools/testing/kunit/kunit_parser.py    | 2 +-
 tools/testing/kunit/kunit_tool_test.py | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/kunit/kunit_parser.py b/tools/testing/kunit/kunit_parser.py
index a56c75a973b5..d0ed5dd5cfc4 100644
--- a/tools/testing/kunit/kunit_parser.py
+++ b/tools/testing/kunit/kunit_parser.py
@@ -782,7 +782,7 @@ def parse_run_tests(kernel_output: Iterable[str]) -> Test:
 	test = Test()
 	if not lines:
 		test.name = '<missing>'
-		test.add_error('could not find any KTAP output!')
+		test.add_error('Could not find any KTAP output. Did any KUnit tests run?')
 		test.status = TestStatus.FAILURE_TO_PARSE_TESTS
 	else:
 		test = parse_test(lines, 0, [])
diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py
index 90c65b072be9..84a08cf07242 100755
--- a/tools/testing/kunit/kunit_tool_test.py
+++ b/tools/testing/kunit/kunit_tool_test.py
@@ -207,7 +207,7 @@ class KUnitParserTest(unittest.TestCase):
 		with open(crash_log) as file:
 			result = kunit_parser.parse_run_tests(
 				kunit_parser.extract_tap_lines(file.readlines()))
-		print_mock.assert_any_call(StrContains('could not find any KTAP output!'))
+		print_mock.assert_any_call(StrContains('Could not find any KTAP output.'))
 		print_mock.stop()
 		self.assertEqual(0, len(result.subtests))
 		self.assertEqual(result.counts.errors, 1)
@@ -588,7 +588,7 @@ class KUnitMainTest(unittest.TestCase):
 		self.assertEqual(e.exception.code, 1)
 		self.assertEqual(self.linux_source_mock.build_reconfig.call_count, 1)
 		self.assertEqual(self.linux_source_mock.run_kernel.call_count, 1)
-		self.print_mock.assert_any_call(StrContains('could not find any KTAP output!'))
+		self.print_mock.assert_any_call(StrContains('Could not find any KTAP output.'))
 
 	def test_exec_no_tests(self):
 		self.linux_source_mock.run_kernel = mock.Mock(return_value=['TAP version 14', '1..0'])

base-commit: 870f63b7cd78d0055902d839a60408f7428b4e84
-- 
2.38.1.431.g37b22c650d-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] kunit: tool: tweak error message when no KTAP found
  2022-11-11  3:18 [PATCH] kunit: tool: tweak error message when no KTAP found Daniel Latypov
@ 2022-11-19  8:32 ` David Gow
  0 siblings, 0 replies; 2+ messages in thread
From: David Gow @ 2022-11-19  8:32 UTC (permalink / raw)
  To: Daniel Latypov
  Cc: brendanhiggins, rmoar, linux-kernel, kunit-dev, linux-kselftest, skhan

[-- Attachment #1: Type: text/plain, Size: 3642 bytes --]

On Fri, Nov 11, 2022 at 11:19 AM Daniel Latypov <dlatypov@google.com> wrote:
>
> We currently tell people we "couldn't find any KTAP output" with no
> indication as to what this might mean.
>
> After this patch, we get:
>
> $ ./tools/testing/kunit/kunit.py parse /dev/null
> ============================================================
> [ERROR] Test: <missing>: Could not find any KTAP output. Did any KUnit tests run?
> ============================================================
> Testing complete. Ran 0 tests: errors: 1
>
> Note: we could try and generate a more verbose message like
> > Please check .kunit/test.log to see the raw kernel output.
> or the like, but we'd need to know what the build dir was to know where
> test.log actually lives.
>
> This patch tries to make a more minimal improvement.
>
> Signed-off-by: Daniel Latypov <dlatypov@google.com>
> ---

I agree that this is clearer.

One minor nitpick is that we still have the (useless) 'Test:
<missing>:' prefix, which also makes the error much longer than the
'===' dividers. I think the error would be more aesthetically pleasing
if we could fix that.

That's a very minor point, though, so regardless:

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

Cheers,
-- David

>  tools/testing/kunit/kunit_parser.py    | 2 +-
>  tools/testing/kunit/kunit_tool_test.py | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/kunit/kunit_parser.py b/tools/testing/kunit/kunit_parser.py
> index a56c75a973b5..d0ed5dd5cfc4 100644
> --- a/tools/testing/kunit/kunit_parser.py
> +++ b/tools/testing/kunit/kunit_parser.py
> @@ -782,7 +782,7 @@ def parse_run_tests(kernel_output: Iterable[str]) -> Test:
>         test = Test()
>         if not lines:
>                 test.name = '<missing>'
> -               test.add_error('could not find any KTAP output!')
> +               test.add_error('Could not find any KTAP output. Did any KUnit tests run?')
>                 test.status = TestStatus.FAILURE_TO_PARSE_TESTS
>         else:
>                 test = parse_test(lines, 0, [])
> diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py
> index 90c65b072be9..84a08cf07242 100755
> --- a/tools/testing/kunit/kunit_tool_test.py
> +++ b/tools/testing/kunit/kunit_tool_test.py
> @@ -207,7 +207,7 @@ class KUnitParserTest(unittest.TestCase):
>                 with open(crash_log) as file:
>                         result = kunit_parser.parse_run_tests(
>                                 kunit_parser.extract_tap_lines(file.readlines()))
> -               print_mock.assert_any_call(StrContains('could not find any KTAP output!'))
> +               print_mock.assert_any_call(StrContains('Could not find any KTAP output.'))
>                 print_mock.stop()
>                 self.assertEqual(0, len(result.subtests))
>                 self.assertEqual(result.counts.errors, 1)
> @@ -588,7 +588,7 @@ class KUnitMainTest(unittest.TestCase):
>                 self.assertEqual(e.exception.code, 1)
>                 self.assertEqual(self.linux_source_mock.build_reconfig.call_count, 1)
>                 self.assertEqual(self.linux_source_mock.run_kernel.call_count, 1)
> -               self.print_mock.assert_any_call(StrContains('could not find any KTAP output!'))
> +               self.print_mock.assert_any_call(StrContains('Could not find any KTAP output.'))
>
>         def test_exec_no_tests(self):
>                 self.linux_source_mock.run_kernel = mock.Mock(return_value=['TAP version 14', '1..0'])
>
> base-commit: 870f63b7cd78d0055902d839a60408f7428b4e84
> --
> 2.38.1.431.g37b22c650d-goog
>

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4003 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-19  8:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-11  3:18 [PATCH] kunit: tool: tweak error message when no KTAP found Daniel Latypov
2022-11-19  8:32 ` David Gow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).