* [RFC PATCH 0/4 v2] ftracetests: Add ftrace tests to ftracetests
@ 2014-11-03 21:27 Steven Rostedt
2014-11-03 21:27 ` [RFC PATCH 1/4 v2] ftracetest: Add clear_trace() helper to reset the trace file Steven Rostedt
` (5 more replies)
0 siblings, 6 replies; 10+ messages in thread
From: Steven Rostedt @ 2014-11-03 21:27 UTC (permalink / raw)
To: linux-kernel; +Cc: Masami Hiramatsu, Andrew Morton
Second attempt. I took the advice from Masami Hiramatsu and modified
my tests. I also added some helper functions to ftracetests as well.
I split the one function graph test into two. One to just test the
filtering of the function graph and another to test with stack tracer.
Steven Rostedt (Red Hat) (4):
ftracetest: Add clear_trace() helper to reset the trace file
ftracetest: Add disable/enable_tracing() helper calls
ftracetest: Add helper reset_tracer() function
ftracetest: Add a couple of ftrace test cases
----
tools/testing/selftests/ftrace/ftracetest | 3 +
.../ftrace/test.d/ftrace/fgraph-filter-stack.tc | 94 ++++++++++++++++++++++
.../ftrace/test.d/ftrace/fgraph-filter.tc | 49 +++++++++++
.../ftrace/test.d/ftrace/func_profiler.tc | 76 +++++++++++++++++
tools/testing/selftests/ftrace/test.d/functions | 16 ++++
5 files changed, 238 insertions(+)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [RFC PATCH 1/4 v2] ftracetest: Add clear_trace() helper to reset the trace file
2014-11-03 21:27 [RFC PATCH 0/4 v2] ftracetests: Add ftrace tests to ftracetests Steven Rostedt
@ 2014-11-03 21:27 ` Steven Rostedt
2014-11-03 21:27 ` [RFC PATCH 2/4 v2] ftracetest: Add disable/enable_tracing() helper calls Steven Rostedt
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2014-11-03 21:27 UTC (permalink / raw)
To: linux-kernel; +Cc: Masami Hiramatsu, Andrew Morton
[-- Attachment #1: 0001-ftracetest-Add-clear_trace-helper-to-reset-the-trace.patch --]
[-- Type: text/plain, Size: 1270 bytes --]
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
Created the file tools/testing/ftrace/test.d/functions that will
hold helper functions.
First function added was clear_trace() that is descriptive in its
name to show that "echo > trace" is clearing the trace file.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
tools/testing/selftests/ftrace/ftracetest | 3 +++
tools/testing/selftests/ftrace/test.d/functions | 4 ++++
2 files changed, 7 insertions(+)
create mode 100644 tools/testing/selftests/ftrace/test.d/functions
diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index f15c0da07aca..c6381a9faf83 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -235,6 +235,9 @@ run_test() { # testfile
fi
}
+# load in the helper functions
+. $TEST_DIR/functions
+
# Main loop
for t in $TEST_CASES; do
run_test $t
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
new file mode 100644
index 000000000000..1aa9f2e9c40b
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/functions
@@ -0,0 +1,4 @@
+
+clear_trace() { # reset trace output
+ echo > trace
+}
--
2.1.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC PATCH 2/4 v2] ftracetest: Add disable/enable_tracing() helper calls
2014-11-03 21:27 [RFC PATCH 0/4 v2] ftracetests: Add ftrace tests to ftracetests Steven Rostedt
2014-11-03 21:27 ` [RFC PATCH 1/4 v2] ftracetest: Add clear_trace() helper to reset the trace file Steven Rostedt
@ 2014-11-03 21:27 ` Steven Rostedt
2014-11-03 21:27 ` [RFC PATCH 3/4 v2] ftracetest: Add helper reset_tracer() function Steven Rostedt
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2014-11-03 21:27 UTC (permalink / raw)
To: linux-kernel; +Cc: Masami Hiramatsu, Andrew Morton
[-- Attachment #1: 0002-ftracetest-Add-disable-enable_tracing-helper-calls.patch --]
[-- Type: text/plain, Size: 794 bytes --]
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
Add calls that disable and enable tracing respectively by echoing
0 or 1 into tracing_on.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
tools/testing/selftests/ftrace/test.d/functions | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
index 1aa9f2e9c40b..c5bf630e9be8 100644
--- a/tools/testing/selftests/ftrace/test.d/functions
+++ b/tools/testing/selftests/ftrace/test.d/functions
@@ -2,3 +2,11 @@
clear_trace() { # reset trace output
echo > trace
}
+
+disable_tracing() { # stop trace recording
+ echo 0 > tracing_on
+}
+
+enable_tracing() { # start trace recording
+ echo 1 > tracing_on
+}
--
2.1.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC PATCH 3/4 v2] ftracetest: Add helper reset_tracer() function
2014-11-03 21:27 [RFC PATCH 0/4 v2] ftracetests: Add ftrace tests to ftracetests Steven Rostedt
2014-11-03 21:27 ` [RFC PATCH 1/4 v2] ftracetest: Add clear_trace() helper to reset the trace file Steven Rostedt
2014-11-03 21:27 ` [RFC PATCH 2/4 v2] ftracetest: Add disable/enable_tracing() helper calls Steven Rostedt
@ 2014-11-03 21:27 ` Steven Rostedt
2014-11-03 21:27 ` [RFC PATCH 4/4 v2] ftracetest: Add a couple of ftrace test cases Steven Rostedt
` (2 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2014-11-03 21:27 UTC (permalink / raw)
To: linux-kernel; +Cc: Masami Hiramatsu, Andrew Morton
[-- Attachment #1: 0003-ftracetest-Add-helper-reset_tracer-function.patch --]
[-- Type: text/plain, Size: 791 bytes --]
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
Add a helper function reset_tracer() that will clear the current_tracer
(echo nop > current_tracer).
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
tools/testing/selftests/ftrace/test.d/functions | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
index c5bf630e9be8..5d8cd06d920f 100644
--- a/tools/testing/selftests/ftrace/test.d/functions
+++ b/tools/testing/selftests/ftrace/test.d/functions
@@ -10,3 +10,7 @@ disable_tracing() { # stop trace recording
enable_tracing() { # start trace recording
echo 1 > tracing_on
}
+
+reset_tracer() { # reset the current tracer
+ echo nop > current_tracer
+}
--
2.1.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC PATCH 4/4 v2] ftracetest: Add a couple of ftrace test cases
2014-11-03 21:27 [RFC PATCH 0/4 v2] ftracetests: Add ftrace tests to ftracetests Steven Rostedt
` (2 preceding siblings ...)
2014-11-03 21:27 ` [RFC PATCH 3/4 v2] ftracetest: Add helper reset_tracer() function Steven Rostedt
@ 2014-11-03 21:27 ` Steven Rostedt
2014-11-04 8:31 ` Namhyung Kim
2014-11-04 5:59 ` [RFC PATCH 0/4 v2] ftracetests: Add ftrace tests to ftracetests Masami Hiramatsu
2014-11-04 9:30 ` Masami Hiramatsu
5 siblings, 1 reply; 10+ messages in thread
From: Steven Rostedt @ 2014-11-03 21:27 UTC (permalink / raw)
To: linux-kernel; +Cc: Masami Hiramatsu, Andrew Morton
[-- Attachment #1: 0004-ftracetest-Add-a-couple-of-ftrace-test-cases.patch --]
[-- Type: text/plain, Size: 7169 bytes --]
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
Added three test cases to get the feel of adding tests to ftracetest.
The three cases are:
function profiling test, to make sure function profiling still works
with function tracing (was a regression)
function graph filter test to make sure that function graph filtering works.
function graph filter with stack tracing test to make sure that the function
graph filter does filter and also continues to filter when another function tracer
is running (like the stack tracer)
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
.../ftrace/test.d/ftrace/fgraph-filter-stack.tc | 94 ++++++++++++++++++++++
.../ftrace/test.d/ftrace/fgraph-filter.tc | 49 +++++++++++
.../ftrace/test.d/ftrace/func_profiler.tc | 76 +++++++++++++++++
3 files changed, 219 insertions(+)
create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc
create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc
create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc
new file mode 100644
index 000000000000..3d8f79176681
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc
@@ -0,0 +1,94 @@
+#!/bin/sh
+# description: ftrace - function graph filters with stack tracer
+
+# Make sure that function graph filtering works, and is not
+# affected by other tracers enabled (like stack tracer)
+
+if ! grep -q function_graph available_tracers; then
+ echo "no function graph tracer configured"
+ exit_unsupported
+fi
+
+if [ ! -f set_ftrace_filter ]; then
+ echo "set_ftrace_filter not found? Is dynamic ftrace not set?"
+ exit_unsupported
+fi
+
+do_reset() {
+ reset_tracer
+ echo 0 > /proc/sys/kernel/stack_tracer_enabled
+ enable_tracing
+ clear_trace
+ echo > set_ftrace_filter
+}
+
+disable_tracing
+clear_trace;
+
+# filter something, schedule is always good
+if ! echo "schedule" > set_ftrace_filter; then
+ # test for powerpc 64
+ if ! echo ".schedule" > set_ftrace_filter; then
+ echo "can not enable schedule filter"
+ exit -1
+ fi
+fi
+
+echo function_graph > current_tracer
+
+if [ ! -f stack_trace ]; then
+ echo "Stack tracer not configured"
+ do_reset
+ exit_unsupported;
+fi
+
+echo "Now testing with stack tracer"
+
+echo 1 > /proc/sys/kernel/stack_tracer_enabled
+
+disable_tracing
+clear_trace
+enable_tracing
+sleep 1
+
+count=`cat trace | grep '()' | grep -v schedule | wc -l`
+
+if [ $count -ne 0 ]; then
+ echo "Graph filtering not working with stack tracer?"
+ exit -1
+fi
+
+count=`cat trace | grep 'schedule()' | wc -l`
+if [ $count -eq 0 ]; then
+ echo "No schedule traces found?"
+ exit -1
+fi
+
+# Make sure we did find something
+count=`cat trace | grep 'schedule()' | wc -l`
+if [ $count -eq 0 ]; then
+ echo "No schedule traces found?"
+ exit -1
+fi
+
+echo 0 > /proc/sys/kernel/stack_tracer_enabled
+clear_trace
+sleep 1
+
+
+count=`cat trace | grep '()' | grep -v schedule | wc -l`
+
+if [ $count -ne 0 ]; then
+ echo "Graph filtering not working after stack tracer disabled?"
+ exit -1
+fi
+
+count=`cat trace | grep 'schedule()' | wc -l`
+if [ $count -eq 0 ]; then
+ echo "No schedule traces found?"
+ exit -1
+fi
+
+do_reset
+
+exit 0
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc
new file mode 100644
index 000000000000..18bda31c4c54
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc
@@ -0,0 +1,49 @@
+#!/bin/sh
+# description: ftrace - function graph filters
+
+# Make sure that function graph filtering works
+
+if ! grep -q function_graph available_tracers; then
+ echo "no function graph tracer configured"
+ exit_unsupported
+fi
+
+do_reset() {
+ reset_tracer
+ enable_tracing
+ clear_trace
+}
+
+disable_tracing
+clear_trace
+
+# filter something, schedule is always good
+if ! echo "schedule" > set_ftrace_filter; then
+ # test for powerpc 64
+ if ! echo ".schedule" > set_ftrace_filter; then
+ echo "can not enable schedule filter"
+ exit -1
+ fi
+fi
+
+echo function_graph > current_tracer
+enable_tracing
+sleep 1
+# search for functions (has "()" on the line), and make sure
+# that only the schedule function was found
+count=`cat trace | grep '()' | grep -v schedule | wc -l`
+if [ $count -ne 0 ]; then
+ echo "Graph filtering not working by itself?"
+ exit -1;
+fi
+
+# Make sure we did find something
+count=`cat trace | grep 'schedule()' | wc -l`
+if [ $count -eq 0 ]; then
+ echo "No schedule traces found?"
+ exit -1
+fi
+
+do_reset
+
+exit 0
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc
new file mode 100644
index 000000000000..d09d9a676530
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc
@@ -0,0 +1,76 @@
+#!/bin/sh
+# description: ftrace - function profiler with function tracing
+
+# There was a bug after a rewrite of the ftrace infrastructure that
+# caused the function_profiler not to be able to run with the function
+# tracer, because the function_profiler used the function_graph tracer
+# and it was assumed the two could not run simultaneously.
+#
+# There was another related bug where the solution to the first bug
+# broke the way filtering of the function tracer worked.
+#
+# This test triggers those bugs on those kernels.
+#
+# We need function_graph and profiling to to run this test
+if ! grep -q function_graph available_tracers; then
+ echo "no function graph tracer configured"
+ exit_unsupported;
+fi
+
+if [ ! -f set_ftrace_filter ]; then
+ echo "set_ftrace_filter not found? Is dynamic ftrace not set?"
+ exit_unsupported
+fi
+
+if [ ! -f function_profile_enabled ]; then
+ echo "function_profile_enabled not found, function profiling enabled?"
+ exit_unsupported
+fi
+
+echo "Testing function tracer with profiler:"
+echo "enable function tracer"
+echo function > current_tracer
+echo "enable profiler"
+echo 1 > function_profile_enabled
+
+sleep 1
+
+echo "Now filter on just schedule"
+echo '*schedule' > set_ftrace_filter
+clear_trace
+
+echo "Now disable function profiler"
+echo 0 > function_profile_enabled
+
+sleep 1
+
+# make sure only schedule functions exist
+
+echo "testing if only schedule is being traced"
+if grep -v -e '^#' -e 'schedule' trace; then
+ echo "more than schedule was found"
+ exit 1
+fi
+
+echo "Make sure schedule was traced"
+if ! grep -e 'schedule' trace > /dev/null; then
+ cat trace
+ echo "can not find schedule in trace"
+ exit 1
+fi
+
+echo > set_ftrace_filter
+clear_trace
+
+sleep 1
+
+echo "make sure something other than scheduler is being traced"
+if ! grep -v -e '^#' -e 'schedule' trace > /dev/null; then
+ cat trace
+ echo "no other functions besides schedule was found"
+ exit 1
+fi
+
+reset_tracer
+
+exit 0
--
2.1.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 0/4 v2] ftracetests: Add ftrace tests to ftracetests
2014-11-03 21:27 [RFC PATCH 0/4 v2] ftracetests: Add ftrace tests to ftracetests Steven Rostedt
` (3 preceding siblings ...)
2014-11-03 21:27 ` [RFC PATCH 4/4 v2] ftracetest: Add a couple of ftrace test cases Steven Rostedt
@ 2014-11-04 5:59 ` Masami Hiramatsu
2014-11-04 9:30 ` Masami Hiramatsu
5 siblings, 0 replies; 10+ messages in thread
From: Masami Hiramatsu @ 2014-11-04 5:59 UTC (permalink / raw)
To: Steven Rostedt; +Cc: linux-kernel, Andrew Morton
(2014/11/04 6:27), Steven Rostedt wrote:
> Second attempt. I took the advice from Masami Hiramatsu and modified
> my tests. I also added some helper functions to ftracetests as well.
>
> I split the one function graph test into two. One to just test the
> filtering of the function graph and another to test with stack tracer.
This series looks good to me :)
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
for this series.
Thank you!
>
> Steven Rostedt (Red Hat) (4):
> ftracetest: Add clear_trace() helper to reset the trace file
> ftracetest: Add disable/enable_tracing() helper calls
> ftracetest: Add helper reset_tracer() function
> ftracetest: Add a couple of ftrace test cases
>
> ----
> tools/testing/selftests/ftrace/ftracetest | 3 +
> .../ftrace/test.d/ftrace/fgraph-filter-stack.tc | 94 ++++++++++++++++++++++
> .../ftrace/test.d/ftrace/fgraph-filter.tc | 49 +++++++++++
> .../ftrace/test.d/ftrace/func_profiler.tc | 76 +++++++++++++++++
> tools/testing/selftests/ftrace/test.d/functions | 16 ++++
> 5 files changed, 238 insertions(+)
>
>
>
--
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 4/4 v2] ftracetest: Add a couple of ftrace test cases
2014-11-03 21:27 ` [RFC PATCH 4/4 v2] ftracetest: Add a couple of ftrace test cases Steven Rostedt
@ 2014-11-04 8:31 ` Namhyung Kim
2014-11-04 14:03 ` Steven Rostedt
0 siblings, 1 reply; 10+ messages in thread
From: Namhyung Kim @ 2014-11-04 8:31 UTC (permalink / raw)
To: Steven Rostedt; +Cc: linux-kernel, Masami Hiramatsu, Andrew Morton
Hi Steve,
Just a few nitpicks.. Otherwise looks good to me.
On Mon, 03 Nov 2014 16:27:41 -0500, Steven Rostedt wrote:
> From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
>
> Added three test cases to get the feel of adding tests to ftracetest.
> The three cases are:
>
> function profiling test, to make sure function profiling still works
> with function tracing (was a regression)
>
> function graph filter test to make sure that function graph filtering works.
>
> function graph filter with stack tracing test to make sure that the function
> graph filter does filter and also continues to filter when another function tracer
> is running (like the stack tracer)
>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
> .../ftrace/test.d/ftrace/fgraph-filter-stack.tc | 94 ++++++++++++++++++++++
> .../ftrace/test.d/ftrace/fgraph-filter.tc | 49 +++++++++++
> .../ftrace/test.d/ftrace/func_profiler.tc | 76 +++++++++++++++++
> 3 files changed, 219 insertions(+)
> create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc
> create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc
> create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc
>
> diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc
> new file mode 100644
> index 000000000000..3d8f79176681
> --- /dev/null
> +++ b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc
> @@ -0,0 +1,94 @@
> +#!/bin/sh
> +# description: ftrace - function graph filters with stack tracer
> +
> +# Make sure that function graph filtering works, and is not
> +# affected by other tracers enabled (like stack tracer)
> +
> +if ! grep -q function_graph available_tracers; then
> + echo "no function graph tracer configured"
> + exit_unsupported
> +fi
> +
> +if [ ! -f set_ftrace_filter ]; then
> + echo "set_ftrace_filter not found? Is dynamic ftrace not set?"
> + exit_unsupported
> +fi
> +
> +do_reset() {
> + reset_tracer
> + echo 0 > /proc/sys/kernel/stack_tracer_enabled
> + enable_tracing
> + clear_trace
> + echo > set_ftrace_filter
> +}
> +
> +disable_tracing
> +clear_trace;
> +
> +# filter something, schedule is always good
> +if ! echo "schedule" > set_ftrace_filter; then
> + # test for powerpc 64
> + if ! echo ".schedule" > set_ftrace_filter; then
You did 'echo '*schedule' > set_ftrace_filter' in the last test case.
> + echo "can not enable schedule filter"
> + exit -1
> + fi
> +fi
> +
> +echo function_graph > current_tracer
> +
> +if [ ! -f stack_trace ]; then
> + echo "Stack tracer not configured"
> + do_reset
> + exit_unsupported;
> +fi
> +
> +echo "Now testing with stack tracer"
> +
> +echo 1 > /proc/sys/kernel/stack_tracer_enabled
> +
> +disable_tracing
> +clear_trace
> +enable_tracing
> +sleep 1
> +
> +count=`cat trace | grep '()' | grep -v schedule | wc -l`
> +
> +if [ $count -ne 0 ]; then
> + echo "Graph filtering not working with stack tracer?"
> + exit -1
> +fi
> +
> +count=`cat trace | grep 'schedule()' | wc -l`
> +if [ $count -eq 0 ]; then
> + echo "No schedule traces found?"
> + exit -1
> +fi
> +
> +# Make sure we did find something
> +count=`cat trace | grep 'schedule()' | wc -l`
> +if [ $count -eq 0 ]; then
> + echo "No schedule traces found?"
> + exit -1
> +fi
Do you really want to do it twice?
> +
> +echo 0 > /proc/sys/kernel/stack_tracer_enabled
> +clear_trace
> +sleep 1
> +
> +
> +count=`cat trace | grep '()' | grep -v schedule | wc -l`
> +
> +if [ $count -ne 0 ]; then
> + echo "Graph filtering not working after stack tracer disabled?"
> + exit -1
> +fi
> +
> +count=`cat trace | grep 'schedule()' | wc -l`
> +if [ $count -eq 0 ]; then
> + echo "No schedule traces found?"
> + exit -1
> +fi
> +
> +do_reset
> +
> +exit 0
[SNIP]
> --- /dev/null
> +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc
> @@ -0,0 +1,76 @@
> +#!/bin/sh
> +# description: ftrace - function profiler with function tracing
> +
> +# There was a bug after a rewrite of the ftrace infrastructure that
> +# caused the function_profiler not to be able to run with the function
> +# tracer, because the function_profiler used the function_graph tracer
> +# and it was assumed the two could not run simultaneously.
> +#
> +# There was another related bug where the solution to the first bug
> +# broke the way filtering of the function tracer worked.
> +#
> +# This test triggers those bugs on those kernels.
> +#
> +# We need function_graph and profiling to to run this test
> +if ! grep -q function_graph available_tracers; then
> + echo "no function graph tracer configured"
> + exit_unsupported;
> +fi
> +
> +if [ ! -f set_ftrace_filter ]; then
> + echo "set_ftrace_filter not found? Is dynamic ftrace not set?"
> + exit_unsupported
> +fi
> +
> +if [ ! -f function_profile_enabled ]; then
> + echo "function_profile_enabled not found, function profiling enabled?"
> + exit_unsupported
> +fi
> +
> +echo "Testing function tracer with profiler:"
> +echo "enable function tracer"
> +echo function > current_tracer
> +echo "enable profiler"
> +echo 1 > function_profile_enabled
Oh, this test is verbose.. :)
> +
> +sleep 1
> +
> +echo "Now filter on just schedule"
> +echo '*schedule' > set_ftrace_filter
Here..
> +clear_trace
> +
> +echo "Now disable function profiler"
> +echo 0 > function_profile_enabled
> +
> +sleep 1
> +
> +# make sure only schedule functions exist
> +
> +echo "testing if only schedule is being traced"
> +if grep -v -e '^#' -e 'schedule' trace; then
It seems you might want to add -q or > /dev/null. Or count the
resulting lines like other tests.
> + echo "more than schedule was found"
> + exit 1
'exit -1' for consistency?
Thanks,
Namhyung
> +fi
> +
> +echo "Make sure schedule was traced"
> +if ! grep -e 'schedule' trace > /dev/null; then
> + cat trace
> + echo "can not find schedule in trace"
> + exit 1
> +fi
> +
> +echo > set_ftrace_filter
> +clear_trace
> +
> +sleep 1
> +
> +echo "make sure something other than scheduler is being traced"
> +if ! grep -v -e '^#' -e 'schedule' trace > /dev/null; then
> + cat trace
> + echo "no other functions besides schedule was found"
> + exit 1
> +fi
> +
> +reset_tracer
> +
> +exit 0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 0/4 v2] ftracetests: Add ftrace tests to ftracetests
2014-11-03 21:27 [RFC PATCH 0/4 v2] ftracetests: Add ftrace tests to ftracetests Steven Rostedt
` (4 preceding siblings ...)
2014-11-04 5:59 ` [RFC PATCH 0/4 v2] ftracetests: Add ftrace tests to ftracetests Masami Hiramatsu
@ 2014-11-04 9:30 ` Masami Hiramatsu
2014-11-04 14:03 ` Steven Rostedt
5 siblings, 1 reply; 10+ messages in thread
From: Masami Hiramatsu @ 2014-11-04 9:30 UTC (permalink / raw)
To: Steven Rostedt; +Cc: linux-kernel, Andrew Morton
(2014/11/04 6:27), Steven Rostedt wrote:
> Second attempt. I took the advice from Masami Hiramatsu and modified
> my tests. I also added some helper functions to ftracetests as well.
>
> I split the one function graph test into two. One to just test the
> filtering of the function graph and another to test with stack tracer.
>
> Steven Rostedt (Red Hat) (4):
> ftracetest: Add clear_trace() helper to reset the trace file
> ftracetest: Add disable/enable_tracing() helper calls
> ftracetest: Add helper reset_tracer() function
BTW, I think you can fold these patches into one. No need to separate
for each helper functions.
Thank you,
--
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 4/4 v2] ftracetest: Add a couple of ftrace test cases
2014-11-04 8:31 ` Namhyung Kim
@ 2014-11-04 14:03 ` Steven Rostedt
0 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2014-11-04 14:03 UTC (permalink / raw)
To: Namhyung Kim; +Cc: linux-kernel, Masami Hiramatsu, Andrew Morton
On Tue, 04 Nov 2014 17:31:47 +0900
Namhyung Kim <namhyung@kernel.org> wrote:
> Hi Steve,
>
> Just a few nitpicks.. Otherwise looks good to me.
>
Of course. It wasn't easy taking my hacks and making them somewhat less
hacky.
>
> On Mon, 03 Nov 2014 16:27:41 -0500, Steven Rostedt wrote:
> > From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> >
> > Added three test cases to get the feel of adding tests to ftracetest.
> > The three cases are:
> >
> > function profiling test, to make sure function profiling still works
> > with function tracing (was a regression)
> >
> > function graph filter test to make sure that function graph filtering works.
> >
> > function graph filter with stack tracing test to make sure that the function
> > graph filter does filter and also continues to filter when another function tracer
> > is running (like the stack tracer)
> >
> > Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> > ---
> > .../ftrace/test.d/ftrace/fgraph-filter-stack.tc | 94 ++++++++++++++++++++++
> > .../ftrace/test.d/ftrace/fgraph-filter.tc | 49 +++++++++++
> > .../ftrace/test.d/ftrace/func_profiler.tc | 76 +++++++++++++++++
> > 3 files changed, 219 insertions(+)
> > create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc
> > create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc
> > create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc
> >
> > diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc
> > new file mode 100644
> > index 000000000000..3d8f79176681
> > --- /dev/null
> > +++ b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc
> > @@ -0,0 +1,94 @@
> > +#!/bin/sh
> > +# description: ftrace - function graph filters with stack tracer
> > +
> > +# Make sure that function graph filtering works, and is not
> > +# affected by other tracers enabled (like stack tracer)
> > +
> > +if ! grep -q function_graph available_tracers; then
> > + echo "no function graph tracer configured"
> > + exit_unsupported
> > +fi
> > +
> > +if [ ! -f set_ftrace_filter ]; then
> > + echo "set_ftrace_filter not found? Is dynamic ftrace not set?"
> > + exit_unsupported
> > +fi
> > +
> > +do_reset() {
> > + reset_tracer
> > + echo 0 > /proc/sys/kernel/stack_tracer_enabled
> > + enable_tracing
> > + clear_trace
> > + echo > set_ftrace_filter
> > +}
> > +
> > +disable_tracing
> > +clear_trace;
> > +
> > +# filter something, schedule is always good
> > +if ! echo "schedule" > set_ftrace_filter; then
> > + # test for powerpc 64
> > + if ! echo ".schedule" > set_ftrace_filter; then
>
> You did 'echo '*schedule' > set_ftrace_filter' in the last test case.
That was me being lazy. :-)
I actually like having both ways, as it adds different types of testing
to the infrastructure. When it comes to testing, having all tests do
everything the same isn't always the best thing. I've found most my bugs
by tests doing things slightly different.
>
>
> > + echo "can not enable schedule filter"
> > + exit -1
> > + fi
> > +fi
> > +
> > +echo function_graph > current_tracer
> > +
> > +if [ ! -f stack_trace ]; then
> > + echo "Stack tracer not configured"
> > + do_reset
> > + exit_unsupported;
> > +fi
> > +
> > +echo "Now testing with stack tracer"
> > +
> > +echo 1 > /proc/sys/kernel/stack_tracer_enabled
> > +
> > +disable_tracing
> > +clear_trace
> > +enable_tracing
> > +sleep 1
> > +
> > +count=`cat trace | grep '()' | grep -v schedule | wc -l`
> > +
> > +if [ $count -ne 0 ]; then
> > + echo "Graph filtering not working with stack tracer?"
> > + exit -1
> > +fi
> > +
> > +count=`cat trace | grep 'schedule()' | wc -l`
> > +if [ $count -eq 0 ]; then
> > + echo "No schedule traces found?"
> > + exit -1
> > +fi
> > +
> > +# Make sure we did find something
> > +count=`cat trace | grep 'schedule()' | wc -l`
> > +if [ $count -eq 0 ]; then
> > + echo "No schedule traces found?"
> > + exit -1
> > +fi
>
> Do you really want to do it twice?
Crap, no. Hmm, that was probably suppose to go into the other file. Let
me fix that.
>
>
> > +
> > +echo 0 > /proc/sys/kernel/stack_tracer_enabled
> > +clear_trace
> > +sleep 1
> > +
> > +
> > +count=`cat trace | grep '()' | grep -v schedule | wc -l`
> > +
> > +if [ $count -ne 0 ]; then
> > + echo "Graph filtering not working after stack tracer disabled?"
> > + exit -1
> > +fi
> > +
> > +count=`cat trace | grep 'schedule()' | wc -l`
> > +if [ $count -eq 0 ]; then
> > + echo "No schedule traces found?"
> > + exit -1
> > +fi
> > +
> > +do_reset
> > +
> > +exit 0
>
>
> [SNIP]
> > --- /dev/null
> > +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc
> > @@ -0,0 +1,76 @@
> > +#!/bin/sh
> > +# description: ftrace - function profiler with function tracing
> > +
> > +# There was a bug after a rewrite of the ftrace infrastructure that
> > +# caused the function_profiler not to be able to run with the function
> > +# tracer, because the function_profiler used the function_graph tracer
> > +# and it was assumed the two could not run simultaneously.
> > +#
> > +# There was another related bug where the solution to the first bug
> > +# broke the way filtering of the function tracer worked.
> > +#
> > +# This test triggers those bugs on those kernels.
> > +#
> > +# We need function_graph and profiling to to run this test
> > +if ! grep -q function_graph available_tracers; then
> > + echo "no function graph tracer configured"
> > + exit_unsupported;
> > +fi
> > +
> > +if [ ! -f set_ftrace_filter ]; then
> > + echo "set_ftrace_filter not found? Is dynamic ftrace not set?"
> > + exit_unsupported
> > +fi
> > +
> > +if [ ! -f function_profile_enabled ]; then
> > + echo "function_profile_enabled not found, function profiling enabled?"
> > + exit_unsupported
> > +fi
> > +
> > +echo "Testing function tracer with profiler:"
> > +echo "enable function tracer"
> > +echo function > current_tracer
> > +echo "enable profiler"
> > +echo 1 > function_profile_enabled
>
> Oh, this test is verbose.. :)
I could switch those to comments. When running the tests, these are
suppressed. Should I change them?
>
>
> > +
> > +sleep 1
> > +
> > +echo "Now filter on just schedule"
> > +echo '*schedule' > set_ftrace_filter
>
> Here..
Yep, me being lazy. But I think I'll keep it as a variant. At least
until I have better testing of filters. This is really basic. My stress
tests use trace-cmd, which isn't what we want for these tests.
>
> > +clear_trace
> > +
> > +echo "Now disable function profiler"
> > +echo 0 > function_profile_enabled
> > +
> > +sleep 1
> > +
> > +# make sure only schedule functions exist
> > +
> > +echo "testing if only schedule is being traced"
> > +if grep -v -e '^#' -e 'schedule' trace; then
>
> It seems you might want to add -q or > /dev/null. Or count the
> resulting lines like other tests.
Why?
The -v is an inverse search. It returns true if it finds anything but
'^#' and 'schedule', and false if it doesn't.
That's what we want. Why count lines? We could add -q, but again, all
output is suppressed. This came from my own test scripts, and there I
purposely left out the -q because if it failed, I wanted to see what
was there that wasn't suppose to be.
-- Steve
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 0/4 v2] ftracetests: Add ftrace tests to ftracetests
2014-11-04 9:30 ` Masami Hiramatsu
@ 2014-11-04 14:03 ` Steven Rostedt
0 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2014-11-04 14:03 UTC (permalink / raw)
To: Masami Hiramatsu; +Cc: linux-kernel, Andrew Morton
On Tue, 04 Nov 2014 18:30:37 +0900
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> wrote:
> (2014/11/04 6:27), Steven Rostedt wrote:
> > Second attempt. I took the advice from Masami Hiramatsu and modified
> > my tests. I also added some helper functions to ftracetests as well.
> >
> > I split the one function graph test into two. One to just test the
> > filtering of the function graph and another to test with stack tracer.
> >
> > Steven Rostedt (Red Hat) (4):
> > ftracetest: Add clear_trace() helper to reset the trace file
> > ftracetest: Add disable/enable_tracing() helper calls
> > ftracetest: Add helper reset_tracer() function
>
> BTW, I think you can fold these patches into one. No need to separate
> for each helper functions.
Yeah, I probably should. I did those each at different times, and just
put them in separately.
-- Steve
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-11-04 14:04 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-03 21:27 [RFC PATCH 0/4 v2] ftracetests: Add ftrace tests to ftracetests Steven Rostedt
2014-11-03 21:27 ` [RFC PATCH 1/4 v2] ftracetest: Add clear_trace() helper to reset the trace file Steven Rostedt
2014-11-03 21:27 ` [RFC PATCH 2/4 v2] ftracetest: Add disable/enable_tracing() helper calls Steven Rostedt
2014-11-03 21:27 ` [RFC PATCH 3/4 v2] ftracetest: Add helper reset_tracer() function Steven Rostedt
2014-11-03 21:27 ` [RFC PATCH 4/4 v2] ftracetest: Add a couple of ftrace test cases Steven Rostedt
2014-11-04 8:31 ` Namhyung Kim
2014-11-04 14:03 ` Steven Rostedt
2014-11-04 5:59 ` [RFC PATCH 0/4 v2] ftracetests: Add ftrace tests to ftracetests Masami Hiramatsu
2014-11-04 9:30 ` Masami Hiramatsu
2014-11-04 14:03 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox