Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1624517
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 4/4] selftests: ftrace: Add a testcase for function PID filter |
| Date | 2017-04-17 04:50 +0200 |
| Message-ID | <tx4TL-3l1-5@gated-at.bofh.it> (permalink) |
| References | <tx4TL-3l1-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Like event pid filtering test, add function pid filtering test with the
new "function-fork" option. It also tests it on an instance directory
so that it can verify the bug related pid filtering on instances.
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
.../ftrace/test.d/ftrace/func-filter-pid.tc | 98 ++++++++++++++++++++++
1 file changed, 98 insertions(+)
create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc
new file mode 100644
index 000000000000..cd552f44c3b4
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc
@@ -0,0 +1,98 @@
+#!/bin/sh
+# description: ftrace - function pid filters
+
+# Make sure that function pid matching filter works.
+# Also test it on an instance directory
+
+if ! grep -q function available_tracers; then
+ echo "no function tracer configured"
+ exit_unsupported
+fi
+
+if [ ! -f set_ftrace_pid ]; then
+ echo "set_ftrace_pid not found? Is function tracer not set?"
+ exit_unsupported
+fi
+
+if [ ! -f set_ftrace_filter ]; then
+ echo "set_ftrace_filter not found? Is function tracer not set?"
+ exit_unsupported
+fi
+
+read PID _ < /proc/self/stat
+
+# default value of function-fork option
+orig_value=`grep function-fork trace_options`
+
+do_reset() {
+ reset_tracer
+ clear_trace
+ enable_tracing
+ echo > set_ftrace_filter
+ echo > set_ftrace_pid
+
+ echo $orig_value > trace_options
+}
+
+fail() { # msg
+ do_reset
+ echo $1
+ exit $FAIL
+}
+
+yield() {
+ ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
+}
+
+do_test() {
+ disable_tracing
+
+ echo do_execve* > set_ftrace_filter
+ echo *do_fork >> set_ftrace_filter
+
+ echo $PID > set_ftrace_pid
+ echo function > current_tracer
+
+ # don't allow children to be traced
+ echo nofunction-fork > trace_options
+
+ enable_tracing
+ yield
+
+ count_pid=`cat trace | grep -v ^# | grep $PID | wc -l`
+ count_other=`cat trace | grep -v ^# | grep -v $PID | wc -l`
+
+ # count_other should be 0
+ if [ $count_pid -eq 0 -o $count_other -ne 0 ]; then
+ fail "PID filtering not working?"
+ fi
+
+ disable_tracing
+ clear_trace
+
+ # allow children to be traced
+ echo function-fork > trace_options
+
+ enable_tracing
+ yield
+
+ count_pid=`cat trace | grep -v ^# | grep $PID | wc -l`
+ count_other=`cat trace | grep -v ^# | grep -v $PID | wc -l`
+
+ # count_other should NOT be 0
+ if [ $count_pid -eq 0 -o $count_other -eq 0 ]; then
+ fail "PID filtering not following fork?"
+ fi
+}
+
+do_test
+
+mkdir instances/foo
+cd instances/foo
+do_test
+cd ../../
+rmdir instances/foo
+
+do_reset
+
+exit 0
--
2.12.2
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/4] ftrace: Add 'function-fork' trace option (v2) Namhyung Kim <namhyung@kernel.org> - 2017-04-17 04:50 +0200
[PATCH 2/4] ftrace: Add 'function-fork' trace option Namhyung Kim <namhyung@kernel.org> - 2017-04-17 04:50 +0200
[PATCH 1/4] ftrace: Fix function pid filter on instances Namhyung Kim <namhyung@kernel.org> - 2017-04-17 04:50 +0200
Re: [PATCH 1/4] ftrace: Fix function pid filter on instances Masami Hiramatsu <mhiramat@kernel.org> - 2017-04-17 14:00 +0200
Re: [PATCH 1/4] ftrace: Fix function pid filter on instances Namhyung Kim <namhyung@kernel.org> - 2017-04-17 15:10 +0200
[PATCH 4/4] selftests: ftrace: Add a testcase for function PID filter Namhyung Kim <namhyung@kernel.org> - 2017-04-17 04:50 +0200
Re: [PATCH 0/4] ftrace: Add 'function-fork' trace option (v2) Steven Rostedt <rostedt@goodmis.org> - 2017-04-17 21:20 +0200
Re: [PATCH 0/4] ftrace: Add 'function-fork' trace option (v2) Namhyung Kim <namhyung@kernel.org> - 2017-04-19 02:30 +0200
Re: [PATCH 0/4] ftrace: Add 'function-fork' trace option (v2) Steven Rostedt <rostedt@goodmis.org> - 2017-04-19 03:30 +0200
csiph-web