linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kunit: tool: suggest using decode_stacktrace.sh on kernel crash
@ 2021-11-20  3:24 Daniel Latypov
  2021-12-07 22:58 ` Brendan Higgins
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Latypov @ 2021-11-20  3:24 UTC (permalink / raw)
  To: brendanhiggins, davidgow
  Cc: linux-kernel, kunit-dev, linux-kselftest, skhan, Daniel Latypov

kunit.py isn't very clear that
1) it stashes a copy of the unparsed output in $BUILD_DIR/test.log
2) it sets $BUILD_DIR=.kunit by default

So it's trickier than it should be for a user to come up with the right
command to do so.

Make kunit.py print out a command for this if
a) we saw a test case crash
b) we only ran one kernel (test.log only contains output from the last)

Example suggested command:
$ scripts/decode_stacktrace.sh .kunit/vmlinux .kunit < .kunit/test.log | tee .kunit/decoded.log | ./tools/testing/kunit/kunit.py parse

Without debug info a user might see something like
[14:11:25] Call Trace:
[14:11:25] ? kunit_binary_assert_format (:?)
[14:11:25] kunit_try_run_case (test.c:?)
[14:11:25] ? __kthread_parkme (kthread.c:?)
[14:11:25] kunit_generic_run_threadfn_adapter (try-catch.c:?)
[14:11:25] ? kunit_generic_run_threadfn_adapter (try-catch.c:?)
[14:11:25] kthread (kthread.c:?)
[14:11:25] new_thread_handler (:?)
[14:11:25] [CRASHED]

`tee` is in GNU coreutils, so it seems fine to add that into the
pipeline by default, that way users can inspect the otuput in more
detail.

Note: to turn on debug info, users would need to do something like
$ echo -e 'CONFIG_DEBUG_KERNEL=y\nCONFIG_DEBUG_INFO=y' >> .kunit/.kunitconfig
$ ./tools/testing/kunit/kunit.py config
$ ./tools/testing/kunit/kunit.py build
$ <then run decode_stacktrace.sh now vmlinux is updated>

This feels too clunky to include in the instructions.
With --kconfig_add [1], it would become a bit less painful.

[1] https://lore.kernel.org/linux-kselftest/20211106013058.2621799-2-dlatypov@google.com/

Signed-off-by: Daniel Latypov <dlatypov@google.com>
---
 tools/testing/kunit/kunit.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py
index 68e6f461c758..a45836ac2ca1 100755
--- a/tools/testing/kunit/kunit.py
+++ b/tools/testing/kunit/kunit.py
@@ -156,6 +156,12 @@ def exec_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitExecRequest,
 
 		test_counts.add_subtest_counts(result.result.test.counts)
 
+	if len(filter_globs) == 1 and test_counts.crashed > 0:
+		bd = request.build_dir
+		print('The kernel seems to have crashed; you can decode the stack traces with:')
+		print('$ scripts/decode_stacktrace.sh {}/vmlinux {} < {} | tee {}/decoded.log | {} parse'.format(
+				bd, bd, kunit_kernel.get_outfile_path(bd), bd, sys.argv[0]))
+
 	kunit_status = _map_to_overall_status(test_counts.get_status())
 	return KunitResult(status=kunit_status, result=result.result, elapsed_time=exec_time)
 

base-commit: fa55b7dcdc43c1aa1ba12bca9d2dd4318c2a0dbf
-- 
2.34.0.rc2.393.gf8c9666880-goog


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

* Re: [PATCH] kunit: tool: suggest using decode_stacktrace.sh on kernel crash
  2021-11-20  3:24 [PATCH] kunit: tool: suggest using decode_stacktrace.sh on kernel crash Daniel Latypov
@ 2021-12-07 22:58 ` Brendan Higgins
  0 siblings, 0 replies; 2+ messages in thread
From: Brendan Higgins @ 2021-12-07 22:58 UTC (permalink / raw)
  To: Daniel Latypov; +Cc: davidgow, linux-kernel, kunit-dev, linux-kselftest, skhan

On Fri, Nov 19, 2021 at 10:24 PM Daniel Latypov <dlatypov@google.com> wrote:
>
> kunit.py isn't very clear that
> 1) it stashes a copy of the unparsed output in $BUILD_DIR/test.log
> 2) it sets $BUILD_DIR=.kunit by default
>
> So it's trickier than it should be for a user to come up with the right
> command to do so.
>
> Make kunit.py print out a command for this if
> a) we saw a test case crash
> b) we only ran one kernel (test.log only contains output from the last)
>
> Example suggested command:
> $ scripts/decode_stacktrace.sh .kunit/vmlinux .kunit < .kunit/test.log | tee .kunit/decoded.log | ./tools/testing/kunit/kunit.py parse
>
> Without debug info a user might see something like
> [14:11:25] Call Trace:
> [14:11:25] ? kunit_binary_assert_format (:?)
> [14:11:25] kunit_try_run_case (test.c:?)
> [14:11:25] ? __kthread_parkme (kthread.c:?)
> [14:11:25] kunit_generic_run_threadfn_adapter (try-catch.c:?)
> [14:11:25] ? kunit_generic_run_threadfn_adapter (try-catch.c:?)
> [14:11:25] kthread (kthread.c:?)
> [14:11:25] new_thread_handler (:?)
> [14:11:25] [CRASHED]
>
> `tee` is in GNU coreutils, so it seems fine to add that into the
> pipeline by default, that way users can inspect the otuput in more
> detail.
>
> Note: to turn on debug info, users would need to do something like
> $ echo -e 'CONFIG_DEBUG_KERNEL=y\nCONFIG_DEBUG_INFO=y' >> .kunit/.kunitconfig
> $ ./tools/testing/kunit/kunit.py config
> $ ./tools/testing/kunit/kunit.py build
> $ <then run decode_stacktrace.sh now vmlinux is updated>
>
> This feels too clunky to include in the instructions.
> With --kconfig_add [1], it would become a bit less painful.
>
> [1] https://lore.kernel.org/linux-kselftest/20211106013058.2621799-2-dlatypov@google.com/
>
> Signed-off-by: Daniel Latypov <dlatypov@google.com>

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

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

end of thread, other threads:[~2021-12-07 22:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-20  3:24 [PATCH] kunit: tool: suggest using decode_stacktrace.sh on kernel crash Daniel Latypov
2021-12-07 22:58 ` 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).