Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1523284
| From | Masami Hiramatsu <mhiramat@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH -tip v3 2/9] selftests: ftrace: Initialize ftrace before each test |
| Date | 2016-11-16 09:20 +0100 |
| Message-ID | <sE3BM-jF-19@gated-at.bofh.it> (permalink) |
| References | <sE3BL-jF-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Reset ftrace to initial state before running each test.
This fixes some test cases to enable tracing before starting
trace test. This can avoid false-positive failure when
previous testcase fails while disabling tracing.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
---
Changes in v3:
- Fix to avoid initializing error by checking all optional features
---
tools/testing/selftests/ftrace/ftracetest | 2 +-
tools/testing/selftests/ftrace/test.d/functions | 28 +++++++++++++++++++++++
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index 4c6a0bf..a03d366 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -228,7 +228,7 @@ trap 'SIG_RESULT=$XFAIL' $SIG_XFAIL
__run_test() { # testfile
# setup PID and PPID, $$ is not updated.
- (cd $TRACING_DIR; read PID _ < /proc/self/stat ; set -e; set -x; . $1)
+ (cd $TRACING_DIR; read PID _ < /proc/self/stat; set -e; set -x; initialize_ftrace; . $1)
[ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID
}
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
index c37262f..91de1a8 100644
--- a/tools/testing/selftests/ftrace/test.d/functions
+++ b/tools/testing/selftests/ftrace/test.d/functions
@@ -23,3 +23,31 @@ reset_trigger() { # reset all current setting triggers
done
}
+reset_events_filter() { # reset all current setting filters
+ grep -v ^none events/*/*/filter |
+ while read line; do
+ echo 0 > `echo $line | cut -f1 -d:`
+ done
+}
+
+disable_events() {
+ echo 0 > events/enable
+}
+
+initialize_ftrace() { # Reset ftrace to initial-state
+# As the initial state, ftrace will be set to nop tracer,
+# no events, no triggers, no filters, no function filters,
+# no probes, and tracing on.
+ disable_tracing
+ reset_tracer
+ reset_trigger
+ reset_events_filter
+ disable_events
+ echo > set_event_pid # event tracer is always on
+ [ -f set_ftrace_filter ] && echo | tee set_ftrace_*
+ [ -f set_graph_function ] && echo | tee set_graph_*
+ [ -f stack_trace_filter ] && echo > stack_trace_filter
+ [ -f kprobe_events ] && echo > kprobe_events
+ [ -f uprobe_events ] && echo > uprobe_events
+ enable_tracing
+}
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH -tip v3 0/9] ftrace: selftests: Add full glob matching and update ftracetest Masami Hiramatsu <mhiramat@kernel.org> - 2016-11-16 09:20 +0100 [PATCH -tip v3 9/9] selftests: ftrace: Add a testcase for types of kprobe event Masami Hiramatsu <mhiramat@kernel.org> - 2016-11-16 09:20 +0100 [PATCH -tip v3 4/9] selftests: ftrace: Check whether snapshot trigger is supported correctly Masami Hiramatsu <mhiramat@kernel.org> - 2016-11-16 09:20 +0100 [PATCH -tip v3 2/9] selftests: ftrace: Initialize ftrace before each test Masami Hiramatsu <mhiramat@kernel.org> - 2016-11-16 09:20 +0100 [PATCH -tip v3 5/9] selftests: ftrace: Fix trigger-mod to run without syscall trace Masami Hiramatsu <mhiramat@kernel.org> - 2016-11-16 09:20 +0100 [PATCH -tip v3 8/9] selftests: ftrace: Add a testcase for function filter glob match Masami Hiramatsu <mhiramat@kernel.org> - 2016-11-16 09:20 +0100 [PATCH -tip v3 7/9] selftests: ftrace: Introduce TMPDIR for temporary files Masami Hiramatsu <mhiramat@kernel.org> - 2016-11-16 09:20 +0100
csiph-web