linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kunit: kunit_tool: Correctly parse diagnostic messages
@ 2020-11-10  7:29 David Gow
  2020-11-10 10:58 ` Marco Elver
  2020-11-30 22:01 ` Brendan Higgins
  0 siblings, 2 replies; 3+ messages in thread
From: David Gow @ 2020-11-10  7:29 UTC (permalink / raw)
  To: brendanhiggins, Shuah Khan, Arpitha Raghunandan, Marco Elver
  Cc: KUnit Development, linux-kselftest, Linux Kernel Mailing List, David Gow

Currently, kunit_tool expects all diagnostic lines in test results to
contain ": " somewhere, as both the subtest header and the crash report
do. Fix this to accept any line starting with (minus indent) "# " as
being a valid diagnostic line.

This matches what the TAP spec[1] and the draft KTAP spec[2] are
expecting.

[1]: http://testanything.org/tap-specification.html
[2]: https://lore.kernel.org/linux-kselftest/CY4PR13MB1175B804E31E502221BC8163FD830@CY4PR13MB1175.namprd13.prod.outlook.com/T/

Signed-off-by: David Gow <davidgow@google.com>
---
 tools/testing/kunit/kunit_parser.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/testing/kunit/kunit_parser.py b/tools/testing/kunit/kunit_parser.py
index 84a1af2581f5..dab4cfa05b74 100644
--- a/tools/testing/kunit/kunit_parser.py
+++ b/tools/testing/kunit/kunit_parser.py
@@ -134,8 +134,8 @@ def parse_ok_not_ok_test_case(lines: List[str], test_case: TestCase) -> bool:
 	else:
 		return False
 
-SUBTEST_DIAGNOSTIC = re.compile(r'^[\s]+# .*?: (.*)$')
-DIAGNOSTIC_CRASH_MESSAGE = 'kunit test case crashed!'
+SUBTEST_DIAGNOSTIC = re.compile(r'^[\s]+# (.*)$')
+DIAGNOSTIC_CRASH_MESSAGE = re.compile(r'^[\s]+# .*?: kunit test case crashed!$')
 
 def parse_diagnostic(lines: List[str], test_case: TestCase) -> bool:
 	save_non_diagnositic(lines, test_case)
@@ -145,7 +145,8 @@ def parse_diagnostic(lines: List[str], test_case: TestCase) -> bool:
 	match = SUBTEST_DIAGNOSTIC.match(line)
 	if match:
 		test_case.log.append(lines.pop(0))
-		if match.group(1) == DIAGNOSTIC_CRASH_MESSAGE:
+		crash_match = DIAGNOSTIC_CRASH_MESSAGE.match(line)
+		if crash_match:
 			test_case.status = TestStatus.TEST_CRASHED
 		return True
 	else:
-- 
2.29.2.222.g5d2a92d10f8-goog


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

* Re: [PATCH] kunit: kunit_tool: Correctly parse diagnostic messages
  2020-11-10  7:29 [PATCH] kunit: kunit_tool: Correctly parse diagnostic messages David Gow
@ 2020-11-10 10:58 ` Marco Elver
  2020-11-30 22:01 ` Brendan Higgins
  1 sibling, 0 replies; 3+ messages in thread
From: Marco Elver @ 2020-11-10 10:58 UTC (permalink / raw)
  To: David Gow
  Cc: Brendan Higgins, Shuah Khan, Arpitha Raghunandan,
	KUnit Development, open list:KERNEL SELFTEST FRAMEWORK,
	Linux Kernel Mailing List

On Tue, 10 Nov 2020 at 08:29, David Gow <davidgow@google.com> wrote:
>
> Currently, kunit_tool expects all diagnostic lines in test results to
> contain ": " somewhere, as both the subtest header and the crash report
> do. Fix this to accept any line starting with (minus indent) "# " as
> being a valid diagnostic line.
>
> This matches what the TAP spec[1] and the draft KTAP spec[2] are
> expecting.
>
> [1]: http://testanything.org/tap-specification.html
> [2]: https://lore.kernel.org/linux-kselftest/CY4PR13MB1175B804E31E502221BC8163FD830@CY4PR13MB1175.namprd13.prod.outlook.com/T/
>
> Signed-off-by: David Gow <davidgow@google.com>

