[23/25] selftests/ftrace: Add max stack tracer testcase
diff mbox series

Message ID 153269404756.3084.16183774834747280299.stgit@devbox
State New
Headers show
Series
  • selftests/ftrace: Improve ftracetest with coverage check
Related show

Commit Message

Masami Hiramatsu July 27, 2018, 12:20 p.m. UTC
Add a testcase for max stack tracer, which checks basic
max stack usage tracing and its filter feature.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 .../ftrace/test.d/ftrace/func_stack_tracer.tc      |   39 ++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc


--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Masami Hiramatsu Aug. 3, 2018, 5:24 a.m. UTC | #1
On Fri, 27 Jul 2018 21:20:47 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> Add a testcase for max stack tracer, which checks basic
> max stack usage tracing and its filter feature.
> 

Hmm, this test sometimes fails. (not always)
Let me check what happens.

Thank you,


> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> ---
>  .../ftrace/test.d/ftrace/func_stack_tracer.tc      |   39 ++++++++++++++++++++
>  1 file changed, 39 insertions(+)
>  create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc
> 
> diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc
> new file mode 100644
> index 000000000000..b414f0e3c646
> --- /dev/null
> +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc
> @@ -0,0 +1,39 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +# description: ftrace - Max stack tracer
> +# Test the basic function of max-stack usage tracing
> +
> +if [ ! -f stack_trace ]; then
> +  echo "Max stack tracer is not supported - please make CONFIG_STACK_TRACER=y"
> +  exit_unsupported
> +fi
> +
> +echo > stack_trace_filter
> +echo 0 > stack_max_size
> +echo 1 > /proc/sys/kernel/stack_tracer_enabled
> +
> +: "Fork and wait for the first entry become !lock"
> +timeout=10
> +while [ $timeout -ne 0 ]; do
> +  ( echo "forked" )
> +  FL=`grep " 0)" stack_trace`
> +  echo $FL | grep -q "lock" || break;
> +  timeout=$((timeout - 1))
> +done
> +echo 0 > /proc/sys/kernel/stack_tracer_enabled
> +
> +echo '*lock*' > stack_trace_filter
> +test `cat stack_trace_filter | wc -l` -eq `grep lock stack_trace_filter | wc -l`
> +
> +echo 0 > stack_max_size
> +echo 1 > /proc/sys/kernel/stack_tracer_enabled
> +
> +: "Fork and always the first entry including lock"
> +timeout=10
> +while [ $timeout -ne 0 ]; do
> +  ( echo "forked" )
> +  FL=`grep " 0)" stack_trace`
> +  echo $FL | grep -q "lock"
> +  timeout=$((timeout - 1))
> +done
> +echo 0 > /proc/sys/kernel/stack_tracer_enabled
>

Patch
diff mbox series

diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc
new file mode 100644
index 000000000000..b414f0e3c646
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc
@@ -0,0 +1,39 @@ 
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# description: ftrace - Max stack tracer
+# Test the basic function of max-stack usage tracing
+
+if [ ! -f stack_trace ]; then
+  echo "Max stack tracer is not supported - please make CONFIG_STACK_TRACER=y"
+  exit_unsupported
+fi
+
+echo > stack_trace_filter
+echo 0 > stack_max_size
+echo 1 > /proc/sys/kernel/stack_tracer_enabled
+
+: "Fork and wait for the first entry become !lock"
+timeout=10
+while [ $timeout -ne 0 ]; do
+  ( echo "forked" )
+  FL=`grep " 0)" stack_trace`
+  echo $FL | grep -q "lock" || break;
+  timeout=$((timeout - 1))
+done
+echo 0 > /proc/sys/kernel/stack_tracer_enabled
+
+echo '*lock*' > stack_trace_filter
+test `cat stack_trace_filter | wc -l` -eq `grep lock stack_trace_filter | wc -l`
+
+echo 0 > stack_max_size
+echo 1 > /proc/sys/kernel/stack_tracer_enabled
+
+: "Fork and always the first entry including lock"
+timeout=10
+while [ $timeout -ne 0 ]; do
+  ( echo "forked" )
+  FL=`grep " 0)" stack_trace`
+  echo $FL | grep -q "lock"
+  timeout=$((timeout - 1))
+done
+echo 0 > /proc/sys/kernel/stack_tracer_enabled