Skip to content

Commit

Permalink
Merge tag 'linux-kselftest-5.8-rc2' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/shuah/linux-kselftest

Pull kselftest cleanups from Shuah Khan:

 - ftrace "requires:" list for simplifying and unifying requirement
   checks for each test case, adding "requires:" line instead of
   checking required ftrace interfaces in each test case.

 - a minor spelling correction patch

* tag 'linux-kselftest-5.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
  selftests/ftrace: Support ":README" suffix for requires
  selftests/ftrace: Support ":tracer" suffix for requires
  selftests/ftrace: Convert check_filter_file() with requires list
  selftests/ftrace: Convert required interface checks into requires list
  selftests/ftrace: Add "requires:" list support
  selftests/ftrace: Return unsupported for the unconfigured features
  selftests/ftrace: Allow ":" in description
  tools: testing: ftrace: trigger: fix spelling mistake
  • Loading branch information
Linus Torvalds committed Jun 20, 2020
2 parents 5481fc6 + 1b8eec5 commit 27c2760
Show file tree
Hide file tree
Showing 80 changed files with 123 additions and 637 deletions.
11 changes: 9 additions & 2 deletions tools/testing/selftests/ftrace/ftracetest
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,16 @@ CASENO=0

testcase() { # testfile
CASENO=$((CASENO+1))
desc=`grep "^#[ \t]*description:" $1 | cut -f2 -d:`
desc=`grep "^#[ \t]*description:" $1 | cut -f2- -d:`
prlog -n "[$CASENO]$INSTANCE$desc"
}

checkreq() { # testfile
requires=`grep "^#[ \t]*requires:" $1 | cut -f2- -d:`
# Use eval to pass quoted-patterns correctly.
eval check_requires "$requires"
}

test_on_instance() { # testfile
grep -q "^#[ \t]*flags:.*instance" $1
}
Expand Down Expand Up @@ -356,7 +362,8 @@ trap 'SIG_RESULT=$XFAIL' $SIG_XFAIL