Acked-by: Marco Elver <elver@google.com>

Thanks!

> ---
>  tools/testing/kunit/kunit_parser.py | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/kunit/kunit_parser.py b/tools/testing/kunit/kunit_parser.py
> index 84a1af2581f5..dab4cfa05b74 100644
> --- a/tools/testing/kunit/kunit_parser.py
> +++ b/tools/testing/kunit/kunit_parser.py
> @@ -134,8 +134,8 @@ def parse_ok_not_ok_test_case(lines: List[str], test_case: TestCase) -> bool:
>         else:
>                 return False
>
> -SUBTEST_DIAGNOSTIC = re.compile(r'^[\s]+# .*?: (.*)$')
> -DIAGNOSTIC_CRASH_MESSAGE = 'kunit test case crashed!'
> +SUBTEST_DIAGNOSTIC = re.compile(r'^[\s]+# (.*)$')
> +DIAGNOSTIC_CRASH_MESSAGE = re.compile(r'^[\s]+# .*?: kunit test case crashed!$')
>
>  def parse_diagnostic(lines: List[str], test_case: TestCase) -> bool:
>         save_non_diagnositic(lines, test_case)
> @@ -145,7 +145,8 @@ def parse_diagnostic(lines: List[str], test_case: TestCase) -> bool:
>         match = SUBTEST_DIAGNOSTIC.match(line)
>         if match:
>                 test_case.log.append(lines.pop(0))
> -               if match.group(1) == DIAGNOSTIC_CRASH_MESSAGE:
> +               crash_match = DIAGNOSTIC_CRASH_MESSAGE.match(line)
> +               if crash_match:
>                         test_case.status = TestStatus.TEST_CRASHED
>                 return True
>         else:
> --
> 2.29.2.222.g5d2a92d10f8-goog
>

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

* Re: [PATCH] kunit: kunit_tool: Correctly parse diagnostic messages
  2020-11-10  7:29 [PATCH] kunit: kunit_tool: Correctly parse diagnostic messages David Gow
  2020-11-10 10:58 ` Marco Elver
@ 2020-11-30 22:01 ` Brendan Higgins
  1 sibling, 0 replies; 3+ messages in thread
From: Brendan Higgins @ 2020-11-30 22:01 UTC (permalink / raw)
  To: David Gow
  Cc: Shuah Khan, Arpitha Raghunandan, Marco Elver, KUnit Development,
	open list:KERNEL SELFTEST FRAMEWORK, Linux Kernel Mailing List

On Mon, Nov 9, 2020 at 11:29 PM David Gow <davidgow@google.com> wrote:
>
> Currently, kunit_tool expects all diagnostic lines in test results to
> contain ": " somewhere, as both the subtest header and the crash report
> do. Fix this to accept any line starting with (minus indent) "# " as
> being a valid diagnostic line.
>
> This matches what the TAP spec[1] and the draft KTAP spec[2] are
> expecting.
>
> [1]: http://testanything.org/tap-specification.html
> [2]: https://lore.kernel.org/linux-kselftest/CY4PR13MB1175B804E31E502221BC8163FD830@CY4PR13MB1175.namprd13.prod.outlook.com/T/
>
> Signed-off-by: David Gow <davidgow@google.com>

Reviewed-by: Brendan Higgins <brendanhiggins@google.com>

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

end of thread, other threads:[~2020-11-30 22:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-10  7:29 [PATCH] kunit: kunit_tool: Correctly parse diagnostic messages David Gow
2020-11-10 10:58 ` Marco Elver
2020-11-30 22:01 ` Brendan Higgins

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).