selftests/ftrace: Improve ftracetest with coverage check
Masami Hiramatsu
maintainerv2 cover selftests/ftrace: Improve ftracetest with coverage check
Hello,
Here is the 2nd version of the series for improving ftracetest testcase using gcov/lcov. From previous version, I've added 6 new testcases for some tracers and ftrace basic features.
With this series, ftracetest coverage under kernel/trace/ is improved as below. (Note that this kernel enables ftrace startup tests)
Without new testcases
Lines: 10563 17268 61.2 %
Functions: 1114 1785 62.4 %
With new testcases
Lines: 11703 17268 67.8 %
Functions: 1262 1785 70.7 %
Of course we don't need to make it 100%, because ftracetest is a function/specification test, and there are functions and lines which never be called (like critical error detection :) ). Also, ftrace has some amount of code for perf and bpf subsystem which should be tested by perf/bpf tests.
However, GCOV(LCOV) gives us a good insight into which functions are covered or not covered by the test cases. We can find which functions are not tested yet from the coverage information.
This series has some ftracetest framework improvements too, which are for debugging ftracetest itself.
Tracing/Gcov-kernel:
- Add CONFIG_GCOV_PROFILE_FRACE, which enables gcov profiling only on tracing subsystem (under kernel/trace/). This may not needed for everyone (like a debugging feature).
So it can be dropped anyway.
Ftracetest framework improvements:
- Add --stop-fail for detecting failure soon.
- Add --console for interactively debugging a testcase by shell.
- Add testcase-number prefix to logfile for finding log easier.
- Improve general init function
- Call general init function after all testcases.
- Remove init/cleanup code from all testcase (since general init function will fixed it up)
Testcase fixes:
- Fix to check $comm availability.
- Make checkbashisms clean
Testcase improvements:
- Use loopback address instead of localhost
- Improve kprobe on module testcase to load/unload module
- Improve kprobe testcase to check log data
- Improve kretprobe testcase to check log data
- Test kprobe-event argument with various bitsize
- Check set_event_pid result
Adding testcases:
- Add kprobe event with $comm argument testcase
- Add kprobe profile testcase
- Add kprobe-event with symbol argument testcase
- Add nop tracer testcase
- Add trace_printk sample module testcase
- Add ringbuffer size changing testcase
- Add function profiling statistics testcase
- Add max stack tracer testcase
- Add function filter on module testcase
- Add trace_pipe testcase
- Add stacktrace ftrace filter command testcase
- Add wakeup tracer testcase
- Add wakeup_rt tracer testcase
- Add blktrace testcase
- Add ftrace cpumask testcase
- Add ftrace output format testcase
TBD:
Following testcase improvements are remaining.
- Checking of various supported types (like u8, u64 etc.) testcases
Thank you,
---
Masami Hiramatsu (32):
tracing: Allow gcov profiling on only ftrace subsystem selftests/ftrace: Add --stop-fail hidden option for debug selftests/ftrace: Add --console hidden option selftests/ftrace: Add case number prefix to logfile selftests/ftrace: More initialize features in initialize_ftrace selftests/ftrace: Add SPDX License Identifier to template selftests/ftrace: Cleanup ftrace after running test selftests/ftrace: Remove unneeded per-test init/cleanup ftrace selftests/ftrace: Fix to test kprobe $comm arg only if available selftests/ftrace: Fix checkbashisms errors
selftests/ftrace: Use loopback address instead of localhost selftests/ftrace: Improve kprobe on module testcase to load/unload module selftests/ftrace: Improve kprobe testcase to check log data selftests/ftrace: Improve kretprobe testcase to check log data selftests/ftrace: Test kprobe-event argument with various bitsize selftests/ftrace: Check set_event_pid result selftests/ftrace: Add kprobe event with $comm argument testcase selftests/ftrace: Add kprobe profile testcase selftests/ftrace: Add a testcase for nop tracer selftests/ftrace: Add kprobe-event with symbol argument test selftests/ftrace: Add trace_printk sample module test selftests/ftrace: Add ringbuffer size changing testcase selftests/ftrace: Add function profiling stat testcase selftests/ftrace: Add max stack tracer testcase selftests/ftrace: Add function filter on module testcase selftests/ftrace: Add trace_pipe testcase
selftests/ftrace: Add stacktrace ftrace filter command testcase selftests/ftrace: Add wakeup tracer testcase selftests/ftrace: Add wakeup_rt tracer testcase selftests/ftrace: Add ftrace cpumask testcase selftests/ftrace: Add output format testcase selftests/ftrace: Add blktrace testcase
kernel/trace/Kconfig | 13 +++ kernel/trace/Makefile | 5 + tools/testing/selftests/ftrace/config | 7 ++ tools/testing/selftests/ftrace/ftracetest | 32 ++++++- .../ftrace/test.d/00basic/print_format.tc | 51 +++++++++++ .../ftrace/test.d/00basic/ringbuffer_size.tc | 21 +++++ .../selftests/ftrace/test.d/00basic/trace_pipe.tc | 15 +++ .../selftests/ftrace/test.d/event/event-enable.tc | 8 -- .../selftests/ftrace/test.d/event/event-pid.tc | 6 + .../ftrace/test.d/event/subsystem-enable.tc | 8 -- .../ftrace/test.d/event/toplevel-enable.tc | 8 -- .../selftests/ftrace/test.d/event/trace_printk.tc | 27 ++++++ .../ftrace/test.d/ftrace/fgraph-filter-stack.tc | 4 - .../ftrace/test.d/ftrace/fgraph-filter.tc | 9 -- .../ftrace/test.d/ftrace/func-filter-pid.tc | 8 -- .../ftrace/test.d/ftrace/func-filter-stacktrace.tc | 12 +++ .../selftests/ftrace/test.d/ftrace/func_cpumask.tc | 34 +++++++ .../ftrace/test.d/ftrace/func_event_triggers.tc | 3 - .../ftrace/test.d/ftrace/func_mod_trace.tc | 24 +++++ .../ftrace/test.d/ftrace/func_profile_stat.tc | 23 +++++ .../ftrace/test.d/ftrace/func_profiler.tc | 4 - .../ftrace/test.d/ftrace/func_set_ftrace_file.tc | 13 --- .../ftrace/test.d/ftrace/func_stack_tracer.tc | 39 +++++++++ .../test.d/ftrace/func_traceonoff_triggers.tc | 11 -- tools/testing/selftests/ftrace/test.d/functions | 5 + .../ftrace/test.d/kprobe/add_and_remove.tc | 3 - .../selftests/ftrace/test.d/kprobe/busy_check.tc | 3 - .../selftests/ftrace/test.d/kprobe/kprobe_args.tc | 8 +- .../ftrace/test.d/kprobe/kprobe_args_comm.tc | 17 ++++ .../ftrace/test.d/kprobe/kprobe_args_string.tc | 5 - .../ftrace/test.d/kprobe/kprobe_args_symbol.tc | 39 +++++++++ .../ftrace/test.d/kprobe/kprobe_args_syntax.tc | 8 +- .../ftrace/test.d/kprobe/kprobe_args_type.tc | 52 +++++++---- .../ftrace/test.d/kprobe/kprobe_eventname.tc | 5 - .../ftrace/test.d/kprobe/kprobe_ftrace.tc | 9 -- .../ftrace/test.d/kprobe/kprobe_module.tc | 36 +++++++- .../ftrace/test.d/kprobe/kretprobe_args.tc | 9 +- .../ftrace/test.d/kprobe/kretprobe_maxactive.tc | 4 - .../ftrace/test.d/kprobe/multiple_kprobes.tc | 5 - .../selftests/ftrace/test.d/kprobe/probepoint.tc | 4 - .../selftests/ftrace/test.d/kprobe/profile.tc | 15 +++ tools/testing/selftests/ftrace/test.d/template | 1 .../testing/selftests/ftrace/test.d/tracer/blk.tc | 91 ++++++++++++++++++++ .../testing/selftests/ftrace/test.d/tracer/nop.tc | 22 +++++ .../selftests/ftrace/test.d/tracer/wakeup.tc | 25 +++++ .../selftests/ftrace/test.d/tracer/wakeup_rt.tc | 25 +++++ .../inter-event/trigger-extended-error-support.tc | 12 --- .../inter-event/trigger-field-variable-support.tc | 15 --- .../trigger-inter-event-combined-hist.tc | 15 --- .../inter-event/trigger-multi-actions-accept.tc | 14 --- .../inter-event/trigger-onmatch-action-hist.tc | 15 --- .../trigger-onmatch-onmax-action-hist.tc | 15 --- .../inter-event/trigger-onmax-action-hist.tc | 15 --- .../trigger-synthetic-event-createremove.tc | 12 --- .../ftrace/test.d/trigger/trigger-eventonoff.tc | 12 --- .../ftrace/test.d/trigger/trigger-filter.tc | 14 --- .../ftrace/test.d/trigger/trigger-hist-mod.tc | 12 --- .../ftrace/test.d/trigger/trigger-hist.tc | 12 --- .../ftrace/test.d/trigger/trigger-multihist.tc | 16 ---- .../ftrace/test.d/trigger/trigger-snapshot.tc | 12 --- .../ftrace/test.d/trigger/trigger-stacktrace.tc | 12 --- .../test.d/trigger/trigger-trace-marker-hist.tc | 11 -- .../trigger/trigger-trace-marker-snapshot.tc | 16 ---- .../trigger-trace-marker-synthetic-kernel.tc | 12 --- .../trigger/trigger-trace-marker-synthetic.tc | 12 --- .../ftrace/test.d/trigger/trigger-traceonoff.tc | 12 --- 66 files changed, 630 insertions(+), 412 deletions(-) create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/print_format.tc create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tc create mode 100644 tools/testing/selftests/ftrace/test.d/event/trace_printk.tc create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_mod_trace.tc create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_profile_stat.tc create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_comm.tc create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_symbol.tc create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/profile.tc create mode 100644 tools/testing/selftests/ftrace/test.d/tracer/blk.tc create mode 100644 tools/testing/selftests/ftrace/test.d/tracer/nop.tc create mode 100644 tools/testing/selftests/ftrace/test.d/tracer/wakeup.tc create mode 100644 tools/testing/selftests/ftrace/test.d/tracer/wakeup_rt.tc
--
Masami Hiramatsu (Linaro)
Masami Hiramatsu
maintainerPATCH v2 1/32 tracing: Allow gcov profiling on only ftrace subsystem
Add GCOV_PROFILE_FTRACE to allow gcov profiling
on only files in ftrace subsystem. This kconfig
flag will be used for checking kselftest/ftrace
coverage.
--- kernel/trace/Kconfig | 13 +++++++++++++ kernel/trace/Makefile | 5 +++++ 2 files changed, 18 insertions(+)
kernel/trace/Kconfig +13 -0
@@ -774,6 +774,19 @@ config TRACING_EVENTS_GPIO help Enable tracing events for gpio subsystem +config GCOV_PROFILE_FTRACE + bool "Enable GCOV profiling on ftrace subsystem" + depends on GCOV_KERNEL + help + Enable GCOV profiling on ftrace subsystem for checking + which functions/lines are tested. + + If unsure, say N. + + Note that on a kernel compiled with this flags, ftrace will be + significantly run slower. So do not enable it for production + kernel. + endif # FTRACE endif # TRACING_SUPPORT
kernel/trace/Makefile +5 -0
@@ -23,6 +23,11 @@ ifdef CONFIG_TRACING_BRANCHES KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING endif +# for GCOV coverage profiling +ifdef CONFIG_GCOV_PROFILE_FTRACE +GCOV_PROFILE := y +endif + CFLAGS_trace_benchmark.o := -I$(src) CFLAGS_trace_events_filter.o := -I$(src)
Steven Rostedt
maintainerRe: [PATCH v2 01/32] tracing: Allow gcov profiling on only ftrace subsystem
Quoted 3 lines · On Fri, 17 Aug 2018 01:29:39 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Add
GCOV_PROFILE_FTRACEto allow gcov profiling
on only files in ftrace subsystem. This kconfig
flag will be used for checking kselftest/ftrace
Note, I haven't heard of "kconfig flag" as the terminology. Usually, we just say "config" or "config option".
Quoted 18 lines
coverage.
Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- kernel/trace/Kconfig | 13 +++++++++++++ kernel/trace/Makefile | 5 +++++ 2 files changed, 18 insertions(+)kernel/trace/Kconfig +2
-0@@ -774,6 +774,19 @@ config TRACING_EVENTS_GPIO help Enable tracing events for gpio subsystem +config GCOV_PROFILE_FTRACE + bool "Enable GCOV profiling on ftrace subsystem"
kernel/trace/Kconfig config TRACING_EVENTS_GPIO · line 788
Quoted 10 lines
kernel/trace/Kconfig +10
-0+ depends on GCOV_KERNEL + help + Enable GCOV profiling on ftrace subsystem for checking + which functions/lines are tested. + + If unsure, say N. + + Note that on a kernel compiled with this flags, ftrace will be + significantly run slower. So do not enable it for production + kernel.
I would rewrite the above as:
Note that on a kernel compiled with this config, ftrace will run significantly slower.
I think we can leave out the production sentence. It should be obvious from the "significantly slower" part.
Other than that, it looks fine to me.
-- Steve
Quoted 20 lines
kernel/trace/Kconfig +1
-0+ endif # FTRACE endif # TRACING_SUPPORTkernel/trace/Makefile +5
-0@@ -23,6 +23,11 @@ ifdef CONFIG_TRACING_BRANCHES KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING endif +# for GCOV coverage profiling +ifdef CONFIG_GCOV_PROFILE_FTRACE +GCOV_PROFILE := y +endif + CFLAGS_trace_benchmark.o := -I$(src) CFLAGS_trace_events_filter.o := -I$(src)
Steven Rostedt
maintainerRe: [PATCH v2 01/32] tracing: Allow gcov profiling on only ftrace subsystem
Quoted 1 line · On Mon, 20 Aug 2018 11:32:13 -0400 Steven Rostedt <rostedt at goodmis.org>…
Other than that, it looks fine to me.
This patch also seems out of place for the series. Want to resend it separately, and I'll apply it?
Thanks!
-- Steve
Masami Hiramatsu
maintainerRe: [PATCH v2 01/32] tracing: Allow gcov profiling on only ftrace subsystem
Hi Steve,
Quoted 6 lines · On Mon, 20 Aug 2018 11:33:49 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 1 line · On Mon, 20 Aug 2018 11:32:13 -0400 Steven Rostedt <[email protected]> wrote:
Other than that, it looks fine to me.
This patch also seems out of place for the series.
Yes, this one is the patch for ftrace, not ftracetest.
Quoted 2 lines
Want to resend it
separately, and I'll apply it?
OK, I'll fix "config" and resend it :)
Thank you,
Signature · 1 line
Masami Hiramatsu <mhiramat at kernel.org>
Masami Hiramatsu
maintainerPATCH 1/1 tracing: Allow gcov profiling on only ftrace subsystem
In reply to Steven RostedtAdd GCOV_PROFILE_FTRACE to allow gcov profiling
on only files in ftrace subsystem. This config
option will be used for checking kselftest/ftrace
coverage.
---
Changes in v2.1:
- Fix description according to Steve's comment.
--- kernel/trace/Kconfig | 12 ++++++++++++ kernel/trace/Makefile | 5 +++++ 2 files changed, 17 insertions(+)
kernel/trace/Kconfig +12 -0
@@ -774,6 +774,18 @@ config TRACING_EVENTS_GPIO help Enable tracing events for gpio subsystem +config GCOV_PROFILE_FTRACE + bool "Enable GCOV profiling on ftrace subsystem" + depends on GCOV_KERNEL + help + Enable GCOV profiling on ftrace subsystem for checking + which functions/lines are tested. + + If unsure, say N. + + Note that on a kernel compiled with this config, ftrace will + run significantly slower. + endif # FTRACE endif # TRACING_SUPPORT
kernel/trace/Makefile +5 -0
@@ -23,6 +23,11 @@ ifdef CONFIG_TRACING_BRANCHES KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING endif +# for GCOV coverage profiling +ifdef CONFIG_GCOV_PROFILE_FTRACE +GCOV_PROFILE := y +endif + CFLAGS_trace_benchmark.o := -I$(src) CFLAGS_trace_events_filter.o := -I$(src)
Re: [PATCH v2.1] tracing: Allow gcov profiling on only ftrace subsystem
Quoted 7 lines · On Tue, 21 Aug 2018 16:27:58 +0900 Masami Hiramatsu <[email protected]> wrote:
Add
GCOV_PROFILE_FTRACEto allow gcov profiling
on only files in ftrace subsystem. This config
option will be used for checking kselftest/ftrace
coverage.Signed-off-by Masami Hiramatsu <[email protected]>---
Applied. Thanks Masami!
-- Steve
Masami Hiramatsu
maintainerPATCH v2 2/32 selftests/ftrace: Add --stop-fail hidden option for debug
In reply to Masami HiramatsuAdd --stop-fail option for debugging the ftracetest.
--- tools/testing/selftests/ftrace/ftracetest | 13 +++++++++++++ 1 file changed, 13 insertions(+)
tools/testing/selftests/ftrace/ftracetest +13 -0
@@ -69,6 +69,10 @@ parse_opts() { # opts DEBUG=1 shift 1 ;; + --stop-fail) + STOP_FAILURE=1 + shift 1 + ;; --fail-unsupported) UNSUPPORTED_RESULT=1 shift 1
@@ -117,6 +121,7 @@ KEEP_LOG=0 DEBUG=0 VERBOSE=0 UNSUPPORTED_RESULT=0 +STOP_FAILURE=0 # Parse command-line options parse_opts $*
@@ -304,6 +309,10 @@ run_test() { # testfile # Main loop for t in $TEST_CASES; do run_test $t + if [ $STOP_FAILURE -ne 0 -a $TOTAL_RESULT -ne 0 ]; then + echo "A failure detected. Stop test." + exit 1 + fi done # Test on instance loop
@@ -315,6 +324,10 @@ for t in $TEST_CASES; do run_test $t rmdir $TRACING_DIR TRACING_DIR=$SAVED_TRACING_DIR + if [ $STOP_FAILURE -ne 0 -a $TOTAL_RESULT -ne 0 ]; then + echo "A failure detected. Stop test." + exit 1 + fi done prlog ""
Re: [PATCH v2 02/32] selftests/ftrace: Add --stop-fail hidden option for debug
Quoted 2 lines · On Fri, 17 Aug 2018 01:30:08 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Add --stop-fail option for debugging the ftracetest.
-- Steve
Quoted 10 lines
Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- tools/testing/selftests/ftrace/ftracetest | 13 +++++++++++++ 1 file changed, 13 insertions(+)tools/testing/selftests/ftrace/ftracetest +0
-0@@ -69,6 +69,10 @@ parse_opts() { # opts
Masami Hiramatsu
maintainerPATCH v2 3/32 selftests/ftrace: Add --console hidden option
In reply to Masami HiramatsuAdd --console hidden option for debug test cases.
This option allows to put "sh" or something else
when the test case hits a bug.
--- tools/testing/selftests/ftrace/ftracetest | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
tools/testing/selftests/ftrace/ftracetest +13 -1
@@ -60,11 +60,21 @@ parse_opts() { # opts shift 1 ;; --verbose|-v|-vv|-vvv) + if [ $VERBOSE -eq -1 ]; then + usage "--console can not use with --verbose" + fi VERBOSE=$((VERBOSE + 1)) [ $1 = '-vv' ] && VERBOSE=$((VERBOSE + 1)) [ $1 = '-vvv' ] && VERBOSE=$((VERBOSE + 2)) shift 1 ;; + --console) + if [ $VERBOSE -ne 0 ]; then + usage "--console can not use with --verbose" + fi + VERBOSE=-1 + shift 1 + ;; --debug|-d) DEBUG=1 shift 1
@@ -283,7 +293,9 @@ run_test() { # testfile testcase $1 echo "execute$INSTANCE: "$1 > $testlog SIG_RESULT=0 - if [ -z "$LOG_FILE" ]; then + if [ $VERBOSE -eq -1 ]; then + __run_test $1 + elif [ -z "$LOG_FILE" ]; then __run_test $1 2>&1 elif [ $VERBOSE -ge 3 ]; then __run_test $1 | tee -a $testlog 2>&1
Steven Rostedt
maintainerRe: [PATCH v2 03/32] selftests/ftrace: Add --console hidden option
Quoted 3 lines · On Fri, 17 Aug 2018 01:30:36 +0900 Masami Hiramatsu <[email protected]> wrote:
Add --console hidden option for debug test cases.
This option allows to put "sh" or something else
when the test case hits a bug.
Can you add more information to why and how this would be used.
-- Steve
Masami Hiramatsu
maintainerRe: [PATCH v2 03/32] selftests/ftrace: Add --console hidden option
Quoted 8 lines · On Fri, 24 Aug 2018 16:37:37 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 3 lines · On Fri, 17 Aug 2018 01:30:36 +0900 Masami Hiramatsu <[email protected]> wrote:
Add --console hidden option for debug test cases.
This option allows to put "sh" or something else
when the test case hits a bug.Can you add more information to why and how this would be used.
For example, if you find a testcase which doesn't pass, you can insert sh for interactive debug as below
#!/bin/sh
# description: sample test case
good-command
suspicious-wrong-command
sh # <- add this for interactive debug
Thank you,
Signature · 1 line
Masami Hiramatsu <mhiramat at kernel.org>
Steven Rostedt
maintainerRe: [PATCH v2 03/32] selftests/ftrace: Add --console hidden option
Quoted 15 lines · On Sat, 25 Aug 2018 10:35:13 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Quoted 8 lines · On Fri, 24 Aug 2018 16:37:37 -0400 Steven Rostedt <rostedt at goodmis.org>…
Quoted 3 lines · On Fri, 17 Aug 2018 01:30:36 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Add --console hidden option for debug test cases.
This option allows to put "sh" or something else
when the test case hits a bug.Can you add more information to why and how this would be used.
For example, if you find a testcase which doesn't pass, you can insert sh for interactive debug as below
Quoted 7 lines
#!/bin/sh
# description: sample test casegood-command
suspicious-wrong-command
sh # <- add this for interactive debug
Ah! OK. But this needs to be explained a little better in the change log as well as in the comments for it.
Thanks!
-- Steve
Masami Hiramatsu
maintainerRe: [PATCH v2 03/32] selftests/ftrace: Add --console hidden option
Quoted 21 lines · On Fri, 24 Aug 2018 21:42:04 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 18 lines · On Sat, 25 Aug 2018 10:35:13 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 8 lines · On Fri, 24 Aug 2018 16:37:37 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 3 lines · On Fri, 17 Aug 2018 01:30:36 +0900 Masami Hiramatsu <[email protected]> wrote:
Add --console hidden option for debug test cases.
This option allows to put "sh" or something else
when the test case hits a bug.Can you add more information to why and how this would be used.
For example, if you find a testcase which doesn't pass, you can insert sh for interactive debug as below
#!/bin/sh
# description: sample test case
Quoted 7 lines
Quoted 4 lines
good-command
suspicious-wrong-command
sh # <- add this for interactive debugAh! OK. But this needs to be explained a little better in the change log as well as in the comments for it.
Ah sorry I missed "I will add following example"... yes, of course I add this to description.
Thank you,
Quoted 4 lines
Thanks!
-- Steve
Signature · 1 line
Masami Hiramatsu <mhiramat at kernel.org>
Masami Hiramatsu
maintainerPATCH v2 4/32 selftests/ftrace: Add case number prefix to logfile
In reply to Masami HiramatsuAdd a case number prefix to each logfile. This makes it easier to find which logfile is corresponding to which failure.
--- tools/testing/selftests/ftrace/ftracetest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/ftrace/ftracetest +2 -2
@@ -284,13 +284,13 @@ __run_test() { # testfile # Run one test case run_test() { # testfile local testname=`basename $1` + testcase $1 if [ ! -z "$LOG_FILE" ] ; then - local testlog=`mktemp $LOG_DIR/${testname}-log.XXXXXX` + local testlog=`mktemp $LOG_DIR/${CASENO}-${testname}-log.XXXXXX` else local testlog=/proc/self/fd/1 fi export TMPDIR=`mktemp -d /tmp/ftracetest-dir.XXXXXX` - testcase $1 echo "execute$INSTANCE: "$1 > $testlog SIG_RESULT=0 if [ $VERBOSE -eq -1 ]; then
Re: [PATCH v2 04/32] selftests/ftrace: Add case number prefix to logfile
Quoted 5 lines · On Fri, 17 Aug 2018 01:31:05 +0900 Masami Hiramatsu <[email protected]> wrote:
Add a case number prefix to each logfile. This makes it easier to find which logfile is corresponding to which failure.
Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>
-- Steve
Quoted 24 lines
--- tools/testing/selftests/ftrace/ftracetest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/testing/selftests/ftrace/ftracetest +2
-2@@ -284,13 +284,13 @@ __run_test() { # testfile # Run one test case run_test() { # testfile local testname=`basename $1` + testcase $1 if [ ! -z "$LOG_FILE" ] ; then - local testlog=`mktemp $LOG_DIR/${testname}-log.XXXXXX` + local testlog=`mktemp $LOG_DIR/${CASENO}-${testname}-log.XXXXXX` else local testlog=/proc/self/fd/1 fi export TMPDIR=`mktemp -d /tmp/ftracetest-dir.XXXXXX` - testcase $1 echo "execute$INSTANCE: "$1 > $testlog SIG_RESULT=0 if [ $VERBOSE -eq -1 ]; then
Masami Hiramatsu
maintainerPATCH v2 5/32 selftests/ftrace: More initialize features in initialize_ftrace
In reply to Masami HiramatsuClear pid filter, synthetic_events, snapshots, ftrace filter, and trace log in initialize_ftrace(), since those are used in test cases.
---
Changes in v2:
- Add reset_ftrace_filter
--- tools/testing/selftests/ftrace/test.d/functions | 5 +++++ 1 file changed, 5 insertions(+)
tools/testing/selftests/ftrace/test.d/functions +5 -0
@@ -89,12 +89,17 @@ initialize_ftrace() { # Reset ftrace to initial-state reset_tracer reset_trigger reset_events_filter + reset_ftrace_filter disable_events echo > set_event_pid # event tracer is always on + echo > set_ftrace_pid [ -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 + [ -f synthetic_events ] && echo > synthetic_events + [ -f snapshot ] && echo 0 > snapshot + clear_trace enable_tracing }
Re: [PATCH v2 05/32] selftests/ftrace: More initialize features in initialize_ftrace
Quoted 5 lines · On Fri, 17 Aug 2018 01:31:33 +0900 Masami Hiramatsu <[email protected]> wrote:
Clear pid filter,
synthetic_events, snapshots, ftrace filter, and trace log ininitialize_ftrace(), since those are used in test cases.Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>
-- Steve
Quoted 29 lines
---
Changes in v2:
- Addreset_ftrace_filter--- tools/testing/selftests/ftrace/test.d/functions | 5 +++++ 1 file changed, 5 insertions(+)tools/testing/selftests/ftrace/test.d/functions +5
-0@@ -89,12 +89,17 @@ initialize_ftrace() { # Reset ftrace to initial-state reset_tracer reset_trigger reset_events_filter + reset_ftrace_filter disable_events echo > set_event_pid # event tracer is always on + echo > set_ftrace_pid [ -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 + [ -f synthetic_events ] && echo > synthetic_events + [ -f snapshot ] && echo 0 > snapshot + clear_trace enable_tracing }
Re: [PATCH v2 05/32] selftests/ftrace: More initialize features in initialize_ftrace
In reply to Masami HiramatsuQuoted 5 lines · On Fri, 17 Aug 2018 01:31:33 +0900 Masami Hiramatsu <[email protected]> wrote:
Clear pid filter,
synthetic_events, snapshots, ftrace filter, and trace log ininitialize_ftrace(), since those are used in test cases.Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>
-- Steve
Quoted 29 lines
---
Changes in v2:
- Addreset_ftrace_filter--- tools/testing/selftests/ftrace/test.d/functions | 5 +++++ 1 file changed, 5 insertions(+)tools/testing/selftests/ftrace/test.d/functions +5
-0@@ -89,12 +89,17 @@ initialize_ftrace() { # Reset ftrace to initial-state reset_tracer reset_trigger reset_events_filter + reset_ftrace_filter disable_events echo > set_event_pid # event tracer is always on + echo > set_ftrace_pid [ -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 + [ -f synthetic_events ] && echo > synthetic_events + [ -f snapshot ] && echo 0 > snapshot + clear_trace enable_tracing }
Steven Rostedt
maintainerRe: [PATCH v2 05/32] selftests/ftrace: More initialize features in initialize_ftrace
Quoted 11 lines · On Fri, 24 Aug 2018 17:46:01 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 5 lines · On Fri, 17 Aug 2018 01:31:33 +0900 Masami Hiramatsu <[email protected]> wrote:
Clear pid filter,
synthetic_events, snapshots, ftrace filter, and trace log ininitialize_ftrace(), since those are used in test cases.Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>Acked-by Steven Rostedt (VMware) <rostedt at goodmis.org>
Bah, this was suppose to be for the previous patch (which I just got done testing). I'll send out a separate ack for that.
-- Steve
Masami Hiramatsu
maintainerPATCH v2 6/32 selftests/ftrace: Add SPDX License Identifier to template
In reply to Masami HiramatsuAdd SPDX License Identifier line to template file so that someone who makes new testcase from the template does not forgot it.
--- tools/testing/selftests/ftrace/test.d/template | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/ftrace/test.d/template +1 -0
@@ -1,4 +1,5 @@ #!/bin/sh +# SPDX-License-Identifier: GPL2.0 # description: %HERE DESCRIBE WHAT THIS DOES% # you have to add ".tc" extention for your testcase file # Note that all tests are run with "errexit" option.
Masami Hiramatsu
maintainerPATCH v2 7/32 selftests/ftrace: Cleanup ftrace after running test
In reply to Masami HiramatsuCleanup ftrace by initialize_ftrace() after running all test cases. This means we also don't need cleanup ftrace on each test case, except for some special options.
--- tools/testing/selftests/ftrace/ftracetest | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/ftrace/ftracetest +1 -0
@@ -341,6 +341,7 @@ for t in $TEST_CASES; do exit 1 fi done +(cd $TRACING_DIR; initialize_ftrace) # for cleanup prlog "" prlog "# of passed: " `echo $PASSED_CASES | wc -w`
Masami Hiramatsu
maintainerPATCH v2 8/32 selftests/ftrace: Remove unneeded per-test init/cleanup ftrace
In reply to Masami HiramatsuSince ftracetest framework calls initialize_ftrace() right before each test and after all tests, we don't need to init/cleanup ftrace for each test case.
Just remove such unneeded init/cleanup code because it can increase logfile size.
--- .../selftests/ftrace/test.d/event/event-enable.tc | 6 ------ .../selftests/ftrace/test.d/event/event-pid.tc | 3 +-- .../ftrace/test.d/event/subsystem-enable.tc | 6 ------ .../ftrace/test.d/event/toplevel-enable.tc | 6 ------ .../ftrace/test.d/ftrace/fgraph-filter-stack.tc | 4 ---- .../ftrace/test.d/ftrace/fgraph-filter.tc | 9 --------- .../ftrace/test.d/ftrace/func-filter-pid.tc | 6 ------ .../ftrace/test.d/ftrace/func_event_triggers.tc | 3 --- .../ftrace/test.d/ftrace/func_profiler.tc | 4 ---- .../ftrace/test.d/ftrace/func_set_ftrace_file.tc | 13 ------------- .../test.d/ftrace/func_traceonoff_triggers.tc | 11 ----------- .../ftrace/test.d/kprobe/add_and_remove.tc | 3 --- .../selftests/ftrace/test.d/kprobe/busy_check.tc | 3 --- .../selftests/ftrace/test.d/kprobe/kprobe_args.tc | 2 -- .../ftrace/test.d/kprobe/kprobe_args_string.tc | 5 ----- .../ftrace/test.d/kprobe/kprobe_args_syntax.tc | 5 ----- .../ftrace/test.d/kprobe/kprobe_args_type.tc | 4 ---- .../ftrace/test.d/kprobe/kprobe_eventname.tc | 5 ----- .../ftrace/test.d/kprobe/kprobe_ftrace.tc | 9 --------- .../ftrace/test.d/kprobe/kprobe_module.tc | 5 ----- .../ftrace/test.d/kprobe/kretprobe_args.tc | 2 -- .../ftrace/test.d/kprobe/kretprobe_maxactive.tc | 4 ---- .../ftrace/test.d/kprobe/multiple_kprobes.tc | 5 ----- .../selftests/ftrace/test.d/kprobe/probepoint.tc | 4 ---- .../inter-event/trigger-extended-error-support.tc | 12 ------------ .../inter-event/trigger-field-variable-support.tc | 13 ------------- .../trigger-inter-event-combined-hist.tc | 13 ------------- .../inter-event/trigger-multi-actions-accept.tc | 14 -------------- .../inter-event/trigger-onmatch-action-hist.tc | 13 ------------- .../trigger-onmatch-onmax-action-hist.tc | 13 ------------- .../inter-event/trigger-onmax-action-hist.tc | 13 ------------- .../trigger-synthetic-event-createremove.tc | 12 ------------ .../ftrace/test.d/trigger/trigger-eventonoff.tc | 12 ------------ .../ftrace/test.d/trigger/trigger-filter.tc | 14 -------------- .../ftrace/test.d/trigger/trigger-hist-mod.tc | 12 ------------ .../ftrace/test.d/trigger/trigger-hist.tc | 12 ------------ .../ftrace/test.d/trigger/trigger-multihist.tc | 16 ---------------- .../ftrace/test.d/trigger/trigger-snapshot.tc | 12 ------------ .../ftrace/test.d/trigger/trigger-stacktrace.tc | 12 ------------ .../test.d/trigger/trigger-trace-marker-hist.tc | 11 ----------- .../trigger/trigger-trace-marker-snapshot.tc | 12 ------------ .../trigger-trace-marker-synthetic-kernel.tc | 12 ------------ .../trigger/trigger-trace-marker-synthetic.tc | 12 ------------ .../ftrace/test.d/trigger/trigger-traceonoff.tc | 12 ------------ 44 files changed, 1 insertion(+), 378 deletions(-)
tools/testing/selftests/ftrace/test.d/event/event-enable.tc +0 -6
@@ -9,7 +9,6 @@ do_reset() { } fail() { #msg - do_reset echo $1 exit_fail }
@@ -23,9 +22,6 @@ if [ ! -f set_event -o ! -d events/sched ]; then exit_unsupported fi -reset_tracer -do_reset - echo 'sched:sched_switch' > set_event yield
@@ -57,6 +53,4 @@ if [ $count -ne 0 ]; then fail "sched_switch events should not be recorded" fi -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/event/event-pid.tc +1 -2
@@ -30,8 +30,7 @@ if [ ! -f set_event_pid ]; then exit_unsupported fi -reset_tracer -do_reset +echo 0 > options/event-fork echo 1 > events/sched/sched_switch/enable
tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc +0 -6
@@ -9,7 +9,6 @@ do_reset() { } fail() { #msg - do_reset echo $1 exit_fail }
@@ -23,9 +22,6 @@ if [ ! -f set_event -o ! -d events/sched ]; then exit_unsupported fi -reset_tracer -do_reset - echo 'sched:*' > set_event yield
@@ -57,6 +53,4 @@ if [ $count -ne 0 ]; then fail "any of scheduler events should not be recorded" fi -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc +0 -6
@@ -8,7 +8,6 @@ do_reset() { } fail() { #msg - do_reset echo $1 exit_fail }
@@ -22,9 +21,6 @@ if [ ! -f available_events -o ! -f set_event -o ! -d events ]; then exit_unsupported fi -reset_tracer -do_reset - echo '*:*' > set_event yield
@@ -60,6 +56,4 @@ if [ $count -ne 0 ]; then fail "any of events should not be recorded" fi -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc +0 -4
@@ -16,13 +16,9 @@ if [ ! -f set_ftrace_filter ]; then fi do_reset() { - reset_tracer if [ -e /proc/sys/kernel/stack_tracer_enabled ]; then echo 0 > /proc/sys/kernel/stack_tracer_enabled fi - enable_tracing - clear_trace - echo > set_ftrace_filter } fail() { # msg
tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc +0 -9
@@ -9,14 +9,7 @@ if ! grep -q function_graph available_tracers; then exit_unsupported fi -do_reset() { - reset_tracer - enable_tracing - clear_trace -} - fail() { # msg - do_reset echo $1 exit_fail }
@@ -48,6 +41,4 @@ if [ $count -eq 0 ]; then fail "No schedule traces found?" fi -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc +0 -6
@@ -35,12 +35,6 @@ if [ $do_function_fork -eq 1 ]; then fi do_reset() { - reset_tracer - clear_trace - enable_tracing - echo > set_ftrace_filter - echo > set_ftrace_pid - if [ $do_function_fork -eq 0 ]; then return fi
tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc +0 -3
@@ -25,15 +25,12 @@ do_reset() { } fail() { # mesg - do_reset echo $1 exit_fail } SLEEP_TIME=".1" -do_reset - echo "Testing function probes with events:" EVENT="sched:sched_switch"
tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc +0 -4
@@ -29,8 +29,6 @@ if [ ! -f function_profile_enabled ]; then fi fail() { # mesg - reset_tracer - echo > set_ftrace_filter echo $1 exit_fail }
@@ -76,6 +74,4 @@ if ! grep -v -e '^#' -e 'schedule' trace > /dev/null; then fail "no other functions besides schedule was found" fi -reset_tracer - exit 0
tools/testing/selftests/ftrace/test.d/ftrace/func_set_ftrace_file.tc +0 -13
@@ -15,22 +15,11 @@ if [ ! -f set_ftrace_filter ]; then exit_unsupported fi -do_reset() { - reset_tracer - reset_ftrace_filter - disable_events - clear_trace - enable_tracing -} - fail() { # mesg - do_reset echo $1 exit_fail } -do_reset - FILTER=set_ftrace_filter FUNC1="schedule" FUNC2="do_softirq"
@@ -165,6 +154,4 @@ test_actual rm $TMPDIR/expected rm $TMPDIR/actual -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc +0 -11
@@ -16,24 +16,13 @@ if [ ! -f set_ftrace_filter ]; then exit_unsupported fi -do_reset() { - reset_ftrace_filter - reset_tracer - disable_events - clear_trace - enable_tracing -} - fail() { # mesg - do_reset echo $1 exit_fail } SLEEP_TIME=".1" -do_reset - echo "Testing function probes with enabling disabling tracing:" cnt_trace() {
tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc +0 -3
@@ -4,10 +4,7 @@ [ -f kprobe_events ] || exit_unsupported # this is configurable -echo 0 > events/enable -echo > kprobe_events echo p:myevent _do_fork > kprobe_events grep myevent kprobe_events test -d events/kprobes/myevent echo > kprobe_events -clear_trace
tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc +0 -3
@@ -4,12 +4,9 @@ [ -f kprobe_events ] || exit_unsupported -echo 0 > events/enable -echo > kprobe_events echo p:myevent _do_fork > kprobe_events test -d events/kprobes/myevent echo 1 > events/kprobes/myevent/enable echo > kprobe_events && exit_fail # this must fail echo 0 > events/kprobes/myevent/enable echo > kprobe_events # this must succeed -clear_trace
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc +0 -2
@@ -4,8 +4,6 @@ [ -f kprobe_events ] || exit_unsupported # this is configurable -echo 0 > events/enable -echo > kprobe_events echo 'p:testprobe _do_fork $stack $stack0 +0($stack)' > kprobe_events grep testprobe kprobe_events test -d events/kprobes/testprobe
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc +0 -5
@@ -4,9 +4,6 @@ [ -f kprobe_events ] || exit_unsupported # this is configurable -echo 0 > events/enable -echo > kprobe_events - case `uname -m` in x86_64) ARG1=%di
@@ -44,5 +41,3 @@ echo 1 > events/kprobes/testprobe/enable echo "p:test _do_fork" >> kprobe_events grep -qe "testprobe.* arg1=\"test\" arg2=\"test\"" trace -echo 0 > events/enable -echo > kprobe_events
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc +0 -5
@@ -6,9 +6,6 @@ grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue -echo 0 > events/enable -echo > kprobe_events - PROBEFUNC="vfs_read" GOODREG= BADREG=
@@ -100,5 +97,3 @@ test_badarg "${GOODREG}::${GOODTYPE}" "${GOODREG}:${BADTYPE}" \ test_goodarg "\$comm:string" "+0(\$stack):string" test_badarg "\$comm:x64" "\$stack:string" "${GOODREG}:string" - -echo > kprobe_events
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc +0 -4
@@ -6,10 +6,6 @@ grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue -echo 0 > events/enable -echo > kprobe_events -enable_tracing - echo 'p:testprobe _do_fork $stack0:s32 $stack0:u32 $stack0:x32 $stack0:b8 at 4/32' > kprobe_events grep testprobe kprobe_events test -d events/kprobes/testprobe
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc +0 -5
@@ -4,9 +4,6 @@ [ -f kprobe_events ] || exit_unsupported # this is configurable -disable_events -echo > kprobe_events - :;: "Add an event on function without name" ;: FUNC=`grep " [tT] .*vfs_read$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "`
@@ -33,5 +30,3 @@ echo "p $FUNC" > kprobe_events EVENT=`grep $FUNC kprobe_events | cut -f 1 -d " " | cut -f 2 -d:` [ "x" != "x$EVENT" ] || exit_failure test -d events/$EVENT || exit_failure - -echo > kprobe_events
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc +0 -9
@@ -8,8 +8,6 @@ grep function available_tracers || exit_unsupported # this is configurable # prepare echo nop > current_tracer echo _do_fork > set_ftrace_filter -echo 0 > events/enable -echo > kprobe_events echo 'p:testprobe _do_fork' > kprobe_events # kprobe on / ftrace off
@@ -47,10 +45,3 @@ echo > trace ( echo "forked") grep testprobe trace ! grep '_do_fork <-' trace - -# cleanup -echo nop > current_tracer -echo > set_ftrace_filter -echo 0 > events/kprobes/testprobe/enable -echo > kprobe_events -echo > trace
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc +0 -5
@@ -4,9 +4,6 @@ [ -f kprobe_events ] || exit_unsupported # this is configurable -disable_events -echo > kprobe_events - :;: "Add an event on a module function without specifying event name" ;: MOD=`lsmod | head -n 2 | tail -n 1 | cut -f1 -d" "`
@@ -25,5 +22,3 @@ test -d events/kprobes/event1 || exit_failure echo "p:kprobes1/event1 $MOD:$FUNC" > kprobe_events test -d events/kprobes1/event1 || exit_failure - -echo > kprobe_events
tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc +0 -2
@@ -4,8 +4,6 @@ [ -f kprobe_events ] || exit_unsupported # this is configurable -echo 0 > events/enable -echo > kprobe_events echo 'r:testprobe2 _do_fork $retval' > kprobe_events grep testprobe2 kprobe_events test -d events/kprobes/testprobe2
tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_maxactive.tc +0 -4
@@ -5,8 +5,6 @@ [ -f kprobe_events ] || exit_unsupported # this is configurable grep -q 'r\[maxactive\]' README || exit_unsupported # this is older version -echo > kprobe_events - # Test if we successfully reject unknown messages if echo 'a:myprobeaccept inet_csk_accept' > kprobe_events; then false; else true; fi
@@ -37,5 +35,3 @@ echo > kprobe_events echo 'r10 inet_csk_accept' > kprobe_events grep inet_csk_accept kprobe_events echo > kprobe_events - -clear_trace
tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc +0 -5
@@ -12,11 +12,6 @@ case `uname -m` in *) OFFS=0;; esac -if [ -d events/kprobes ]; then - echo 0 > events/kprobes/enable - echo > kprobe_events -fi - N=0 echo "Setup up kprobes on first available 256 text symbols" grep -i " t " /proc/kallsyms | cut -f3 -d" " | grep -v .*\\..* | \
tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc +0 -4
@@ -30,8 +30,6 @@ if [ `printf "%x" -1 | wc -c` != 9 ]; then UINT_TEST=yes fi -echo 0 > events/enable -echo > kprobe_events echo "p:testprobe ${TARGET_FUNC}" > kprobe_events echo "p:testprobe ${TARGET}" > kprobe_events echo "p:testprobe ${TARGET_FUNC}${NEXT}" > kprobe_events
@@ -39,5 +37,3 @@ echo "p:testprobe ${TARGET_FUNC}${NEXT}" > kprobe_events if [ "${UINT_TEST}" = yes ]; then ! echo "p:testprobe ${TARGET_FUNC}${OVERFLOW}" > kprobe_events fi -echo > kprobe_events -clear_trace
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-extended-error-support.tc +0 -12
@@ -2,14 +2,7 @@ # description: event trigger - test extended error support -do_reset() { - reset_trigger - echo > set_event - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -24,9 +17,6 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi -reset_tracer -do_reset - echo "Test extended error support" echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_wakeup/trigger ! echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' >> events/sched/sched_wakeup/trigger 2> /dev/null
@@ -34,6 +24,4 @@ if ! grep -q "ERROR:" events/sched/sched_wakeup/hist; then fail "Failed to generate extended error in histogram" fi -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc +0 -13
@@ -1,14 +1,7 @@ #!/bin/sh # description: event trigger - test field variable support -do_reset() { - reset_trigger - echo > set_event - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -23,10 +16,6 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi -clear_synthetic_events -reset_tracer -do_reset - echo "Test field variable support" echo 'wakeup_latency u64 lat; pid_t pid; int prio; char comm[16]' > synthetic_events
@@ -49,6 +38,4 @@ if grep -q "synthetic_prio=prio" events/sched/sched_waking/hist; then fail "Failed to remove histogram with field variable" fi -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc +0 -13
@@ -1,14 +1,7 @@ #!/bin/sh # description: event trigger - test inter-event combined histogram trigger -do_reset() { - reset_trigger - echo > set_event - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -23,10 +16,6 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi -reset_tracer -do_reset -clear_synthetic_events - echo "Test create synthetic event" echo 'waking_latency u64 lat pid_t pid' > synthetic_events
@@ -53,6 +42,4 @@ if ! grep -q "pid:" events/synthetic/waking+wakeup_latency/hist; then fail "Failed to create combined histogram" fi -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-multi-actions-accept.tc +0 -14
@@ -1,15 +1,7 @@ #!/bin/sh # description: event trigger - test multiple actions on hist trigger - -do_reset() { - reset_trigger - echo > set_event - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -24,10 +16,6 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi -clear_synthetic_events -reset_tracer -do_reset - echo "Test multiple actions on hist trigger" echo 'wakeup_latency u64 lat; pid_t pid' >> synthetic_events TRIGGER1=events/sched/sched_wakeup/trigger
@@ -39,6 +27,4 @@ echo 'hist:keys=next_pid:onmatch(sched.sched_wakeup).wakeup_latency(sched.sched_ echo 'hist:keys=next_pid:onmatch(sched.sched_wakeup).wakeup_latency(sched.sched_switch.$wakeup_lat,prev_pid) if next_comm=="cyclictest"' >> $TRIGGER2 echo 'hist:keys=next_pid if next_comm=="cyclictest"' >> $TRIGGER2 -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc +0 -13
@@ -1,14 +1,7 @@ #!/bin/sh # description: event trigger - test inter-event histogram trigger onmatch action -do_reset() { - reset_trigger - echo > set_event - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -23,10 +16,6 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi -clear_synthetic_events -reset_tracer -do_reset - echo "Test create synthetic event" echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events
@@ -45,6 +34,4 @@ if ! grep -q "ping" events/synthetic/wakeup_latency/hist; then fail "Failed to create onmatch action inter-event histogram" fi -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc +0 -13
@@ -1,14 +1,7 @@ #!/bin/sh # description: event trigger - test inter-event histogram trigger onmatch-onmax action -do_reset() { - reset_trigger - echo > set_event - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -23,10 +16,6 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi -clear_synthetic_events -reset_tracer -do_reset - echo "Test create synthetic event" echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events
@@ -45,6 +34,4 @@ if [ ! grep -q "ping" events/synthetic/wakeup_latency/hist -o ! grep -q "max:" e fail "Failed to create onmatch-onmax action inter-event histogram" fi -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc +0 -13
@@ -1,14 +1,7 @@ #!/bin/sh # description: event trigger - test inter-event histogram trigger onmax action -do_reset() { - reset_trigger - echo > set_event - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -23,10 +16,6 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi -clear_synthetic_events -reset_tracer -do_reset - echo "Test create synthetic event" echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events
@@ -43,6 +32,4 @@ if ! grep -q "max:" events/sched/sched_switch/hist; then fail "Failed to create onmax action inter-event histogram" fi -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-createremove.tc +0 -12
@@ -1,13 +1,7 @@ #!/bin/sh # description: event trigger - test synthetic event create remove -do_reset() { - reset_trigger - echo > set_event - clear_trace -} fail() { #msg - do_reset echo $1 exit_fail }
@@ -22,10 +16,6 @@ if [ ! -f synthetic_events ]; then exit_unsupported fi -clear_synthetic_events -reset_tracer -do_reset - echo "Test create synthetic event" echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events
@@ -49,6 +39,4 @@ if [ -d events/synthetic/wakeup_latency ]; then fail "Failed to delete wakeup_latency synthetic event" fi -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/trigger-eventonoff.tc +0 -12
@@ -3,14 +3,7 @@ # description: event trigger - test event enable/disable trigger # flags: instance -do_reset() { - reset_trigger - echo > set_event - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -25,9 +18,6 @@ if [ ! -f events/sched/sched_process_fork/trigger ]; then exit_unsupported fi -reset_tracer -do_reset - FEATURE=`grep enable_event events/sched/sched_process_fork/trigger` if [ -z "$FEATURE" ]; then echo "event enable/disable trigger is not supported"
@@ -61,6 +51,4 @@ echo 'enable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger ! echo 'enable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger ! echo 'disable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/trigger-filter.tc +0 -14
@@ -3,14 +3,7 @@ # description: event trigger - test trigger filter # flags: instance -do_reset() { - reset_trigger - echo > set_event - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -25,9 +18,6 @@ if [ ! -f events/sched/sched_process_fork/trigger ]; then exit_unsupported fi -reset_tracer -do_reset - echo "Test trigger filter" echo 1 > tracing_on echo 'traceoff if child_pid == 0' > events/sched/sched_process_fork/trigger
@@ -54,8 +44,4 @@ echo '!traceoff' > events/sched/sched_process_fork/trigger echo 'traceoff if parent_pid >= 0 || child_pid >= 0' > events/sched/sched_process_fork/trigger echo '!traceoff' > events/sched/sched_process_fork/trigger - - -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc +0 -12
@@ -3,14 +3,7 @@ # description: event trigger - test histogram modifiers # flags: instance -do_reset() { - reset_trigger - echo > set_event - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -30,9 +23,6 @@ if [ ! -f events/sched/sched_process_fork/hist ]; then exit_unsupported fi -reset_tracer -do_reset - echo "Test histogram with execname modifier" echo 'hist:keys=common_pid.execname' > events/sched/sched_process_fork/trigger
@@ -71,6 +61,4 @@ for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done grep 'bytes_req: ~ 2^[0-9]*' events/kmem/kmalloc/hist > /dev/null || \ fail "log2 modifier on kmem/kmalloc did not work" -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/trigger-hist.tc +0 -12
@@ -3,14 +3,7 @@ # description: event trigger - test histogram trigger # flags: instance -do_reset() { - reset_trigger - echo > set_event - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -30,9 +23,6 @@ if [ ! -f events/sched/sched_process_fork/hist ]; then exit_unsupported fi -reset_tracer -do_reset - echo "Test histogram basic tigger" echo 'hist:keys=parent_pid:vals=child_pid' > events/sched/sched_process_fork/trigger
@@ -79,6 +69,4 @@ check_inc `grep -o "child_pid:[[:space:]]*[[:digit:]]*" \ events/sched/sched_process_fork/hist | cut -d: -f2 ` || fail "sort param on sched_process_fork did not work" -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/trigger-multihist.tc +0 -16
@@ -3,14 +3,7 @@ # description: event trigger - test multiple histogram triggers # flags: instance -do_reset() { - reset_trigger - echo > set_event - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -30,11 +23,6 @@ if [ ! -f events/sched/sched_process_fork/hist ]; then exit_unsupported fi -reset_tracer -do_reset - -reset_trigger - echo "Test histogram multiple tiggers" echo 'hist:keys=parent_pid:vals=child_pid' > events/sched/sched_process_fork/trigger
@@ -67,8 +55,4 @@ grep test_hist events/sched/sched_process_exit/hist > /dev/null || \ diffs=`diff events/sched/sched_process_exit/hist events/sched/sched_process_fork/hist | wc -l` test $diffs -eq 0 || fail "Same name histograms are not same" -reset_trigger - -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc +0 -12
@@ -2,14 +2,7 @@ # SPDX-License-Identifier: GPL-2.0 # description: event trigger - test snapshot-trigger -do_reset() { - reset_trigger - echo > set_event - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -29,9 +22,6 @@ if [ ! -f snapshot ]; then exit_unsupported fi -reset_tracer -do_reset - FEATURE=`grep snapshot events/sched/sched_process_fork/trigger` if [ -z "$FEATURE" ]; then echo "snapshot trigger is not supported"
@@ -57,6 +47,4 @@ echo "Test snapshot semantic errors" echo "snapshot" > events/sched/sched_process_fork/trigger ! echo "snapshot" > events/sched/sched_process_fork/trigger -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/trigger-stacktrace.tc +0 -12
@@ -2,14 +2,7 @@ # SPDX-License-Identifier: GPL-2.0 # description: event trigger - test stacktrace-trigger -do_reset() { - reset_trigger - echo > set_event - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -24,9 +17,6 @@ if [ ! -f events/sched/sched_process_fork/trigger ]; then exit_unsupported fi -reset_tracer -do_reset - FEATURE=`grep stacktrace events/sched/sched_process_fork/trigger` if [ -z "$FEATURE" ]; then echo "stacktrace trigger is not supported"
@@ -49,6 +39,4 @@ echo "Test stacktrace semantic errors" echo "stacktrace" > events/sched/sched_process_fork/trigger ! echo "stacktrace" > events/sched/sched_process_fork/trigger -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-hist.tc +0 -11
@@ -3,14 +3,7 @@ # description: trace_marker trigger - test histogram trigger # flags: instance -do_reset() { - reset_trigger - echo > set_event - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -35,8 +28,6 @@ if [ ! -f events/ftrace/print/hist ]; then exit_unsupported fi -do_reset - echo "Test histogram trace_marker tigger" echo 'hist:keys=common_pid' > events/ftrace/print/trigger
@@ -44,6 +35,4 @@ for i in `seq 1 10` ; do echo "hello" > trace_marker; done grep 'hitcount: *10$' events/ftrace/print/hist > /dev/null || \ fail "hist trigger did not trigger correct times on trace_marker" -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-snapshot.tc +0 -12
@@ -3,15 +3,7 @@ # description: trace_marker trigger - test snapshot trigger # flags: instance -do_reset() { - reset_trigger - echo > set_event - echo 0 > snapshot - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -54,8 +46,6 @@ test_trace() { done } -do_reset - echo "Test snapshot trace_marker tigger" echo 'snapshot' > events/ftrace/print/trigger
@@ -69,6 +59,4 @@ for i in `seq 1 10` ; do echo "hello >$i<" > trace_marker; done test_trace trace 1 test_trace snapshot 2 -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-synthetic-kernel.tc +0 -12
@@ -3,15 +3,7 @@ # description: trace_marker trigger - test histogram with synthetic event against kernel event # flags: -do_reset() { - reset_trigger - echo > set_event - echo > synthetic_events - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -46,8 +38,6 @@ if [ ! -f events/ftrace/print/hist ]; then exit_unsupported fi -do_reset - echo "Test histogram kernel event to trace_marker latency histogram trigger" echo 'latency u64 lat' > synthetic_events
@@ -63,6 +53,4 @@ grep 'hitcount: *1$' events/ftrace/print/hist > /dev/null || \ grep 'hitcount: *1$' events/synthetic/latency/hist > /dev/null || \ fail "hist trigger did not trigger " -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-synthetic.tc +0 -12
@@ -3,15 +3,7 @@ # description: trace_marker trigger - test histogram with synthetic event # flags: -do_reset() { - reset_trigger - echo > set_event - echo > synthetic_events - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -41,8 +33,6 @@ if [ ! -f events/ftrace/print/hist ]; then exit_unsupported fi -do_reset - echo "Test histogram trace_marker to trace_marker latency histogram trigger" echo 'latency u64 lat' > synthetic_events
@@ -61,6 +51,4 @@ fi grep 'hitcount: *1$' events/synthetic/latency/hist > /dev/null || \ fail "hist trigger did not trigger " -do_reset - exit 0
tools/testing/selftests/ftrace/test.d/trigger/trigger-traceonoff.tc +0 -12
@@ -2,14 +2,7 @@ # SPDX-License-Identifier: GPL-2.0 # description: event trigger - test traceon/off trigger -do_reset() { - reset_trigger - echo > set_event - clear_trace -} - fail() { #msg - do_reset echo $1 exit_fail }
@@ -24,9 +17,6 @@ if [ ! -f events/sched/sched_process_fork/trigger ]; then exit_unsupported fi -reset_tracer -do_reset - echo "Test traceoff trigger" echo 1 > tracing_on echo 'traceoff' > events/sched/sched_process_fork/trigger
@@ -54,6 +44,4 @@ echo 'traceon' > events/sched/sched_process_fork/trigger ! echo 'traceon' > events/sched/sched_process_fork/trigger ! echo 'traceoff' > events/sched/sched_process_fork/trigger -do_reset - exit 0
Masami Hiramatsu
maintainerPATCH v2 9/32 selftests/ftrace: Fix to test kprobe $comm arg only if available
In reply to Masami HiramatsuTest $comm in kprobe-event argument syntax testcase only if it is supported on the kernel because $comm has been introduced 4.8 kernel.
So on older stable kernel, it should be skipped.
--- .../ftrace/test.d/kprobe/kprobe_args_syntax.tc | 3 +++ 1 file changed, 3 insertions(+)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc +3 -0
@@ -75,8 +75,11 @@ test_badarg "\$stackp" "\$stack0+10" "\$stack1-10" echo "r ${PROBEFUNC} \$retval" > kprobe_events ! echo "p ${PROBEFUNC} \$retval" > kprobe_events +# $comm was introduced in 4.8, older kernels reject it. +if grep -A1 "fetcharg:" README | grep -q '\$comm' ; then : "Comm access" test_goodarg "\$comm" +fi : "Indirect memory access" test_goodarg "+0(${GOODREG})" "-0(${GOODREG})" "+10(\$stack)" \
Masami Hiramatsu
maintainerPATCH v2 10/32 selftests/ftrace: Fix checkbashisms errors
In reply to Masami HiramatsuFix a test case to make checkbashisms clean.
--- .../trigger/trigger-trace-marker-snapshot.tc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-snapshot.tc +2 -2
@@ -39,10 +39,10 @@ test_trace() { fi echo "testing $line for >$x<" match=`echo $line | sed -e "s/>$x<//"` - if [ "$line" == "$match" ]; then + if [ "$line" = "$match" ]; then fail "$line does not have >$x< in it" fi - let x=$x+2 + x=$((x+2)) done }
Re: [PATCH v2 10/32] selftests/ftrace: Fix checkbashisms errors
Quoted 12 lines · On Fri, 17 Aug 2018 01:33:55 +0900 Masami Hiramatsu <[email protected]> wrote:
Fix a test case to make checkbashisms clean.
Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../trigger/trigger-trace-marker-snapshot.tc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-snapshot.tc +0
-0
tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-snapshot.tc test_trace() { · line 45
Quoted 9 lines
tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-snapshot.tc +2
-2@@ -39,10 +39,10 @@ test_trace() { fi echo "testing $line for >$x<" match=`echo $line | sed -e "s/>$x<//"` - if [ "$line" == "$match" ]; then + if [ "$line" = "$match" ]; then fail "$line does not have >$x< in it" fi - let x=$x+2 + x=$((x+2))
I didn't realize "let" was a bashism. I've been using that on other shells I believe. But whatever.
-- Steve
Quoted 3 lines
tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-snapshot.tc +0
-0done }
Masami Hiramatsu
maintainerPATCH v2 11/32 selftests/ftrace: Use loopback address instead of localhost
In reply to Masami HiramatsuUse raw loopback address instead of localhost, because "localhost" can depend on nsswitch and in some case we can not resolve the localhost.
--- .../selftests/ftrace/test.d/event/event-enable.tc | 2 +- .../selftests/ftrace/test.d/event/event-pid.tc | 2 +- .../ftrace/test.d/event/subsystem-enable.tc | 2 +- .../ftrace/test.d/event/toplevel-enable.tc | 2 +- .../ftrace/test.d/ftrace/func-filter-pid.tc | 2 +- .../inter-event/trigger-field-variable-support.tc | 2 +- .../trigger-inter-event-combined-hist.tc | 2 +- .../inter-event/trigger-onmatch-action-hist.tc | 2 +- .../trigger-onmatch-onmax-action-hist.tc | 2 +- .../inter-event/trigger-onmax-action-hist.tc | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-)
tools/testing/selftests/ftrace/test.d/event/event-enable.tc +1 -1
@@ -14,7 +14,7 @@ fail() { #msg } yield() { - ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 + ping 127.0.0.1 -c 1 || sleep .001 || usleep 1 || sleep 1 } if [ ! -f set_event -o ! -d events/sched ]; then
tools/testing/selftests/ftrace/test.d/event/event-pid.tc +1 -1
@@ -17,7 +17,7 @@ fail() { #msg } yield() { - ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 + ping 127.0.0.1 -c 1 || sleep .001 || usleep 1 || sleep 1 } if [ ! -f set_event -o ! -d events/sched ]; then
tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc +1 -1
@@ -14,7 +14,7 @@ fail() { #msg } yield() { - ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 + ping 127.0.0.1 -c 1 || sleep .001 || usleep 1 || sleep 1 } if [ ! -f set_event -o ! -d events/sched ]; then
tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc +1 -1
@@ -13,7 +13,7 @@ fail() { #msg } yield() { - ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 + ping 127.0.0.1 -c 1 || sleep .001 || usleep 1 || sleep 1 } if [ ! -f available_events -o ! -f set_event -o ! -d events ]; then
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc +1 -1
@@ -49,7 +49,7 @@ fail() { # msg } yield() { - ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 + ping 127.0.0.1 -c 1 || sleep .001 || usleep 1 || sleep 1 } do_test() {
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc +1 -1
@@ -23,7 +23,7 @@ echo 'hist:keys=comm:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/ echo 'hist:keys=next_comm:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,next_pid,sched.sched_waking.prio,next_comm) if next_comm=="ping"' > events/sched/sched_switch/trigger echo 'hist:keys=pid,prio,comm:vals=lat:sort=pid,prio' > events/synthetic/wakeup_latency/trigger -ping localhost -c 3 +ping 127.0.0.1 -c 3 if ! grep -q "ping" events/synthetic/wakeup_latency/hist; then fail "Failed to create inter-event histogram" fi
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc +1 -1
@@ -37,7 +37,7 @@ echo 'waking+wakeup_latency u64 lat; pid_t pid' >> synthetic_events echo 'hist:keys=pid,lat:sort=pid,lat:ww_lat=$waking_lat+$wakeup_lat:onmatch(synthetic.wakeup_latency).waking+wakeup_latency($ww_lat,pid)' >> events/synthetic/wakeup_latency/trigger echo 'hist:keys=pid,lat:sort=pid,lat' >> events/synthetic/waking+wakeup_latency/trigger -ping localhost -c 3 +ping 127.0.0.1 -c 3 if ! grep -q "pid:" events/synthetic/waking+wakeup_latency/hist; then fail "Failed to create combined histogram" fi
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc +1 -1
@@ -29,7 +29,7 @@ echo "Test histogram variables,simple expression support and onmatch action" echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_wakeup/trigger echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_wakeup).wakeup_latency($wakeup_lat,next_pid,next_comm) if next_comm=="ping"' > events/sched/sched_switch/trigger echo 'hist:keys=comm,pid,lat:wakeup_lat=lat:sort=lat' > events/synthetic/wakeup_latency/trigger -ping localhost -c 5 +ping 127.0.0.1 -c 5 if ! grep -q "ping" events/synthetic/wakeup_latency/hist; then fail "Failed to create onmatch action inter-event histogram" fi
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc +1 -1
@@ -29,7 +29,7 @@ echo "Test histogram variables,simple expression support and onmatch-onmax actio echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_wakeup/trigger echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_wakeup).wakeup_latency($wakeup_lat,next_pid,next_comm):onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) if next_comm=="ping"' >> events/sched/sched_switch/trigger echo 'hist:keys=comm,pid,lat:wakeup_lat=lat:sort=lat' > events/synthetic/wakeup_latency/trigger -ping localhost -c 5 +ping 127.0.0.1 -c 5 if [ ! grep -q "ping" events/synthetic/wakeup_latency/hist -o ! grep -q "max:" events/sched/sched_switch/hist]; then fail "Failed to create onmatch-onmax action inter-event histogram" fi
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc +1 -1
@@ -27,7 +27,7 @@ echo "Test onmax action" echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' >> events/sched/sched_waking/trigger echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) if next_comm=="ping"' >> events/sched/sched_switch/trigger -ping localhost -c 3 +ping 127.0.0.1 -c 3 if ! grep -q "max:" events/sched/sched_switch/hist; then fail "Failed to create onmax action inter-event histogram" fi
Steven Rostedt
maintainerRe: [PATCH v2 11/32] selftests/ftrace: Use loopback address instead of localhost
Quoted 75 lines · On Fri, 17 Aug 2018 01:34:23 +0900 Masami Hiramatsu <[email protected]> wrote:
Use raw loopback address instead of localhost, because "localhost" can depend on nsswitch and in some case we can not resolve the localhost.
Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../selftests/ftrace/test.d/event/event-enable.tc | 2 +- .../selftests/ftrace/test.d/event/event-pid.tc | 2 +- .../ftrace/test.d/event/subsystem-enable.tc | 2 +- .../ftrace/test.d/event/toplevel-enable.tc | 2 +- .../ftrace/test.d/ftrace/func-filter-pid.tc | 2 +- .../inter-event/trigger-field-variable-support.tc | 2 +- .../trigger-inter-event-combined-hist.tc | 2 +- .../inter-event/trigger-onmatch-action-hist.tc | 2 +- .../trigger-onmatch-onmax-action-hist.tc | 2 +- .../inter-event/trigger-onmax-action-hist.tc | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-)tools/testing/selftests/ftrace/test.d/event/event-enable.tc +1
-1@@ -14,7 +14,7 @@ fail() { #msg } yield() { - ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 + ping 127.0.0.1 -c 1 || sleep .001 || usleep 1 || sleep 1 } if [ ! -f set_event -o ! -d events/sched ]; thentools/testing/selftests/ftrace/test.d/event/event-pid.tc +1
-1@@ -17,7 +17,7 @@ fail() { #msg } yield() { - ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 + ping 127.0.0.1 -c 1 || sleep .001 || usleep 1 || sleep 1 } if [ ! -f set_event -o ! -d events/sched ]; thentools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc +1
-1@@ -14,7 +14,7 @@ fail() { #msg } yield() { - ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 + ping 127.0.0.1 -c 1 || sleep .001 || usleep 1 || sleep 1 } if [ ! -f set_event -o ! -d events/sched ]; thentools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc +1
-1@@ -13,7 +13,7 @@ fail() { #msg } yield() { - ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 + ping 127.0.0.1 -c 1 || sleep .001 || usleep 1 || sleep 1 } if [ ! -f available_events -o ! -f set_event -o ! -d events ]; thentools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc +0
-0
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc fail() { # msg · line 53
Quoted 6 lines
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc +1
-1@@ -49,7 +49,7 @@ fail() { # msg } yield() { - ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 + ping 127.0.0.1 -c 1 || sleep .001 || usleep 1 || sleep 1 }
Perhaps we should make this a helper function since it's used so much.
Quoted 59 lines
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc +0
-0do_test() {tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc +1
-1@@ -23,7 +23,7 @@ echo 'hist:keys=comm:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/ echo 'hist:keys=next_comm:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,next_pid,sched.sched_waking.prio,next_comm) if next_comm=="ping"' > events/sched/sched_switch/trigger echo 'hist:keys=pid,prio,comm:vals=lat:sort=pid,prio' > events/synthetic/wakeup_latency/trigger -ping localhost -c 3 +ping 127.0.0.1 -c 3 if ! grep -q "ping" events/synthetic/wakeup_latency/hist; then fail "Failed to create inter-event histogram" fitools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc +1
-1@@ -37,7 +37,7 @@ echo 'waking+wakeup_latency u64 lat; pid_t pid' >> synthetic_events echo 'hist:keys=pid,lat:sort=pid,lat:ww_lat=$waking_lat+$wakeup_lat:onmatch(synthetic.wakeup_latency).waking+wakeup_latency($ww_lat,pid)' >> events/synthetic/wakeup_latency/trigger echo 'hist:keys=pid,lat:sort=pid,lat' >> events/synthetic/waking+wakeup_latency/trigger -ping localhost -c 3 +ping 127.0.0.1 -c 3 if ! grep -q "pid:" events/synthetic/waking+wakeup_latency/hist; then fail "Failed to create combined histogram" fitools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc +1
-1@@ -29,7 +29,7 @@ echo "Test histogram variables,simple expression support and onmatch action" echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_wakeup/trigger echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_wakeup).wakeup_latency($wakeup_lat,next_pid,next_comm) if next_comm=="ping"' > events/sched/sched_switch/trigger echo 'hist:keys=comm,pid,lat:wakeup_lat=lat:sort=lat' > events/synthetic/wakeup_latency/trigger -ping localhost -c 5 +ping 127.0.0.1 -c 5 if ! grep -q "ping" events/synthetic/wakeup_latency/hist; then fail "Failed to create onmatch action inter-event histogram" fitools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc +1
-1@@ -29,7 +29,7 @@ echo "Test histogram variables,simple expression support and onmatch-onmax actio echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_wakeup/trigger echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_wakeup).wakeup_latency($wakeup_lat,next_pid,next_comm):onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) if next_comm=="ping"' >> events/sched/sched_switch/trigger echo 'hist:keys=comm,pid,lat:wakeup_lat=lat:sort=lat' > events/synthetic/wakeup_latency/trigger -ping localhost -c 5 +ping 127.0.0.1 -c 5 if [ ! grep -q "ping" events/synthetic/wakeup_latency/hist -o ! grep -q "max:" events/sched/sched_switch/hist]; then fail "Failed to create onmatch-onmax action inter-event histogram" fitools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc +0
-0
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc echo "Test onmax action" · line 30
Quoted 5 lines
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc +1
-1@@ -27,7 +27,7 @@ echo "Test onmax action" echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' >> events/sched/sched_waking/trigger echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) if next_comm=="ping"' >> events/sched/sched_switch/trigger -ping localhost -c 3 +ping 127.0.0.1 -c 3
Perhaps we should also add a variable LOCALHOST="127.0.0.1" and use that. I rather not have the raw address all over the place, in case we want to change its meaning, it's best to do it in one place.
-- Steve
Quoted 3 lines
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc +0
-0if ! grep -q "max:" events/sched/sched_switch/hist; then fail "Failed to create onmax action inter-event histogram" fi
Masami Hiramatsu
maintainerRe: [PATCH v2 11/32] selftests/ftrace: Use loopback address instead of localhost
Quoted 80 lines · On Fri, 24 Aug 2018 17:52:11 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 77 lines · On Fri, 17 Aug 2018 01:34:23 +0900 Masami Hiramatsu <[email protected]> wrote:
Use raw loopback address instead of localhost, because "localhost" can depend on nsswitch and in some case we can not resolve the localhost.
Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../selftests/ftrace/test.d/event/event-enable.tc | 2 +- .../selftests/ftrace/test.d/event/event-pid.tc | 2 +- .../ftrace/test.d/event/subsystem-enable.tc | 2 +- .../ftrace/test.d/event/toplevel-enable.tc | 2 +- .../ftrace/test.d/ftrace/func-filter-pid.tc | 2 +- .../inter-event/trigger-field-variable-support.tc | 2 +- .../trigger-inter-event-combined-hist.tc | 2 +- .../inter-event/trigger-onmatch-action-hist.tc | 2 +- .../trigger-onmatch-onmax-action-hist.tc | 2 +- .../inter-event/trigger-onmax-action-hist.tc | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-)tools/testing/selftests/ftrace/test.d/event/event-enable.tc +1
-1@@ -14,7 +14,7 @@ fail() { #msg } yield() { - ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 + ping 127.0.0.1 -c 1 || sleep .001 || usleep 1 || sleep 1 } if [ ! -f set_event -o ! -d events/sched ]; thentools/testing/selftests/ftrace/test.d/event/event-pid.tc +1
-1@@ -17,7 +17,7 @@ fail() { #msg } yield() { - ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 + ping 127.0.0.1 -c 1 || sleep .001 || usleep 1 || sleep 1 } if [ ! -f set_event -o ! -d events/sched ]; thentools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc +1
-1@@ -14,7 +14,7 @@ fail() { #msg } yield() { - ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 + ping 127.0.0.1 -c 1 || sleep .001 || usleep 1 || sleep 1 } if [ ! -f set_event -o ! -d events/sched ]; thentools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc +1
-1@@ -13,7 +13,7 @@ fail() { #msg } yield() { - ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 + ping 127.0.0.1 -c 1 || sleep .001 || usleep 1 || sleep 1 } if [ ! -f available_events -o ! -f set_event -o ! -d events ]; thentools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc +0
-0@@ -49,7 +49,7 @@ fail() { # msg }
Quoted 6 lines
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc fail() { # msg · line 53
Quoted 4 lines
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc +1
-1yield() { - ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 + ping 127.0.0.1 -c 1 || sleep .001 || usleep 1 || sleep 1 }Perhaps we should make this a helper function since it's used so much.
Yeah, agree. OK, I'll add a patch to move it in common place.
Quoted 61 lines
Quoted 61 lines
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc +0
-0do_test() {tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc +1
-1@@ -23,7 +23,7 @@ echo 'hist:keys=comm:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/ echo 'hist:keys=next_comm:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,next_pid,sched.sched_waking.prio,next_comm) if next_comm=="ping"' > events/sched/sched_switch/trigger echo 'hist:keys=pid,prio,comm:vals=lat:sort=pid,prio' > events/synthetic/wakeup_latency/trigger -ping localhost -c 3 +ping 127.0.0.1 -c 3 if ! grep -q "ping" events/synthetic/wakeup_latency/hist; then fail "Failed to create inter-event histogram" fitools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc +1
-1@@ -37,7 +37,7 @@ echo 'waking+wakeup_latency u64 lat; pid_t pid' >> synthetic_events echo 'hist:keys=pid,lat:sort=pid,lat:ww_lat=$waking_lat+$wakeup_lat:onmatch(synthetic.wakeup_latency).waking+wakeup_latency($ww_lat,pid)' >> events/synthetic/wakeup_latency/trigger echo 'hist:keys=pid,lat:sort=pid,lat' >> events/synthetic/waking+wakeup_latency/trigger -ping localhost -c 3 +ping 127.0.0.1 -c 3 if ! grep -q "pid:" events/synthetic/waking+wakeup_latency/hist; then fail "Failed to create combined histogram" fitools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc +1
-1@@ -29,7 +29,7 @@ echo "Test histogram variables,simple expression support and onmatch action" echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_wakeup/trigger echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_wakeup).wakeup_latency($wakeup_lat,next_pid,next_comm) if next_comm=="ping"' > events/sched/sched_switch/trigger echo 'hist:keys=comm,pid,lat:wakeup_lat=lat:sort=lat' > events/synthetic/wakeup_latency/trigger -ping localhost -c 5 +ping 127.0.0.1 -c 5 if ! grep -q "ping" events/synthetic/wakeup_latency/hist; then fail "Failed to create onmatch action inter-event histogram" fitools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc +1
-1@@ -29,7 +29,7 @@ echo "Test histogram variables,simple expression support and onmatch-onmax actio echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_wakeup/trigger echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_wakeup).wakeup_latency($wakeup_lat,next_pid,next_comm):onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) if next_comm=="ping"' >> events/sched/sched_switch/trigger echo 'hist:keys=comm,pid,lat:wakeup_lat=lat:sort=lat' > events/synthetic/wakeup_latency/trigger -ping localhost -c 5 +ping 127.0.0.1 -c 5 if [ ! grep -q "ping" events/synthetic/wakeup_latency/hist -o ! grep -q "max:" events/sched/sched_switch/hist]; then fail "Failed to create onmatch-onmax action inter-event histogram" fitools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc +0
-0@@ -27,7 +27,7 @@ echo "Test onmax action"
Quoted 8 lines
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc echo "Test onmax action" · line 30
Quoted 4 lines
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc +1
-1echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' >> events/sched/sched_waking/trigger echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) if next_comm=="ping"' >> events/sched/sched_switch/trigger -ping localhost -c 3 +ping 127.0.0.1 -c 3Perhaps we should also add a variable LOCALHOST="127.0.0.1" and use that. I rather not have the raw address all over the place, in case we want to change its meaning, it's best to do it in one place.
Agreed. That should be moved in the common place too.
Thank you,
Quoted 7 lines
-- Steve
Quoted 3 lines
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc +0
-0if ! grep -q "max:" events/sched/sched_switch/hist; then fail "Failed to create onmax action inter-event histogram" fi
Signature · 1 line
Masami Hiramatsu <mhiramat at kernel.org>
Masami Hiramatsu
maintainerPATCH v2 12/32 selftests/ftrace: Improve kprobe on module testcase to load/unload module
In reply to Masami HiramatsuImprove kprobe events on module testcase to check module load/unload with disabled/enabled events. This also change the target module to trace_printk.ko, so it depends on CONFIG_SAMPLE_TRACE_PRINTK=m.
--- tools/testing/selftests/ftrace/config | 4 ++ .../ftrace/test.d/kprobe/kprobe_module.tc | 35 ++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-)
tools/testing/selftests/ftrace/config +4 -0
@@ -7,3 +7,7 @@ CONFIG_HIST_TRIGGERS=y CONFIG_PREEMPT_TRACER=y CONFIG_IRQSOFF_TRACER=y CONFIG_PREEMPTIRQ_DELAY_TEST=m +CONFIG_MODULES=y +CONFIG_MODULE_UNLOAD=y +CONFIG_SAMPLES=y +CONFIG_SAMPLE_TRACE_PRINTK=m
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc +32 -3
@@ -4,11 +4,18 @@ [ -f kprobe_events ] || exit_unsupported # this is configurable +rmmod trace-printk ||: +if ! modprobe trace-printk.ko ; then + echo "No trace-printk sample module - please make CONFIG_SAMPLE_TRACE_PRINTK= +m" + exit_unresolved; +fi + +MOD=trace_printk +FUNC=trace_printk_irq_work + :;: "Add an event on a module function without specifying event name" ;: -MOD=`lsmod | head -n 2 | tail -n 1 | cut -f1 -d" "` -FUNC=`grep -m 1 ".* t .*\\[$MOD\\]" /proc/kallsyms | xargs | cut -f3 -d" "` -[ "x" != "x$MOD" -a "y" != "y$FUNC" ] || exit_unresolved echo "p $MOD:$FUNC" > kprobe_events PROBE_NAME=`echo $MOD:$FUNC | tr ".:" "_"` test -d events/kprobes/p_${PROBE_NAME}_0 || exit_failure
@@ -22,3 +29,25 @@ test -d events/kprobes/event1 || exit_failure echo "p:kprobes1/event1 $MOD:$FUNC" > kprobe_events test -d events/kprobes1/event1 || exit_failure + +:;: "Remove target module, but event still be there" ;: +if ! rmmod trace-printk ; then + echo "Failed to unload module - please enable CONFIG_MODULE_UNLOAD" + exit_unresolved; +fi +test -d events/kprobes1/event1 + +:;: "Check posibility to defining events on unloaded module";: +echo "p:event2 $MOD:$FUNC" >> kprobe_events + +:;: "Target is gone, but we can prepare for next time";: +echo 1 > events/kprobes1/event1/enable + +:;: "Load module again, which means the event1 should be recorded";: +modprobe trace-printk.ko +grep "event1:" trace + +:;: "Remove the module again and check the event is not locked" +rmmod trace-printk +echo 0 > events/kprobes1/event1/enable +echo "-:kprobes1/event1" >> kprobe_events
Steven Rostedt
maintainerRe: [PATCH v2 12/32] selftests/ftrace: Improve kprobe on module testcase to load/unload module
Quoted 28 lines · On Fri, 17 Aug 2018 01:34:51 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Improve kprobe events on module testcase to check module load/unload with disabled/enabled events. This also change the target module to trace_printk.ko, so it depends on
CONFIG_SAMPLE_TRACE_PRINTK=m.Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- tools/testing/selftests/ftrace/config | 4 ++ .../ftrace/test.d/kprobe/kprobe_module.tc | 35 ++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-)tools/testing/selftests/ftrace/config +4
-0@@ -7,3 +7,7 @@ CONFIG_HIST_TRIGGERS=y CONFIG_PREEMPT_TRACER=y CONFIG_IRQSOFF_TRACER=y CONFIG_PREEMPTIRQ_DELAY_TEST=m +CONFIG_MODULES=y +CONFIG_MODULE_UNLOAD=y +CONFIG_SAMPLES=y +CONFIG_SAMPLE_TRACE_PRINTK=mtools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc +0
-0
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc line 8
Quoted 5 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc +2
-0@@ -4,11 +4,18 @@ [ -f kprobe_events ] || exit_unsupported # this is configurable +rmmod trace-printk ||: +if ! modprobe trace-printk.ko ; then
"modprobe trace-printk.ko" dosen't work. You need to drop the .ko
Quoted 26 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc +14
-3+ echo "No trace-printk sample module - please make CONFIG_SAMPLE_TRACE_PRINTK= +m" + exit_unresolved; +fi + +MOD=trace_printk +FUNC=trace_printk_irq_work + :;: "Add an event on a module function without specifying event name" ;: -MOD=`lsmod | head -n 2 | tail -n 1 | cut -f1 -d" "` -FUNC=`grep -m 1 ".* t .*\\[$MOD\\]" /proc/kallsyms | xargs | cut -f3 -d" "` -[ "x" != "x$MOD" -a "y" != "y$FUNC" ] || exit_unresolved echo "p $MOD:$FUNC" > kprobe_events PROBE_NAME=`echo $MOD:$FUNC | tr ".:" "_"` test -d events/kprobes/p_${PROBE_NAME}_0 || exit_failure@@ -22,3 +29,25 @@ test -d events/kprobes/event1 || exit_failure echo "p:kprobes1/event1 $MOD:$FUNC" > kprobe_events test -d events/kprobes1/event1 || exit_failure + +:;: "Remove target module, but event still be there" ;: +if ! rmmod trace-printk ; then + echo "Failed to unload module - please enable CONFIG_MODULE_UNLOAD" + exit_unresolved; +fi
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc test -d events/kprobes/event1 || exit_failure · line 47
Quoted 10 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc +10
-0+test -d events/kprobes1/event1 + +:;: "Check posibility to defining events on unloaded module";: +echo "p:event2 $MOD:$FUNC" >> kprobe_events + +:;: "Target is gone, but we can prepare for next time";: +echo 1 > events/kprobes1/event1/enable + +:;: "Load module again, which means the event1 should be recorded";: +modprobe trace-printk.ko
Same here.
-- Steve
Quoted 6 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc +6
-0+grep "event1:" trace + +:;: "Remove the module again and check the event is not locked" +rmmod trace-printk +echo 0 > events/kprobes1/event1/enable +echo "-:kprobes1/event1" >> kprobe_events
Masami Hiramatsu
maintainerPATCH v2 13/32 selftests/ftrace: Improve kprobe testcase to check log data
In reply to Masami HiramatsuImprove kprobe testcase to check the log data correctness and ensure the event definition is corrctly including argument definition.
--- .../selftests/ftrace/test.d/kprobe/kprobe_args.tc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc +5 -1
@@ -5,10 +5,14 @@ [ -f kprobe_events ] || exit_unsupported # this is configurable echo 'p:testprobe _do_fork $stack $stack0 +0($stack)' > kprobe_events -grep testprobe kprobe_events +grep testprobe kprobe_events | grep -q 'arg1=\$stack arg2=\$stack0 arg3=+0(\$stack)' test -d events/kprobes/testprobe + echo 1 > events/kprobes/testprobe/enable ( echo "forked") +grep testprobe trace | grep '_do_fork' | \ + grep -q 'arg1=0x[[:xdigit:]]* arg2=0x[[:xdigit:]]* arg3=0x[[:xdigit:]]*$' + echo 0 > events/kprobes/testprobe/enable echo "-:testprobe" >> kprobe_events clear_trace
Masami Hiramatsu
maintainerPATCH v2 14/32 selftests/ftrace: Improve kretprobe testcase to check log data
In reply to Masami HiramatsuImprove kretprobe testcase to check the log data correctness and ensure the event definition is corrctly including argument definition.
--- .../ftrace/test.d/kprobe/kretprobe_args.tc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc +6 -1
@@ -4,11 +4,16 @@ [ -f kprobe_events ] || exit_unsupported # this is configurable +# Add new kretprobe event echo 'r:testprobe2 _do_fork $retval' > kprobe_events -grep testprobe2 kprobe_events +grep testprobe2 kprobe_events | grep -q 'arg1=\$retval' test -d events/kprobes/testprobe2 + echo 1 > events/kprobes/testprobe2/enable ( echo "forked") + +cat trace | grep testprobe2 | grep -q '<- _do_fork' + echo 0 > events/kprobes/testprobe2/enable echo '-:testprobe2' >> kprobe_events clear_trace
Masami Hiramatsu
maintainerPATCH v2 15/32 selftests/ftrace: Test kprobe-event argument with various bitsize
In reply to Masami HiramatsuImprove the kprobe-event with argument types testcase to test it with various bitsize.
kprobe-event argument can be recorded in given types with various bitsize (8, 16, 32, 64), thus the type testcase should test the different bitsize too.
--- .../ftrace/test.d/kprobe/kprobe_args_type.tc | 48 +++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc +32 -16
@@ -6,29 +6,45 @@ grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue -echo 'p:testprobe _do_fork $stack0:s32 $stack0:u32 $stack0:x32 $stack0:b8 at 4/32' > kprobe_events -grep testprobe kprobe_events -test -d events/kprobes/testprobe - -echo 1 > events/kprobes/testprobe/enable -( echo "forked") -echo 0 > events/kprobes/testprobe/enable -ARGS=`tail -n 1 trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'` +gen_event() { # Bitsize + echo "p:testprobe _do_fork \$stack0:s$1 \$stack0:u$1 \$stack0:x$1 \$stack0:b4 at 4/$1" +} -check_types() { - X1=`printf "%x" $1 | tail -c 8` +check_types() { # s-type u-type x-type bf-type width + test $# -eq 5 + CW=$5 + CW=$((CW / 4)) + X1=`printf "%x" $1 | tail -c ${CW}` X2=`printf "%x" $2` X3=`printf "%x" $3` test $X1 = $X2 test $X2 = $X3 test 0x$X3 = $3 - B4=`printf "%02x" $4` - B3=`echo -n $X3 | tail -c 3 | head -c 2` + B4=`printf "%1x" $4` + B3=`printf "%03x" 0x$X3 | tail -c 2 | head -c 1` test $B3 = $B4 } -check_types $ARGS -echo "-:testprobe" >> kprobe_events -clear_trace -test -d events/kprobes/testprobe && exit_fail || exit_pass +for width in 64 32 16 8; do + : "Add new event with basic types" + gen_event $width > kprobe_events + grep testprobe kprobe_events + test -d events/kprobes/testprobe + + : "Trace the event" + echo 1 > events/kprobes/testprobe/enable + ( echo "forked") + echo 0 > events/kprobes/testprobe/enable + + : "Confirm the arguments is recorded in given types correctly" + ARGS=`grep "testprobe" trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'` + check_types $ARGS $width + + : "Clear event for next loop" + echo "-:testprobe" >> kprobe_events + clear_trace + +done + +exit_pass
Masami Hiramatsu
maintainerPATCH v2 16/32 selftests/ftrace: Check set_event_pid result
In reply to Masami HiramatsuEnsure the set_event_pid shows set pid list.
--- .../selftests/ftrace/test.d/event/event-pid.tc | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/ftrace/test.d/event/event-pid.tc +1 -0
@@ -46,6 +46,7 @@ do_reset read mypid rest < /proc/self/stat echo $mypid > set_event_pid +grep -q $mypid set_event_pid echo 'sched:sched_switch' > set_event yield
Masami Hiramatsu
maintainerPATCH v2 17/32 selftests/ftrace: Add kprobe event with $comm argument testcase
In reply to Masami HiramatsuAdd kprobe-event with $comm argument testcase to
ftracetest. This not only checks syntax but
also checks log file.
--- .../ftrace/test.d/kprobe/kprobe_args_comm.tc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_comm.tc
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_comm.tc new file +17 -0
@@ -0,0 +1,17 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Kprobe event with comm arguments + +[ -f kprobe_events ] || exit_unsupported # this is configurable + +grep -A1 "fetcharg:" README | grep -q "\$comm" || exit_unsupported # this is too old + +echo 'p:testprobe _do_fork comm=$comm ' > kprobe_events +grep testprobe kprobe_events | grep -q 'comm=$comm' +test -d events/kprobes/testprobe + +echo 1 > events/kprobes/testprobe/enable +( echo "forked") +grep testprobe trace | grep -q 'comm=".*"' + +exit 0
Masami Hiramatsu
maintainerPATCH v2 18/32 selftests/ftrace: Add kprobe profile testcase
In reply to Masami HiramatsuAdd a testcase for testing kprobe_profile interface which provides per-kprobe event hit/misshit counts.
--- .../selftests/ftrace/test.d/kprobe/profile.tc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/profile.tc
tools/testing/selftests/ftrace/test.d/kprobe/profile.tc new file +15 -0
@@ -0,0 +1,15 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Kprobe dynamic event - adding and removing + +[ -f kprobe_events ] || exit_unsupported # this is configurable + +! grep -q 'myevent' kprobe_profile +echo p:myevent _do_fork > kprobe_events +grep -q 'myevent[[:space:]]*0[[:space:]]*0$' kprobe_profile +echo 1 > events/kprobes/myevent/enable +( echo "forked" ) +grep -q 'myevent[[:space:]]*[[:digit:]]*[[:space:]]*0$' kprobe_profile +echo 0 > events/kprobes/myevent/enable +echo > kprobe_events +! grep -q 'myevent' kprobe_profile
Masami Hiramatsu
maintainerPATCH v2 19/32 selftests/ftrace: Add a testcase for nop tracer
In reply to Masami HiramatsuAdd a testcase for nop tracer. This tracer has 2 test options, so check it too.
--- .../testing/selftests/ftrace/test.d/tracer/nop.tc | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/tracer/nop.tc
tools/testing/selftests/ftrace/test.d/tracer/nop.tc new file +22 -0
@@ -0,0 +1,22 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Test nop tracer + +# nop must be supported always +grep -q "nop" available_tracers + +echo "nop" > current_tracer + +# nop provides 2 test options +grep -q "test_nop_accept" trace_options +grep -q "test_nop_refuse" trace_options + +# nop_accept always success +echo "test_nop_accept" > trace_options +echo "notest_nop_accept" > trace_options + +# nop_refuse always failed +! echo "test_nop_refuse" > trace_options +! echo "notest_nop_refuse" > trace_options + +exit 0
Steven Rostedt
maintainerRe: [PATCH v2 19/32] selftests/ftrace: Add a testcase for nop tracer
Quoted 3 lines · On Fri, 17 Aug 2018 01:38:09 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Add a testcase for nop tracer. This tracer has 2 test options, so check it too.
I'd rather not include this. In fact, I'd love to get rid of the nop options. They were added to make sure options worked when we first added them. They are actually pointless.
The only point of this test is to know if options work or not. Hmm, I guess that is something that could possibly be valuable :-/
-- Steve
Quoted 34 lines
Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../testing/selftests/ftrace/test.d/tracer/nop.tc | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/tracer/nop.tctools/testing/selftests/ftrace/test.d/tracer/nop.tc new file +22
-0@@ -0,0 +1,22 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Test nop tracer + +# nop must be supported always +grep -q "nop" available_tracers + +echo "nop" > current_tracer + +# nop provides 2 test options +grep -q "test_nop_accept" trace_options +grep -q "test_nop_refuse" trace_options + +# nop_accept always success +echo "test_nop_accept" > trace_options +echo "notest_nop_accept" > trace_options + +# nop_refuse always failed +! echo "test_nop_refuse" > trace_options +! echo "notest_nop_refuse" > trace_options + +exit 0
Masami Hiramatsu
maintainerRe: [PATCH v2 19/32] selftests/ftrace: Add a testcase for nop tracer
Quoted 10 lines · On Fri, 24 Aug 2018 18:53:42 -0400 Steven Rostedt <rostedt at goodmis.org>…
Quoted 3 lines · On Fri, 17 Aug 2018 01:38:09 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Add a testcase for nop tracer. This tracer has 2 test options, so check it too.
I'd rather not include this. In fact, I'd love to get rid of the nop options. They were added to make sure options worked when we first added them. They are actually pointless.
Got it. I was thinking it was an odd option when I was writing a test. :)
Quoted 2 lines
The only point of this test is to know if options work or not. Hmm, I guess that is something that could possibly be valuable :-/
Actually setting "nop" is already done in basic testcase. So I think we can just drop this test.
Thank you,
Quoted 38 lines
-- Steve
Quoted 34 lines
Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../testing/selftests/ftrace/test.d/tracer/nop.tc | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/tracer/nop.tctools/testing/selftests/ftrace/test.d/tracer/nop.tc new file +22
-0@@ -0,0 +1,22 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Test nop tracer + +# nop must be supported always +grep -q "nop" available_tracers + +echo "nop" > current_tracer + +# nop provides 2 test options +grep -q "test_nop_accept" trace_options +grep -q "test_nop_refuse" trace_options + +# nop_accept always success +echo "test_nop_accept" > trace_options +echo "notest_nop_accept" > trace_options + +# nop_refuse always failed +! echo "test_nop_refuse" > trace_options +! echo "notest_nop_refuse" > trace_options + +exit 0
Signature · 1 line
Masami Hiramatsu <mhiramat at kernel.org>
Masami Hiramatsu
maintainerPATCH v2 20/32 selftests/ftrace: Add kprobe-event with symbol argument test
In reply to Masami HiramatsuAdd a testcase for kprobe-event with @symbol argument. Since @symbol needs to refer the kernel data symbol (linux_proc_banner), it requires CONFIG_KALLSYMS_ALL.
--- tools/testing/selftests/ftrace/config | 1 + .../ftrace/test.d/kprobe/kprobe_args_symbol.tc | 39 ++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_symbol.tc
tools/testing/selftests/ftrace/config +1 -0
@@ -11,3 +11,4 @@ CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y CONFIG_SAMPLES=y CONFIG_SAMPLE_TRACE_PRINTK=m +CONFIG_KALLSYMS_ALL=y
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_symbol.tc new file +39 -0
@@ -0,0 +1,39 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Kprobe event symbol argument + +[ -f kprobe_events ] || exit_unsupported # this is configurable + +SYMBOL="linux_proc_banner" + +if [ ! -f /proc/kallsyms ]; then + echo "Can not check the target symbol - please enable CONFIG_KALLSYMS" + exit_unresolved +elif ! grep "$SYMBOL\$" /proc/kallsyms; then + echo "Linux banner is not exported - please enable CONFIG_KALLSYMS_ALL" + exit_unresolved +fi + +: "Test get basic types symbol argument" +echo "p:testprobe_u _do_fork arg1=@linux_proc_banner:u64 arg2=@linux_proc_banner:u32 arg3=@linux_proc_banner:u16 arg4=@linux_proc_banner:u8" > kprobe_events +echo "p:testprobe_s _do_fork arg1=@linux_proc_banner:s64 arg2=@linux_proc_banner:s32 arg3=@linux_proc_banner:s16 arg4=@linux_proc_banner:s8" >> kprobe_events +if grep -q "x8/16/32/64" README; then + echo "p:testprobe_x _do_fork arg1=@linux_proc_banner:x64 arg2=@linux_proc_banner:x32 arg3=@linux_proc_banner:x16 arg4=@linux_proc_banner:x8" >> kprobe_events +fi +echo "p:testprobe_bf _do_fork arg1=@linux_proc_banner:b8 at 4/32" >> kprobe_events +echo 1 > events/kprobes/enable +(echo "forked") +echo 0 > events/kprobes/enable +grep "testprobe_[usx]:.* arg1=.* arg2=.* arg3=.* arg4=.*" trace +grep "testprobe_bf:.* arg1=.*" trace + +: "Test get string symbol argument" +echo "p:testprobe_str _do_fork arg1=@linux_proc_banner:string" > kprobe_events +echo 1 > events/kprobes/enable +(echo "forked") +echo 0 > events/kprobes/enable +RESULT=`grep "testprobe_str" trace | sed -e 's/.* arg1=\(.*\)/\1/'` + +RESULT=`echo $RESULT | sed -e 's/.* \((.*)\) \((.*)\) .*/\1 \2/'` +ORIG=`cat /proc/version | sed -e 's/.* \((.*)\) \((.*)\) .*/\1 \2/'` +test "$RESULT" = "$ORIG"
Masami Hiramatsu
maintainerPATCH v2 21/32 selftests/ftrace: Add trace_printk sample module test
In reply to Masami HiramatsuAdd trace_printk sample module test. This requires to enable trace_printk.ko module for test.
--- .../selftests/ftrace/test.d/event/trace_printk.tc | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/event/trace_printk.tc
tools/testing/selftests/ftrace/test.d/event/trace_printk.tc new file +27 -0
@@ -0,0 +1,27 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Test trace_printk from module + +rmmod trace-printk ||: +if ! modprobe trace-printk.ko ; then + echo "No trace-printk sample module - please make CONFIG_SAMPLE_TRACE_PRINTK=m" + exit_unresolved; +fi + +echo "Waiting for irq work" +sleep 1 + +grep -q ": This .* trace_bputs" trace +grep -q ": This .* trace_puts" trace +grep -q ": This .* trace_bprintk" trace +grep -q ": This .* trace_printk" trace + +grep -q ": (irq) .* trace_bputs" trace +grep -q ": (irq) .* trace_puts" trace +grep -q ": (irq) .* trace_bprintk" trace +grep -q ": (irq) .* trace_printk" trace + +grep -q "This is a %s that will use trace_bprintk" printk_formats +grep -q "(irq) This is a static string that will use trace_bputs" printk_formats + +rmmod trace-printk ||:
Steven Rostedt
maintainerRe: [PATCH v2 21/32] selftests/ftrace: Add trace_printk sample module test
Quoted 15 lines · On Fri, 17 Aug 2018 01:39:06 +0900 Masami Hiramatsu <[email protected]> wrote:
Add
trace_printksample module test. This requires to enable trace_printk.ko module for test.Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../selftests/ftrace/test.d/event/trace_printk.tc | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/event/trace_printk.tctools/testing/selftests/ftrace/test.d/event/trace_printk.tc new file +0
-0
tools/testing/selftests/ftrace/test.d/event/trace_printk.tc line 6
Quoted 6 lines
tools/testing/selftests/ftrace/test.d/event/trace_printk.tc new file +6
-0@@ -0,0 +1,27 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Test trace_printk from module + +rmmod trace-printk ||: +if ! modprobe trace-printk.ko ; then
"modprobe trace-printk.ko" doesn't work. You need to drop the ".ko"
-- Steve
Quoted 21 lines
tools/testing/selftests/ftrace/test.d/event/trace_printk.tc new file +21
-0+ echo "No trace-printk sample module - please make CONFIG_SAMPLE_TRACE_PRINTK=m" + exit_unresolved; +fi + +echo "Waiting for irq work" +sleep 1 + +grep -q ": This .* trace_bputs" trace +grep -q ": This .* trace_puts" trace +grep -q ": This .* trace_bprintk" trace +grep -q ": This .* trace_printk" trace + +grep -q ": (irq) .* trace_bputs" trace +grep -q ": (irq) .* trace_puts" trace +grep -q ": (irq) .* trace_bprintk" trace +grep -q ": (irq) .* trace_printk" trace + +grep -q "This is a %s that will use trace_bprintk" printk_formats +grep -q "(irq) This is a static string that will use trace_bputs" printk_formats + +rmmod trace-printk ||:
Masami Hiramatsu
maintainerRe: [PATCH v2 21/32] selftests/ftrace: Add trace_printk sample module test
Quoted 12 lines · On Fri, 24 Aug 2018 19:06:21 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 9 lines · On Fri, 17 Aug 2018 01:39:06 +0900 Masami Hiramatsu <[email protected]> wrote:
Add
trace_printksample module test. This requires to enable trace_printk.ko module for test.Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../selftests/ftrace/test.d/event/trace_printk.tc | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/event/trace_printk.tc
Quoted 14 lines
tools/testing/selftests/ftrace/test.d/event/trace_printk.tc line 6
Quoted 12 lines
tools/testing/selftests/ftrace/test.d/event/trace_printk.tc new file +6
-0@@ -0,0 +1,27 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Test trace_printk from module + +rmmod trace-printk ||: +if ! modprobe trace-printk.ko ; then"modprobe trace-printk.ko" doesn't work. You need to drop the ".ko"
Ah, I'm using busybox's modprobe, which acccepts .ko :(
I'll fix that.
Thanks!
Quoted 25 lines
-- Steve
Quoted 21 lines
tools/testing/selftests/ftrace/test.d/event/trace_printk.tc new file +21
-0+ echo "No trace-printk sample module - please make CONFIG_SAMPLE_TRACE_PRINTK=m" + exit_unresolved; +fi + +echo "Waiting for irq work" +sleep 1 + +grep -q ": This .* trace_bputs" trace +grep -q ": This .* trace_puts" trace +grep -q ": This .* trace_bprintk" trace +grep -q ": This .* trace_printk" trace + +grep -q ": (irq) .* trace_bputs" trace +grep -q ": (irq) .* trace_puts" trace +grep -q ": (irq) .* trace_bprintk" trace +grep -q ": (irq) .* trace_printk" trace + +grep -q "This is a %s that will use trace_bprintk" printk_formats +grep -q "(irq) This is a static string that will use trace_bputs" printk_formats + +rmmod trace-printk ||:
Signature · 1 line
Masami Hiramatsu <mhiramat at kernel.org>
Masami Hiramatsu
maintainerPATCH v2 22/32 selftests/ftrace: Add ringbuffer size changing testcase
In reply to Masami HiramatsuAdd a testcase for changing ringbuffer size. This tests not only ringbuffer size but also tests the imbalance per-cpu buffer size change too.
--- .../ftrace/test.d/00basic/ringbuffer_size.tc | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc
tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc new file +21 -0
@@ -0,0 +1,21 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Change the ringbuffer size + +rb_size_test() { +ORIG=`cat buffer_size_kb` + +expr $ORIG / 2 > buffer_size_kb + +expr $ORIG \* 2 > buffer_size_kb + +echo $ORIG > buffer_size_kb +} + +rb_size_test + +: "If per-cpu buffer is supported, imbalance it" +if [ -d per_cpu/cpu0 ]; then + cd per_cpu/cpu0 + rb_size_test +fi
Re: [PATCH v2 22/32] selftests/ftrace: Add ringbuffer size changing testcase
Quoted 5 lines · On Fri, 17 Aug 2018 01:39:34 +0900 Masami Hiramatsu <[email protected]> wrote:
Add a testcase for changing ringbuffer size. This tests not only ringbuffer size but also tests the imbalance per-cpu buffer size change too.
Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>
I'm fine with this, but one day I need to port over some of my other tests. I have a test that stresses the ring buffer size (basically checks to see if it can cause an oom). I need to port that to selftests. But for now...
But, one more thing..
Quoted 11 lines
--- .../ftrace/test.d/00basic/ringbuffer_size.tc | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tctools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc new file +0
-0
tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc line 3
Quoted 3 lines
tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc new file +3
-0@@ -0,0 +1,21 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Change the ringbuffer size
Should add:
# flags: instance
As this works for instances as well.
-- Steve
Quoted 18 lines
tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc new file +18
-0+ +rb_size_test() { +ORIG=`cat buffer_size_kb` + +expr $ORIG / 2 > buffer_size_kb + +expr $ORIG \* 2 > buffer_size_kb + +echo $ORIG > buffer_size_kb +} + +rb_size_test + +: "If per-cpu buffer is supported, imbalance it" +if [ -d per_cpu/cpu0 ]; then + cd per_cpu/cpu0 + rb_size_test +fi
Masami Hiramatsu
maintainerRe: [PATCH v2 22/32] selftests/ftrace: Add ringbuffer size changing testcase
Quoted 7 lines · On Fri, 24 Aug 2018 19:18:36 -0400 Steven Rostedt <rostedt at goodmis.org>…
Quoted 4 lines · On Fri, 17 Aug 2018 01:39:34 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Add a testcase for changing ringbuffer size. This tests not only ringbuffer size but also tests the imbalance per-cpu buffer size change too.
Quoted 6 lines
Quoted 1 line
Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>I'm fine with this, but one day I need to port over some of my other tests. I have a test that stresses the ring buffer size (basically checks to see if it can cause an oom). I need to port that to selftests. But for now...
Hmm, such stress test is not good for kselftest, since it can cause oom and kill some test process. Maybe we should have such stresstest framework (which allows test to crash kernel)
Quoted 22 lines
Acked-by Steven Rostedt (VMware) <rostedt at goodmis.org>But, one more thing..
Quoted 11 lines
--- .../ftrace/test.d/00basic/ringbuffer_size.tc | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tctools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc new file +0
-0tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc line 3
Quoted 3 lines
tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc new file +3
-0@@ -0,0 +1,21 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Change the ringbuffer sizeShould add:
Quoted 1 line
# flags: instance
OK, I'll add it.
Thank you!
Quoted 24 lines
As this works for instances as well.
-- Steve
Quoted 18 lines
tools/testing/selftests/ftrace/test.d/00basic/ringbuffer_size.tc new file +18
-0+ +rb_size_test() { +ORIG=`cat buffer_size_kb` + +expr $ORIG / 2 > buffer_size_kb + +expr $ORIG \* 2 > buffer_size_kb + +echo $ORIG > buffer_size_kb +} + +rb_size_test + +: "If per-cpu buffer is supported, imbalance it" +if [ -d per_cpu/cpu0 ]; then + cd per_cpu/cpu0 + rb_size_test +fi
Signature · 1 line
Masami Hiramatsu <mhiramat at kernel.org>
Steven Rostedt
maintainerRe: [PATCH v2 22/32] selftests/ftrace: Add ringbuffer size changing testcase
Quoted 8 lines · On Thu, 30 Aug 2018 16:12:18 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Quoted 4 lines
I'm fine with this, but one day I need to port over some of my other tests. I have a test that stresses the ring buffer size (basically checks to see if it can cause an oom). I need to port that to selftests. But for now...
Hmm, such stress test is not good for kselftest, since it can cause oom and kill some test process. Maybe we should have such stresstest framework (which allows test to crash kernel)
The point of the test is to make sure that it doesn't kill everything :-) The ring buffer code is suppose to detect that it will cause an OOM, and if it does that's considered a failure.
Just like any other test, if it fails, it can crash the kernel. But the ring buffer code is suppose to be able to keep the kernel from crashing (including triggering OOM) if the buffer size is stressed.
Maybe I'll port that over today :-/
-- Steve
Masami Hiramatsu
maintainerRe: [PATCH v2 22/32] selftests/ftrace: Add ringbuffer size changing testcase
Quoted 8 lines · On Thu, 30 Aug 2018 11:50:55 -0400 Steven Rostedt <rostedt at goodmis.org>…
Quoted 5 lines · On Thu, 30 Aug 2018 16:12:18 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Quoted 4 lines
I'm fine with this, but one day I need to port over some of my other tests. I have a test that stresses the ring buffer size (basically checks to see if it can cause an oom). I need to port that to selftests. But for now...
Quoted 7 lines
Quoted 3 lines
Hmm, such stress test is not good for kselftest, since it can cause oom and kill some test process. Maybe we should have such stresstest framework (which allows test to crash kernel)
The point of the test is to make sure that it doesn't kill everything :-) The ring buffer code is suppose to detect that it will cause an OOM, and if it does that's considered a failure.
Ah, OK, so the test itself must not cause OOM. That's reasonable. :)
Quoted 6 lines
Just like any other test, if it fails, it can crash the kernel. But the ring buffer code is suppose to be able to keep the kernel from crashing (including triggering OOM) if the buffer size is stressed.
Maybe I'll port that over today :-/
Looking forward it!
Thank you,
Quoted 3 lines
-- Steve
Signature · 1 line
Masami Hiramatsu <mhiramat at kernel.org>
Steven Rostedt
maintainerRe: [PATCH v2 22/32] selftests/ftrace: Add ringbuffer size changing testcase
Quoted 22 lines · On Fri, 31 Aug 2018 08:35:28 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Quoted 8 lines · On Thu, 30 Aug 2018 11:50:55 -0400 Steven Rostedt <rostedt at goodmis.org>…
Quoted 5 lines · On Thu, 30 Aug 2018 16:12:18 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Quoted 4 lines
I'm fine with this, but one day I need to port over some of my other tests. I have a test that stresses the ring buffer size (basically checks to see if it can cause an oom). I need to port that to selftests. But for now...
Quoted 7 lines
Quoted 3 lines
Hmm, such stress test is not good for kselftest, since it can cause oom and kill some test process. Maybe we should have such stresstest framework (which allows test to crash kernel)
The point of the test is to make sure that it doesn't kill everything :-) The ring buffer code is suppose to detect that it will cause an OOM, and if it does that's considered a failure.
Ah, OK, so the test itself must not cause OOM. That's reasonable. :)
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Just like any other test, if it fails, it can crash the kernel. But the ring buffer code is suppose to be able to keep the kernel from crashing (including triggering OOM) if the buffer size is stressed.
Maybe I'll port that over today :-/
Looking forward it!
Unfortunately, I didn't get to it, and will be on PTO for the next 4 days. Perhaps next week.
-- Steve
Masami Hiramatsu
maintainerPATCH v2 23/32 selftests/ftrace: Add function profiling stat testcase
In reply to Masami HiramatsuAdd a testcase for function profiling per-cpu statistics interface. There is already func_profile.tc, but that is mainly focusing on the combination of function-profiler and function tracer. This testcase ensures trace_stat per-cpu function statistics is correctly updated.
--- .../ftrace/test.d/ftrace/func_profile_stat.tc | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_profile_stat.tc
tools/testing/selftests/ftrace/test.d/ftrace/func_profile_stat.tc new file +23 -0
@@ -0,0 +1,23 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: ftrace - function profiling + +[ ! -f function_profile_enabled ] && exit_unsupported + +: "Enable function profile" +echo 1 > function_profile_enabled + +: "Profile must be updated" +cp trace_stat/function0 $TMPDIR/ +( echo "forked"; sleep 1 ) +: "diff returns 0 if there is no difference" +! diff trace_stat/function0 $TMPDIR/function0 + +echo 0 > function_profile_enabled + +: "Profile must NOT be updated" +cp trace_stat/function0 $TMPDIR/ +( echo "forked"; sleep 1 ) +: "diff returns 0 if there is no difference" +diff trace_stat/function0 $TMPDIR/function0 +
Re: [PATCH v2 23/32] selftests/ftrace: Add function profiling stat testcase
Quoted 32 lines · On Fri, 17 Aug 2018 01:40:02 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Add a testcase for function profiling per-cpu statistics interface. There is already func_profile.tc, but that is mainly focusing on the combination of function-profiler and function tracer. This testcase ensures
trace_statper-cpu function statistics is correctly updated.Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../ftrace/test.d/ftrace/func_profile_stat.tc | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_profile_stat.tctools/testing/selftests/ftrace/test.d/ftrace/func_profile_stat.tc new file +14
-0@@ -0,0 +1,23 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: ftrace - function profiling + +[ ! -f function_profile_enabled ] && exit_unsupported + +: "Enable function profile" +echo 1 > function_profile_enabled + +: "Profile must be updated" +cp trace_stat/function0 $TMPDIR/ +( echo "forked"; sleep 1 ) +: "diff returns 0 if there is no difference" +! diff trace_stat/function0 $TMPDIR/function0
tools/testing/selftests/ftrace/test.d/ftrace/func_profile_stat.tc line 23
Quoted 10 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_profile_stat.tc new file +9
-0+ +echo 0 > function_profile_enabled + +: "Profile must NOT be updated" +cp trace_stat/function0 $TMPDIR/ +( echo "forked"; sleep 1 ) +: "diff returns 0 if there is no difference" +diff trace_stat/function0 $TMPDIR/function0 +
Can remove the last empty line from the file.
Other than that...
-- Steve
-- Steve
Masami Hiramatsu
maintainerRe: [PATCH v2 23/32] selftests/ftrace: Add function profiling stat testcase
Quoted 44 lines · On Fri, 24 Aug 2018 19:20:18 -0400 Steven Rostedt <rostedt at goodmis.org>…
Quoted 40 lines · On Fri, 17 Aug 2018 01:40:02 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Add a testcase for function profiling per-cpu statistics interface. There is already func_profile.tc, but that is mainly focusing on the combination of function-profiler and function tracer. This testcase ensures
trace_statper-cpu function statistics is correctly updated.Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../ftrace/test.d/ftrace/func_profile_stat.tc | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_profile_stat.tctools/testing/selftests/ftrace/test.d/ftrace/func_profile_stat.tc new file +22
-0@@ -0,0 +1,23 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: ftrace - function profiling + +[ ! -f function_profile_enabled ] && exit_unsupported + +: "Enable function profile" +echo 1 > function_profile_enabled + +: "Profile must be updated" +cp trace_stat/function0 $TMPDIR/ +( echo "forked"; sleep 1 ) +: "diff returns 0 if there is no difference" +! diff trace_stat/function0 $TMPDIR/function0 + +echo 0 > function_profile_enabled + +: "Profile must NOT be updated" +cp trace_stat/function0 $TMPDIR/ +( echo "forked"; sleep 1 ) +: "diff returns 0 if there is no difference" +diff trace_stat/function0 $TMPDIR/function0
Quoted 3 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_profile_stat.tc line 23
Quoted 1 line
tools/testing/selftests/ftrace/test.d/ftrace/func_profile_stat.tc new file +1
-0+Can remove the last empty line from the file.
Yes, thank you for pointing it out.
Quoted 4 lines
Other than that...
Acked-by Steven Rostedt (VMware) <rostedt at goodmis.org>
Thanks!
Quoted 4 lines
-- Steve
-- Steve
Signature · 1 line
Masami Hiramatsu <mhiramat at kernel.org>
Masami Hiramatsu
maintainerPATCH v2 24/32 selftests/ftrace: Add max stack tracer testcase
In reply to Masami HiramatsuAdd a testcase for max stack tracer, which checks basic max stack usage tracing and its filter feature.
--- .../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
tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc new file +39 -0
@@ -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
Steven Rostedt
maintainerRe: [PATCH v2 24/32] selftests/ftrace: Add max stack tracer testcase
Quoted 34 lines · On Fri, 17 Aug 2018 01:40:30 +0900 Masami Hiramatsu <[email protected]> wrote:
Add a testcase for max stack tracer, which checks basic max stack usage tracing and its filter feature.
Signed-off-by Masami Hiramatsu <mhiramat at 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.tctools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc new file +19
-0@@ -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`
tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc line 29
Quoted 10 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc new file +10
-0+ 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
This test fails quite a bit because it doesn't guarantee that another stack trace gets in that is bigger, and we don't find the "lock".
-- Steve
Quoted 10 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc new file +10
-0+ +: "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
Masami Hiramatsu
maintainerRe: [PATCH v2 24/32] selftests/ftrace: Add max stack tracer testcase
Quoted 42 lines · On Fri, 24 Aug 2018 19:23:52 -0400 Steven Rostedt <rostedt at goodmis.org>…
Quoted 39 lines · On Fri, 17 Aug 2018 01:40:30 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Add a testcase for max stack tracer, which checks basic max stack usage tracing and its filter feature.
Signed-off-by Masami Hiramatsu <mhiramat at 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.tctools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc new file +24
-0@@ -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 +
Quoted 8 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc line 29
Quoted 5 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc new file +5
-0+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_enabledThis test fails quite a bit because it doesn't guarantee that another stack trace gets in that is bigger, and we don't find the "lock".
Hmm, maybe I misunderstand what is the stack_trace_filter. I thought it filtered the function that triggered stack trace, so the top of stack trace was always filtered function. If not, what does this filter?
Thank you,
Quoted 14 lines
-- Steve
Quoted 10 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc new file +10
-0+ +: "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
Signature · 1 line
Masami Hiramatsu <mhiramat at kernel.org>
Steven Rostedt
maintainerRe: [PATCH v2 24/32] selftests/ftrace: Add max stack tracer testcase
Quoted 54 lines · On Sat, 25 Aug 2018 10:45:09 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 42 lines · On Fri, 24 Aug 2018 19:23:52 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 39 lines · On Fri, 17 Aug 2018 01:40:30 +0900 Masami Hiramatsu <[email protected]> wrote:
Add a testcase for max stack tracer, which checks basic max stack usage tracing and its filter feature.
Signed-off-by Masami Hiramatsu <mhiramat at 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.tctools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc new file +24
-0@@ -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 +Quoted 8 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc line 29
Quoted 5 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc new file +5
-0+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_enabledThis test fails quite a bit because it doesn't guarantee that another stack trace gets in that is bigger, and we don't find the "lock".
Quoted 4 lines
Hmm, maybe I misunderstand what is the
stack_trace_filter. I thought it filtered the function that triggered stack trace, so the top of stack trace was always filtered function. If not, what does this filter?
Ah, I missed the filter part, no its correct, and actually found a bug ;-) By adding this patch, it works again:
kernel/trace/trace_stack.c +1 -1
@@ -111,7 +111,7 @@ check_stack(unsigned long ip, unsigned long *stack) stack_trace_max_size = this_size; stack_trace_max.nr_entries =0 ; - stack_trace_max.skip =3 ; + stack_trace_max.skip =0 ;save_stack_trace (&stack_trace_max);
-- Steve
Quoted 14 lines
Quoted 12 lines
Quoted 11 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc new file +10
-0+ +: "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
Masami Hiramatsu
maintainerRe: [PATCH v2 24/32] selftests/ftrace: Add max stack tracer testcase
Quoted 57 lines · On Fri, 24 Aug 2018 22:41:22 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 54 lines · On Sat, 25 Aug 2018 10:45:09 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 50 lines · On Fri, 24 Aug 2018 19:23:52 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 34 lines · On Fri, 17 Aug 2018 01:40:30 +0900 Masami Hiramatsu <[email protected]> wrote:
Add a testcase for max stack tracer, which checks basic max stack usage tracing and its filter feature.
Signed-off-by Masami Hiramatsu <mhiramat at 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.tctools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc new file +19
-0@@ -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`tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc line 29
Quoted 10 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc new file +10
-0+ 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_enabledThis test fails quite a bit because it doesn't guarantee that another stack trace gets in that is bigger, and we don't find the "lock".
Quoted 7 lines
Quoted 4 lines
Hmm, maybe I misunderstand what is the
stack_trace_filter. I thought it filtered the function that triggered stack trace, so the top of stack trace was always filtered function. If not, what does this filter?Ah, I missed the filter part, no its correct, and actually found a bug ;-) By adding this patch, it works again:
Great! this shows ftracetest really works :)
Anyway, with this fix, we don't need the timeout things anymore.
Thanks!
Quoted 33 lines
kernel/trace/trace_stack.c +1
-2@@ -111,7 +111,7 @@ check_stack(unsigned long ip, unsigned long *stack) stack_trace_max_size = this_size; stack_trace_max.nr_entries =0 ; - stack_trace_max.skip =3 ; + stack_trace_max.skip =0 ;save_stack_trace (&stack_trace_max); -- SteveQuoted 15 lines
Quoted 13 lines
Quoted 12 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc new file +10
-0+ +: "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
Signature · 1 line
Masami Hiramatsu <mhiramat at kernel.org>
Masami Hiramatsu
maintainerPATCH v2 25/32 selftests/ftrace: Add function filter on module testcase
In reply to Masami HiramatsuAdd a testcase for function filter on module.
--- .../ftrace/test.d/ftrace/func_mod_trace.tc | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_mod_trace.tc
tools/testing/selftests/ftrace/test.d/ftrace/func_mod_trace.tc new file +24 -0
@@ -0,0 +1,24 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: ftrace - function trace on module + +[ ! -f set_ftrace_filter ] && exit_unsupported + +: "mod: allows to filter a non exist function" +echo 'non_exist_func:mod:non_exist_module' > set_ftrace_filter +grep -q "non_exist_func" set_ftrace_filter + +: "mod: on exist module" +echo '*:mod:trace_printk' > set_ftrace_filter +if ! modprobe trace-printk.ko ; then + echo "No trace-printk sample module - please make CONFIG_SAMPLE_TRACE_PRINTK= +m" + exit_unresolved; +fi + +: "Wildcard should be resolved after loading module" +grep -q "trace_printk_irq_work" set_ftrace_filter + +: "After removing the filter becomes empty" +rmmod trace_printk +test `cat set_ftrace_filter | wc -l` -eq 0
Steven Rostedt
maintainerRe: [PATCH v2 25/32] selftests/ftrace: Add function filter on module testcase
Quoted 17 lines · On Fri, 17 Aug 2018 01:40:59 +0900 Masami Hiramatsu <[email protected]> wrote:
Add a testcase for function filter on module.
Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../ftrace/test.d/ftrace/func_mod_trace.tc | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_mod_trace.tctools/testing/selftests/ftrace/test.d/ftrace/func_mod_trace.tc new file +3
-0@@ -0,0 +1,24 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: ftrace - function trace on module
tools/testing/selftests/ftrace/test.d/ftrace/func_mod_trace.tc line 13
Quoted 10 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_mod_trace.tc new file +10
-0+ +[ ! -f set_ftrace_filter ] && exit_unsupported + +: "mod: allows to filter a non exist function" +echo 'non_exist_func:mod:non_exist_module' > set_ftrace_filter +grep -q "non_exist_func" set_ftrace_filter + +: "mod: on exist module" +echo '*:mod:trace_printk' > set_ftrace_filter +if ! modprobe trace-printk.ko ; then
Need to remove the '.ko'
-- Steve
Quoted 11 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_mod_trace.tc new file +11
-0+ echo "No trace-printk sample module - please make CONFIG_SAMPLE_TRACE_PRINTK= +m" + exit_unresolved; +fi + +: "Wildcard should be resolved after loading module" +grep -q "trace_printk_irq_work" set_ftrace_filter + +: "After removing the filter becomes empty" +rmmod trace_printk +test `cat set_ftrace_filter | wc -l` -eq 0
Masami Hiramatsu
maintainerPATCH v2 26/32 selftests/ftrace: Add trace_pipe testcase
In reply to Masami HiramatsuAdd a simple testcase for trace_pipe which can consume ringbuffer.
--- .../selftests/ftrace/test.d/00basic/trace_pipe.tc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tc
tools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tc new file +15 -0
@@ -0,0 +1,15 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: trace_pipe and trace_marker + +[ ! -f trace_marker ] && exit_unsupported + +echo "test input 1" > trace_marker + +: "trace interface never consume the ring buffer" +grep -q "test input 1" trace +grep -q "test input 1" trace + +: "trace interface never consume the ring buffer" +head -n 1 trace_pipe | grep -q "test input 1" +! grep -q "test input 1" trace
Steven Rostedt
maintainerRe: [PATCH v2 26/32] selftests/ftrace: Add trace_pipe testcase
Quoted 15 lines · On Fri, 17 Aug 2018 01:41:27 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Add a simple testcase for
trace_pipewhich can consume ringbuffer.Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../selftests/ftrace/test.d/00basic/trace_pipe.tc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tctools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tc new file +0
-0
tools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tc line 3
Quoted 3 lines
tools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tc new file +3
-0@@ -0,0 +1,15 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: trace_pipe and trace_marker
Should add:
# flags: instance
-- Steve
Quoted 12 lines
tools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tc new file +12
-0+ +[ ! -f trace_marker ] && exit_unsupported + +echo "test input 1" > trace_marker + +: "trace interface never consume the ring buffer" +grep -q "test input 1" trace +grep -q "test input 1" trace + +: "trace interface never consume the ring buffer" +head -n 1 trace_pipe | grep -q "test input 1" +! grep -q "test input 1" trace
Masami Hiramatsu
maintainerRe: [PATCH v2 26/32] selftests/ftrace: Add trace_pipe testcase
Quoted 24 lines · On Fri, 24 Aug 2018 19:26:29 -0400 Steven Rostedt <rostedt at goodmis.org>…
Quoted 15 lines · On Fri, 17 Aug 2018 01:41:27 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Add a simple testcase for
trace_pipewhich can consume ringbuffer.Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../selftests/ftrace/test.d/00basic/trace_pipe.tc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tctools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tc new file +0
-0tools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tc line 3
Quoted 3 lines
tools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tc new file +3
-0@@ -0,0 +1,15 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: trace_pipe and trace_markerShould add:
Quoted 1 line
# flags: instance
Ah, right!
Thanks!
Quoted 16 lines
-- Steve
Quoted 12 lines
tools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tc new file +12
-0+ +[ ! -f trace_marker ] && exit_unsupported + +echo "test input 1" > trace_marker + +: "trace interface never consume the ring buffer" +grep -q "test input 1" trace +grep -q "test input 1" trace + +: "trace interface never consume the ring buffer" +head -n 1 trace_pipe | grep -q "test input 1" +! grep -q "test input 1" trace
Signature · 1 line
Masami Hiramatsu <mhiramat at kernel.org>
Masami Hiramatsu
maintainerPATCH v2 27/32 selftests/ftrace: Add stacktrace ftrace filter command testcase
In reply to Masami HiramatsuAdd a test case for stacktrace filter command for ftrace.
--- .../ftrace/test.d/ftrace/func-filter-stacktrace.tc | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc new file +12 -0
@@ -0,0 +1,12 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL2.0 +# description: ftrace - stacktrace filter command + +echo _do_fork:stacktrace >> set_ftrace_filter + +grep -q "_do_fork:stacktrace:unlimited" set_ftrace_filter + +(echo "forked"; sleep 1) + +grep -q "<stack trace>" trace +
Steven Rostedt
maintainerRe: [PATCH v2 27/32] selftests/ftrace: Add stacktrace ftrace filter command testcase
Quoted 14 lines · On Fri, 17 Aug 2018 01:41:55 +0900 Masami Hiramatsu <[email protected]> wrote:
Add a test case for stacktrace filter command for ftrace.
Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../ftrace/test.d/ftrace/func-filter-stacktrace.tc | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tctools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc new file +0
-0
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc line 3
Quoted 3 lines
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc new file +3
-0@@ -0,0 +1,12 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL2.0 +# description: ftrace - stacktrace filter command
Add:
# flags: instance
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc line 12
Quoted 10 lines
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc new file +9
-0+ +echo _do_fork:stacktrace >> set_ftrace_filter + +grep -q "_do_fork:stacktrace:unlimited" set_ftrace_filter + +(echo "forked"; sleep 1) + +grep -q "<stack trace>" trace +
Can remove the extra line.
-- Steve
Masami Hiramatsu
maintainerPATCH v2 28/32 selftests/ftrace: Add wakeup tracer testcase
In reply to Masami HiramatsuAdd a testcase for wakeup tracer.
--- tools/testing/selftests/ftrace/config | 1 + .../selftests/ftrace/test.d/tracer/wakeup.tc | 25 ++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/tracer/wakeup.tc
tools/testing/selftests/ftrace/config +1 -0
@@ -4,6 +4,7 @@ CONFIG_FUNCTION_PROFILER=y CONFIG_TRACER_SNAPSHOT=y CONFIG_STACK_TRACER=y CONFIG_HIST_TRIGGERS=y +CONFIG_SCHED_TRACER=y CONFIG_PREEMPT_TRACER=y CONFIG_IRQSOFF_TRACER=y CONFIG_PREEMPTIRQ_DELAY_TEST=m
tools/testing/selftests/ftrace/test.d/tracer/wakeup.tc new file +25 -0
@@ -0,0 +1,25 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL2.0 +# description: Test wakeup tracer + +if ! which chrt ; then + echo "chrt is not found. This test requires nice command." + exit_unresolved +fi + +if ! grep -wq "wakeup" available_tracers ; then + echo "wakeup tracer is not supported" + exit_unsupported +fi + +echo wakeup > current_tracer +echo 1 > tracing_on +echo 0 > tracing_max_latency + +: "Wakeup higher priority task" +chrt -f 5 sleep 1 + +echo 0 > tracing_on +grep '+ \[[[:digit:]]*\]' trace +grep '==> \[[[:digit:]]*\]' trace +
Masami Hiramatsu
maintainerPATCH v2 29/32 selftests/ftrace: Add wakeup_rt tracer testcase
In reply to Masami HiramatsuAdd a testcase for wakeup_rt tracer. This requires chrt command to test.
--- .../selftests/ftrace/test.d/tracer/wakeup_rt.tc | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/tracer/wakeup_rt.tc
tools/testing/selftests/ftrace/test.d/tracer/wakeup_rt.tc new file +25 -0
@@ -0,0 +1,25 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL2.0 +# description: Test wakeup RT tracer + +if ! which nice ; then + echo "chrt is not found. This test requires chrt command." + exit_unresolved +fi + +if ! grep -wq "wakeup_rt" available_tracers ; then + echo "wakeup_rt tracer is not supported" + exit_unsupported +fi + +echo wakeup > current_tracer +echo 1 > tracing_on +echo 0 > tracing_max_latency + +: "Wakeup a realtime task" +chrt -f 5 sleep 1 + +echo 0 > tracing_on +grep "+ \[[[:digit:]]*\]" trace +grep "==> \[[[:digit:]]*\]" trace +
Steven Rostedt
maintainerRe: [PATCH v2 29/32] selftests/ftrace: Add wakeup_rt tracer testcase
Quoted 20 lines · On Fri, 17 Aug 2018 01:42:52 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Add a testcase for
wakeup_rttracer. This requires chrt command to test.Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../selftests/ftrace/test.d/tracer/wakeup_rt.tc | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/tracer/wakeup_rt.tctools/testing/selftests/ftrace/test.d/tracer/wakeup_rt.tc new file +5
-0@@ -0,0 +1,25 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL2.0 +# description: Test wakeup RT tracer + +if ! which nice ; then
tools/testing/selftests/ftrace/test.d/tracer/wakeup_rt.tc line 15
Quoted 10 lines
tools/testing/selftests/ftrace/test.d/tracer/wakeup_rt.tc new file +10
-0+ echo "chrt is not found. This test requires chrt command." + exit_unresolved +fi + +if ! grep -wq "wakeup_rt" available_tracers ; then + echo "wakeup_rt tracer is not supported" + exit_unsupported +fi + +echo wakeup > current_tracer
I think you meant "echo wakeup_rt" ;-)
-- Steve
Quoted 10 lines
tools/testing/selftests/ftrace/test.d/tracer/wakeup_rt.tc new file +10
-0+echo 1 > tracing_on +echo 0 > tracing_max_latency + +: "Wakeup a realtime task" +chrt -f 5 sleep 1 + +echo 0 > tracing_on +grep "+ \[[[:digit:]]*\]" trace +grep "==> \[[[:digit:]]*\]" trace +
Masami Hiramatsu
maintainerRe: [PATCH v2 29/32] selftests/ftrace: Add wakeup_rt tracer testcase
Quoted 27 lines · On Fri, 24 Aug 2018 22:09:49 -0400 Steven Rostedt <rostedt at goodmis.org>…
Quoted 24 lines · On Fri, 17 Aug 2018 01:42:52 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Add a testcase for
wakeup_rttracer. This requires chrt command to test.Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../selftests/ftrace/test.d/tracer/wakeup_rt.tc | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/tracer/wakeup_rt.tctools/testing/selftests/ftrace/test.d/tracer/wakeup_rt.tc new file +9
-0@@ -0,0 +1,25 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL2.0 +# description: Test wakeup RT tracer + +if ! which nice ; then + echo "chrt is not found. This test requires chrt command." + exit_unresolved +fi +
Quoted 8 lines
tools/testing/selftests/ftrace/test.d/tracer/wakeup_rt.tc line 15
Quoted 6 lines
tools/testing/selftests/ftrace/test.d/tracer/wakeup_rt.tc new file +6
-0+if ! grep -wq "wakeup_rt" available_tracers ; then + echo "wakeup_rt tracer is not supported" + exit_unsupported +fi + +echo wakeup > current_tracerI think you meant "echo
wakeup_rt" ;-)
Oops, that's my fault....
Thanks!
Quoted 14 lines
-- Steve
Quoted 10 lines
tools/testing/selftests/ftrace/test.d/tracer/wakeup_rt.tc new file +10
-0+echo 1 > tracing_on +echo 0 > tracing_max_latency + +: "Wakeup a realtime task" +chrt -f 5 sleep 1 + +echo 0 > tracing_on +grep "+ \[[[:digit:]]*\]" trace +grep "==> \[[[:digit:]]*\]" trace +
Signature · 1 line
Masami Hiramatsu <mhiramat at kernel.org>
Masami Hiramatsu
maintainerPATCH v2 30/32 selftests/ftrace: Add ftrace cpumask testcase
In reply to Masami HiramatsuAdd a testcase for tracing_cpumask with function tracer.
--- .../selftests/ftrace/test.d/ftrace/func_cpumask.tc | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc
tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc new file +34 -0
@@ -0,0 +1,34 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL2.0 +# description: ftrace - function trace with cpumask + +NP=`grep "^processor" /proc/cpuinfo | wc -l` + +if [ $NP -eq 1 ] ;then + echo "We can not test cpumask on UP environment" + exit_unresolved +fi + +do_reset() { + echo ffff > tracing_cpumask +} + +echo 0 > tracing_on +echo > trace +: "Bitmask only record on CPU1" +echo 2 > tracing_cpumask +MASK=0x`cat tracing_cpumask` +test `printf "%d" $MASK` -eq 2 || do_reset + +echo function > current_tracer +echo 1 > tracing_on +(echo "forked") +echo 0 > tracing_on + +: "Check CPU1 events are recorded" +grep -q -e "\[001\]" trace || do_reset + +: "There should be No other cpu events" +! grep -qv -e "\[001\]" -e "^#" trace || do_reset + +do_reset
Steven Rostedt
maintainerRe: [PATCH v2 30/32] selftests/ftrace: Add ftrace cpumask testcase
Quoted 14 lines · On Fri, 17 Aug 2018 01:43:20 +0900 Masami Hiramatsu <[email protected]> wrote:
Add a testcase for
tracing_cpumaskwith function tracer.Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../selftests/ftrace/test.d/ftrace/func_cpumask.tc | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tctools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc new file +0
-0
tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc line 5
Quoted 5 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc new file +5
-0@@ -0,0 +1,34 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL2.0 +# description: ftrace - function trace with cpumask + +NP=`grep "^processor" /proc/cpuinfo | wc -l`
A better way to find the number of CPUs is to either use "nproc" or just look at /sys/devices/system/cpu/cpu[0-9]*. Because what I learned from experience is that searching for strings in /proc/cpuinfo is not cross arch compatible. For example, other archs don't use "processor" in the stings and would come up with a box with 0 CPUs. Something we've been working on for some time ;-)
-- Steve
tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc line 13
Quoted 8 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc new file +8
-0+ +if [ $NP -eq 1 ] ;then + echo "We can not test cpumask on UP environment" + exit_unresolved +fi + +do_reset() { + echo ffff > tracing_cpumask
Why ffff? Should we save what was in tracing_cpumask first and just reuse it?
-- Steve
Quoted 21 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc new file +21
-0+} + +echo 0 > tracing_on +echo > trace +: "Bitmask only record on CPU1" +echo 2 > tracing_cpumask +MASK=0x`cat tracing_cpumask` +test `printf "%d" $MASK` -eq 2 || do_reset + +echo function > current_tracer +echo 1 > tracing_on +(echo "forked") +echo 0 > tracing_on + +: "Check CPU1 events are recorded" +grep -q -e "\[001\]" trace || do_reset + +: "There should be No other cpu events" +! grep -qv -e "\[001\]" -e "^#" trace || do_reset + +do_reset
Masami Hiramatsu
maintainerRe: [PATCH v2 30/32] selftests/ftrace: Add ftrace cpumask testcase
Quoted 21 lines · On Fri, 24 Aug 2018 22:18:22 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 18 lines · On Fri, 17 Aug 2018 01:43:20 +0900 Masami Hiramatsu <[email protected]> wrote:
Add a testcase for
tracing_cpumaskwith function tracer.Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../selftests/ftrace/test.d/ftrace/func_cpumask.tc | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tctools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc new file +4
-0@@ -0,0 +1,34 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL2.0 +# description: ftrace - function trace with cpumask +
Quoted 8 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc line 5
Quoted 1 line
tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc new file +1
-0+NP=`grep "^processor" /proc/cpuinfo | wc -l`A better way to find the number of CPUs is to either use "nproc" or just look at /sys/devices/system/cpu/cpu[0-9]*. Because what I learned from experience is that searching for strings in
/proc/cpuinfois not cross arch compatible. For example, other archs don't use "processor" in the stings and would come up with a box with 0 CPUs. Something we've been working on for some time ;-)
OK, I'll use nproc.
Quoted 14 lines
-- Steve
tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc line 13
Quoted 8 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc new file +8
-0+ +if [ $NP -eq 1 ] ;then + echo "We can not test cpumask on UP environment" + exit_unresolved +fi + +do_reset() { + echo ffff > tracing_cpumaskWhy ffff? Should we save what was in
tracing_cpumaskfirst and just reuse it?
OK, it also works. I just took a margin :)
Thanks!
Quoted 26 lines
-- Steve
Quoted 21 lines
tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc new file +21
-0+} + +echo 0 > tracing_on +echo > trace +: "Bitmask only record on CPU1" +echo 2 > tracing_cpumask +MASK=0x`cat tracing_cpumask` +test `printf "%d" $MASK` -eq 2 || do_reset + +echo function > current_tracer +echo 1 > tracing_on +(echo "forked") +echo 0 > tracing_on + +: "Check CPU1 events are recorded" +grep -q -e "\[001\]" trace || do_reset + +: "There should be No other cpu events" +! grep -qv -e "\[001\]" -e "^#" trace || do_reset + +do_reset
Signature · 1 line
Masami Hiramatsu <mhiramat at kernel.org>
Masami Hiramatsu
maintainerPATCH v2 31/32 selftests/ftrace: Add output format testcase
In reply to Masami HiramatsuAdd a testcase for tracing output format using trace_marker. This tests raw, hex and bin format output.
--- .../ftrace/test.d/00basic/print_format.tc | 51 ++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/print_format.tc
tools/testing/selftests/ftrace/test.d/00basic/print_format.tc new file +51 -0
@@ -0,0 +1,51 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL2.0 +# description: Change print trace format + +if [ ! -f trace_marker ]; then + echo "trace_marker is not supported, can not continue testing" + exit_unresolved +fi + +do_reset() { + if [ `cat options/bin` -eq 1 ]; then + grep -v "^#" trace | od -h | cut -f 2- -d " " | xargs echo + fi + echo 0 > options/hex + echo 0 > options/raw + echo 0 > options/bin + cat trace + exit 1 +} + +echo > trace +echo "abcdefgh" > trace_marker +echo 0 > tracing_on + +: "Get the pid and cpu#" +IDS=`grep -v "^#" trace | sed -e 's/[[:space:]]*.*-\([[:digit:]]*\)[[:space:]]*\[\([[:digit:]]*\)\].*/\1 \2/'` + +read_pid_cpu() { + _PID=$1 + _CPU=`printf "%d" $2` +} + +read_pid_cpu $IDS + +: "Test raw output format" +echo 1 > options/raw +grep -v "^#" trace | grep "^$_PID $_CPU" || do_reset +echo 0 > options/raw + +: "Test hex output format" +echo 1 > options/hex +PAT=`printf "%08x %08x" $_PID $_CPU` +grep -v "^#" trace | grep "^$PAT" || do_reset +echo 0 > options/hex + +: "Test bin output format" +echo 1 > options/bin +PAT=`printf "%04x [[:xdigit:]]* [[:xdigit:]]*%02x" $_PID $_CPU` +# Make a stream of hexdump +grep -v "^#" trace | od -h | cut -f 2- -d " " | xargs echo | grep "$PAT" || do_reset +echo 0 > options/bin
Steven Rostedt
maintainerRe: [PATCH v2 31/32] selftests/ftrace: Add output format testcase
Quoted 2 lines · On Fri, 17 Aug 2018 01:43:49 +0900 Masami Hiramatsu <[email protected]> wrote:
Add a testcase for tracing output format using
trace_marker. This tests raw, hex and bin format output.
I'd like to deprecate these formats. They are useless ever since we implemented trace_pipe_raw.
Let's not add this test.
Thanks,
-- Steve
Quoted 64 lines
Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../ftrace/test.d/00basic/print_format.tc | 51 ++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/print_format.tctools/testing/selftests/ftrace/test.d/00basic/print_format.tc new file +51
-0@@ -0,0 +1,51 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL2.0 +# description: Change print trace format + +if [ ! -f trace_marker ]; then + echo "trace_marker is not supported, can not continue testing" + exit_unresolved +fi + +do_reset() { + if [ `cat options/bin` -eq 1 ]; then + grep -v "^#" trace | od -h | cut -f 2- -d " " | xargs echo + fi + echo 0 > options/hex + echo 0 > options/raw + echo 0 > options/bin + cat trace + exit 1 +} + +echo > trace +echo "abcdefgh" > trace_marker +echo 0 > tracing_on + +: "Get the pid and cpu#" +IDS=`grep -v "^#" trace | sed -e 's/[[:space:]]*.*-\([[:digit:]]*\)[[:space:]]*\[\([[:digit:]]*\)\].*/\1 \2/'` + +read_pid_cpu() { + _PID=$1 + _CPU=`printf "%d" $2` +} + +read_pid_cpu $IDS + +: "Test raw output format" +echo 1 > options/raw +grep -v "^#" trace | grep "^$_PID $_CPU" || do_reset +echo 0 > options/raw + +: "Test hex output format" +echo 1 > options/hex +PAT=`printf "%08x %08x" $_PID $_CPU` +grep -v "^#" trace | grep "^$PAT" || do_reset +echo 0 > options/hex + +: "Test bin output format" +echo 1 > options/bin +PAT=`printf "%04x [[:xdigit:]]* [[:xdigit:]]*%02x" $_PID $_CPU` +# Make a stream of hexdump +grep -v "^#" trace | od -h | cut -f 2- -d " " | xargs echo | grep "$PAT" || do_reset +echo 0 > options/bin
Masami Hiramatsu
maintainerRe: [PATCH v2 31/32] selftests/ftrace: Add output format testcase
Quoted 10 lines · On Fri, 24 Aug 2018 22:19:26 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 2 lines · On Fri, 17 Aug 2018 01:43:49 +0900 Masami Hiramatsu <[email protected]> wrote:
Add a testcase for tracing output format using
trace_marker. This tests raw, hex and bin format output.I'd like to deprecate these formats. They are useless ever since we implemented
trace_pipe_raw.Let's not add this test.
OK, I'll drop it.
I think this test code itself can reuse for testing trace_pipe_raw too. (for next time?)
Thank you,
Quoted 70 lines
Thanks,
-- Steve
Quoted 64 lines
Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- .../ftrace/test.d/00basic/print_format.tc | 51 ++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/print_format.tctools/testing/selftests/ftrace/test.d/00basic/print_format.tc new file +51
-0@@ -0,0 +1,51 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL2.0 +# description: Change print trace format + +if [ ! -f trace_marker ]; then + echo "trace_marker is not supported, can not continue testing" + exit_unresolved +fi + +do_reset() { + if [ `cat options/bin` -eq 1 ]; then + grep -v "^#" trace | od -h | cut -f 2- -d " " | xargs echo + fi + echo 0 > options/hex + echo 0 > options/raw + echo 0 > options/bin + cat trace + exit 1 +} + +echo > trace +echo "abcdefgh" > trace_marker +echo 0 > tracing_on + +: "Get the pid and cpu#" +IDS=`grep -v "^#" trace | sed -e 's/[[:space:]]*.*-\([[:digit:]]*\)[[:space:]]*\[\([[:digit:]]*\)\].*/\1 \2/'` + +read_pid_cpu() { + _PID=$1 + _CPU=`printf "%d" $2` +} + +read_pid_cpu $IDS + +: "Test raw output format" +echo 1 > options/raw +grep -v "^#" trace | grep "^$_PID $_CPU" || do_reset +echo 0 > options/raw + +: "Test hex output format" +echo 1 > options/hex +PAT=`printf "%08x %08x" $_PID $_CPU` +grep -v "^#" trace | grep "^$PAT" || do_reset +echo 0 > options/hex + +: "Test bin output format" +echo 1 > options/bin +PAT=`printf "%04x [[:xdigit:]]* [[:xdigit:]]*%02x" $_PID $_CPU` +# Make a stream of hexdump +grep -v "^#" trace | od -h | cut -f 2- -d " " | xargs echo | grep "$PAT" || do_reset +echo 0 > options/bin
Signature · 1 line
Masami Hiramatsu <mhiramat at kernel.org>
Masami Hiramatsu
maintainerPATCH v2 32/32 selftests/ftrace: Add blktrace testcase
In reply to Masami HiramatsuAdd a basic testcase for blktrace. For making it portable, this test uses a loop device.
--- tools/testing/selftests/ftrace/config | 1 .../testing/selftests/ftrace/test.d/tracer/blk.tc | 91 ++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/tracer/blk.tc
tools/testing/selftests/ftrace/config +1 -0
@@ -5,6 +5,7 @@ CONFIG_TRACER_SNAPSHOT=y CONFIG_STACK_TRACER=y CONFIG_HIST_TRIGGERS=y CONFIG_SCHED_TRACER=y +CONFIG_BLK_DEV_IO_TRACE=y CONFIG_PREEMPT_TRACER=y CONFIG_IRQSOFF_TRACER=y CONFIG_PREEMPTIRQ_DELAY_TEST=m
tools/testing/selftests/ftrace/test.d/tracer/blk.tc new file +91 -0
91 lines not on this page · raw message
Steven Rostedt
maintainerRe: [PATCH v2 32/32] selftests/ftrace: Add blktrace testcase
Quoted 2 lines · On Fri, 17 Aug 2018 01:44:18 +0900 Masami Hiramatsu <[email protected]> wrote:
Add a basic testcase for blktrace. For making it portable, this test uses a loop device.
blktrace is a bit special, as it's maintained by the block subsystem and not really truly part of ftrace. It lives in the tracing directory, but the changes go through Jens's tree. I'm guessing that Jens already has tests for this. Not sure we should add a test to the ftrace selftests for this tracer.
Jens, you have thoughts on this?
-- Steve
Quoted 117 lines
Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- tools/testing/selftests/ftrace/config | 1 .../testing/selftests/ftrace/test.d/tracer/blk.tc | 91 ++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/tracer/blk.tctools/testing/selftests/ftrace/config +1
-0@@ -5,6 +5,7 @@ CONFIG_TRACER_SNAPSHOT=y CONFIG_STACK_TRACER=y CONFIG_HIST_TRIGGERS=y CONFIG_SCHED_TRACER=y +CONFIG_BLK_DEV_IO_TRACE=y CONFIG_PREEMPT_TRACER=y CONFIG_IRQSOFF_TRACER=y CONFIG_PREEMPTIRQ_DELAY_TEST=mtools/testing/selftests/ftrace/test.d/tracer/blk.tc new file +91
-0@@ -0,0 +1,91 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL2.0 +# description: Test blktrace + +IMG=$TMPDIR/fs.img +MNTDIR=$TMPDIR/mnt + +if ! grep -wq "blk" available_tracers ; then + echo "blktrace is not supported" + exit_unsupported +fi + +available_fs() { #fstype + grep -q $1 /proc/filesystems && which mkfs.$1 +} + +if available_fs ext3; then + FSTYPE=ext3 +elif available_fs ext4; then + FSTYPE=ext4 +elif available_fs ext2; then + FSTYPE=ext2 +elif available_fs xfs; then + FSTYPE=xfs +elif available_fs btrfs; then + FSTYPE=btrfs +else + echo "No available block-based filesystems" + exit_unresolved +fi + +if ! which losetup; then + echo "No losetup found" + exit_unresolved +fi +LODEV=`losetup -f` +LODEVTRACE=/sys/block/`basename $LODEV`/trace + +do_cleanup() { + if [ -d $MNTDIR ]; then + umount $MNTDIR ||: + fi + losetup -d $LODEV ||: + rm -f $IMG +} + +# workload failure is not a tracer's failure +workload_fail() { + do_cleanup + echo "Failed to run workload" + exit_unresolved +} + +do_fail() { + do_cleanup + echo "Test failed" + exit 1 +} + +enable_lodevtrace() { + if [ `cat $LODEVTRACE/enable` -ne 1 ]; then + echo 1 > $LODEVTRACE/enable + fi +} + +echo blk > current_tracer + +dd if=/dev/zero of=$IMG bs=1M count=10 &&\ +losetup $LODEV $IMG &&\ +mkfs.$FSTYPE $LODEV &&\ +mkdir -p $MNTDIR &&\ +mount -t $FSTYPE $LODEV $MNTDIR &&\ +enable_lodevtrace &&\ +dd if=/dev/urandom of=$MNTDIR/testfile bs=1M count=1 &&\ +sync &&\ +umount $MNTDIR || workload_fail + +grep -q "[dd]" trace || do_fail +grep -q "[umount]" trace || do_fail +echo > trace + +losetup $LODEV $IMG &&\ +mount -t $FSTYPE $LODEV $MNTDIR &&\ +cat $MNTDIR/testfile > /dev/null &&\ +echo 0 > $LODEVTRACE/enable &&\ +umount $MNTDIR || workload_fail + +grep -q "[cat]" trace || do_fail +grep -q "[mount]" trace || do_fail + +do_cleanup
Masami Hiramatsu
maintainerRe: [PATCH v2 32/32] selftests/ftrace: Add blktrace testcase
Quoted 11 lines · On Fri, 24 Aug 2018 22:22:19 -0400 Steven Rostedt <rostedt at goodmis.org>…
Quoted 2 lines · On Fri, 17 Aug 2018 01:44:18 +0900 Masami Hiramatsu <mhiramat at kernel.org>…
Add a basic testcase for blktrace. For making it portable, this test uses a loop device.
blktrace is a bit special, as it's maintained by the block subsystem and not really truly part of ftrace. It lives in the tracing directory, but the changes go through Jens's tree. I'm guessing that Jens already has tests for this. Not sure we should add a test to the ftrace selftests for this tracer.
I see. But as far as it is in the ftrace, and can easily wake it up from tracefs interface, I think we can have a basic testcase in ftracetest, just for keeping it doesn't break anything.
Quoted 2 lines
Jens, you have thoughts on this?
Jens, ping?
Thank you,
Quoted 121 lines
-- Steve
Quoted 117 lines
Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>--- tools/testing/selftests/ftrace/config | 1 .../testing/selftests/ftrace/test.d/tracer/blk.tc | 91 ++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/tracer/blk.tctools/testing/selftests/ftrace/config +1
-0@@ -5,6 +5,7 @@ CONFIG_TRACER_SNAPSHOT=y CONFIG_STACK_TRACER=y CONFIG_HIST_TRIGGERS=y CONFIG_SCHED_TRACER=y +CONFIG_BLK_DEV_IO_TRACE=y CONFIG_PREEMPT_TRACER=y CONFIG_IRQSOFF_TRACER=y CONFIG_PREEMPTIRQ_DELAY_TEST=mtools/testing/selftests/ftrace/test.d/tracer/blk.tc new file +91
-0@@ -0,0 +1,91 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL2.0 +# description: Test blktrace + +IMG=$TMPDIR/fs.img +MNTDIR=$TMPDIR/mnt + +if ! grep -wq "blk" available_tracers ; then + echo "blktrace is not supported" + exit_unsupported +fi + +available_fs() { #fstype + grep -q $1 /proc/filesystems && which mkfs.$1 +} + +if available_fs ext3; then + FSTYPE=ext3 +elif available_fs ext4; then + FSTYPE=ext4 +elif available_fs ext2; then + FSTYPE=ext2 +elif available_fs xfs; then + FSTYPE=xfs +elif available_fs btrfs; then + FSTYPE=btrfs +else + echo "No available block-based filesystems" + exit_unresolved +fi + +if ! which losetup; then + echo "No losetup found" + exit_unresolved +fi +LODEV=`losetup -f` +LODEVTRACE=/sys/block/`basename $LODEV`/trace + +do_cleanup() { + if [ -d $MNTDIR ]; then + umount $MNTDIR ||: + fi + losetup -d $LODEV ||: + rm -f $IMG +} + +# workload failure is not a tracer's failure +workload_fail() { + do_cleanup + echo "Failed to run workload" + exit_unresolved +} + +do_fail() { + do_cleanup + echo "Test failed" + exit 1 +} + +enable_lodevtrace() { + if [ `cat $LODEVTRACE/enable` -ne 1 ]; then + echo 1 > $LODEVTRACE/enable + fi +} + +echo blk > current_tracer + +dd if=/dev/zero of=$IMG bs=1M count=10 &&\ +losetup $LODEV $IMG &&\ +mkfs.$FSTYPE $LODEV &&\ +mkdir -p $MNTDIR &&\ +mount -t $FSTYPE $LODEV $MNTDIR &&\ +enable_lodevtrace &&\ +dd if=/dev/urandom of=$MNTDIR/testfile bs=1M count=1 &&\ +sync &&\ +umount $MNTDIR || workload_fail + +grep -q "[dd]" trace || do_fail +grep -q "[umount]" trace || do_fail +echo > trace + +losetup $LODEV $IMG &&\ +mount -t $FSTYPE $LODEV $MNTDIR &&\ +cat $MNTDIR/testfile > /dev/null &&\ +echo 0 > $LODEVTRACE/enable &&\ +umount $MNTDIR || workload_fail + +grep -q "[cat]" trace || do_fail +grep -q "[mount]" trace || do_fail + +do_cleanup
Signature · 1 line
Masami Hiramatsu <mhiramat at kernel.org>