__run_test() { # testfile
# setup PID and PPID, $$ is not updated.
(cd $TRACING_DIR; read PID _ < /proc/self/stat; set -e; set -x; initialize_ftrace; . $1)
(cd $TRACING_DIR; read PID _ < /proc/self/stat; set -e; set -x;
checkreq $1; initialize_ftrace; . $1)
[ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID
}

Expand Down
3 changes: 1 addition & 2 deletions tools/testing/selftests/ftrace/test.d/00basic/snapshot.tc
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/bin/sh
# description: Snapshot and tracing setting
# requires: snapshot
# flags: instance

[ ! -f snapshot ] && exit_unsupported

echo "Set tracing off"
echo 0 > tracing_on

Expand Down
3 changes: 1 addition & 2 deletions tools/testing/selftests/ftrace/test.d/00basic/trace_pipe.tc
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: trace_pipe and trace_marker
# requires: trace_marker
# flags: instance

[ ! -f trace_marker ] && exit_unsupported

echo "test input 1" > trace_marker

: "trace interface never consume the ring buffer"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: Test ftrace direct functions against kprobes
# requires: kprobe_events

rmmod ftrace-direct ||:
if ! modprobe ftrace-direct ; then
echo "No ftrace-direct sample module - please build with CONFIG_SAMPLE_FTRACE_DIRECT=m"
exit_unresolved;
fi

if [ ! -f kprobe_events ]; then
echo "No kprobe_events file -please build CONFIG_KPROBE_EVENTS"
exit_unresolved;
fi

echo "Let the module run a little"
sleep 1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: Generic dynamic event - add/remove kprobe events

[ -f dynamic_events ] || exit_unsupported

grep -q "place: \[<module>:\]<symbol>" README || exit_unsupported
grep -q "place (kretprobe): \[<module>:\]<symbol>" README || exit_unsupported
# requires: dynamic_events "place: [<module>:]<symbol>":README "place (kretprobe): [<module>:]<symbol>":README

echo 0 > events/enable
echo > dynamic_events
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: Generic dynamic event - add/remove synthetic events

[ -f dynamic_events ] || exit_unsupported

grep -q "s:\[synthetic/\]" README || exit_unsupported
# requires: dynamic_events "s:[synthetic/]":README

echo 0 > events/enable
echo > dynamic_events
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: Generic dynamic event - selective clear (compatibility)

[ -f dynamic_events ] || exit_unsupported

grep -q "place: \[<module>:\]<symbol>" README || exit_unsupported
grep -q "place (kretprobe): \[<module>:\]<symbol>" README || exit_unsupported

grep -q "s:\[synthetic/\]" README || exit_unsupported

[ -f synthetic_events ] || exit_unsupported
[ -f kprobe_events ] || exit_unsupported
# requires: dynamic_events kprobe_events synthetic_events "place: [<module>:]<symbol>":README "place (kretprobe): [<module>:]<symbol>":README "s:[synthetic/]":README

echo 0 > events/enable
echo > dynamic_events
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: Generic dynamic event - generic clear event

[ -f dynamic_events ] || exit_unsupported

grep -q "place: \[<module>:\]<symbol>" README || exit_unsupported
grep -q "place (kretprobe): \[<module>:\]<symbol>" README || exit_unsupported

grep -q "s:\[synthetic/\]" README || exit_unsupported
# requires: dynamic_events "place: [<module>:]<symbol>":README "place (kretprobe): [<module>:]<symbol>":README "s:[synthetic/]":README

echo 0 > events/enable
echo > dynamic_events
Expand Down
6 changes: 1 addition & 5 deletions tools/testing/selftests/ftrace/test.d/event/event-enable.tc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: event tracing - enable/disable with event level files
# requires: set_event events/sched
# flags: instance

do_reset() {
Expand All @@ -13,11 +14,6 @@ fail() { #msg
exit_fail
}

if [ ! -f set_event -o ! -d events/sched ]; then
echo "event tracing is not supported"
exit_unsupported
fi

echo 'sched:sched_switch' > set_event

yield
Expand Down
11 changes: 1 addition & 10 deletions tools/testing/selftests/ftrace/test.d/event/event-no-pid.tc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: event tracing - restricts events based on pid notrace filtering
# requires: set_event events/sched set_event_pid set_event_notrace_pid
# flags: instance

do_reset() {
Expand Down Expand Up @@ -56,16 +57,6 @@ enable_events() {
echo 1 > tracing_on
}

if [ ! -f set_event -o ! -d events/sched ]; then
echo "event tracing is not supported"
exit_unsupported
fi

if [ ! -f set_event_pid -o ! -f set_event_notrace_pid ]; then
echo "event pid notrace filtering is not supported"
exit_unsupported
fi

echo 0 > options/event-fork

do_reset
Expand Down
11 changes: 1 addition & 10 deletions tools/testing/selftests/ftrace/test.d/event/event-pid.tc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: event tracing - restricts events based on pid
# requires: set_event set_event_pid events/sched
# flags: instance

do_reset() {
Expand All @@ -16,16 +17,6 @@ fail() { #msg
exit_fail
}

if [ ! -f set_event -o ! -d events/sched ]; then
echo "event tracing is not supported"
exit_unsupported
fi

if [ ! -f set_event_pid ]; then
echo "event pid filtering is not supported"
exit_unsupported
fi

echo 0 > options/event-fork

echo 1 > events/sched/sched_switch/enable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: event tracing - enable/disable with subsystem level files
# requires: set_event events/sched/enable
# flags: instance

do_reset() {
Expand All @@ -13,11 +14,6 @@ fail() { #msg
exit_fail
}

if [ ! -f set_event -o ! -d events/sched ]; then
echo "event tracing is not supported"
exit_unsupported
fi

echo 'sched:*' > set_event

yield
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: event tracing - enable/disable with top level files
# requires: available_events set_event events/enable

do_reset() {
echo > set_event
Expand All @@ -12,11 +13,6 @@ fail() { #msg
exit_fail
}

if [ ! -f available_events -o ! -f set_event -o ! -d events ]; then
echo "event tracing is not supported"
exit_unsupported
fi

echo '*:*' > set_event

yield
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: ftrace - function graph filters with stack tracer
# requires: stack_trace set_ftrace_filter function_graph:tracer

# Make sure that function graph filtering works, and is not
# affected by other tracers enabled (like stack tracer)

if ! grep -q function_graph available_tracers; then
echo "no function graph tracer configured"
exit_unsupported
fi

check_filter_file set_ftrace_filter

do_reset() {
if [ -e /proc/sys/kernel/stack_tracer_enabled ]; then
echo 0 > /proc/sys/kernel/stack_tracer_enabled
Expand All @@ -37,12 +31,6 @@ fi

echo function_graph > current_tracer

if [ ! -f stack_trace ]; then
echo "Stack tracer not configured"
do_reset
exit_unsupported;
fi

echo "Now testing with stack tracer"

echo 1 > /proc/sys/kernel/stack_tracer_enabled
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: ftrace - function graph filters
# requires: set_ftrace_filter function_graph:tracer

# Make sure that function graph filtering works

if ! grep -q function_graph available_tracers; then
echo "no function graph tracer configured"
exit_unsupported
fi

check_filter_file set_ftrace_filter

fail() { # msg
echo $1
exit_fail
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: ftrace - function glob filters
# requires: set_ftrace_filter function:tracer

# Make sure that function glob matching filter works.

if ! grep -q function available_tracers; then
echo "no function tracer configured"
exit_unsupported
fi

check_filter_file set_ftrace_filter

disable_tracing
clear_trace

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: ftrace - function pid notrace filters
# requires: set_ftrace_notrace_pid set_ftrace_filter function:tracer
# flags: instance

# Make sure that function pid matching filter with notrace works.

if ! grep -q function available_tracers; then
echo "no function tracer configured"
exit_unsupported
fi

if [ ! -f set_ftrace_notrace_pid ]; then
echo "set_ftrace_notrace_pid not found? Is function tracer not set?"
exit_unsupported
fi

check_filter_file set_ftrace_filter

do_function_fork=1

if [ ! -f options/function-fork ]; then
Expand Down
13 changes: 1 addition & 12 deletions tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: ftrace - function pid filters
# requires: set_ftrace_pid set_ftrace_filter function:tracer
# flags: instance

# Make sure that function pid matching filter works.
# Also test it on an instance directory

if ! grep -q function available_tracers; then
echo "no function tracer configured"
exit_unsupported
fi

if [ ! -f set_ftrace_pid ]; then
echo "set_ftrace_pid not found? Is function tracer not set?"
exit_unsupported
fi

check_filter_file set_ftrace_filter

do_function_fork=1

if [ ! -f options/function-fork ]; then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: ftrace - stacktrace filter command
# requires: set_ftrace_filter
# flags: instance

check_filter_file set_ftrace_filter

echo _do_fork:stacktrace >> set_ftrace_filter

grep -q "_do_fork:stacktrace:unlimited" set_ftrace_filter
Expand Down
6 changes: 1 addition & 5 deletions tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: ftrace - function trace with cpumask
# requires: function:tracer

if ! which nproc ; then
nproc() {
Expand All @@ -15,11 +16,6 @@ if [ $NP -eq 1 ] ;then
exit_unresolved
fi

if ! grep -q "function" available_tracers ; then
echo "Function trace is not enabled"
exit_unsupported
fi

ORIG_CPUMASK=`cat tracing_cpumask`

do_reset() {
Expand Down
Loading

0 comments on commit 27c2760

Please sign in to comment.