Skip to content

Commit

Permalink
selftests/ftrace: Introduce exit_pass and exit_fail
Browse files Browse the repository at this point in the history
As same as other results, introduce exit_pass and exit_fail
functions so that we can easily understand what will happen.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
  • Loading branch information
Masami Hiramatsu authored and Shuah Khan committed Nov 15, 2017
1 parent f737b8f commit 42534b1
Show file tree
Hide file tree
Showing 28 changed files with 35 additions and 28 deletions.
7 changes: 7 additions & 0 deletions tools/testing/selftests/ftrace/ftracetest
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,14 @@ SIG_RESULT=
SIG_BASE=36 # Use realtime signals
SIG_PID=$$

exit_pass () {
exit 0
}

SIG_FAIL=$((SIG_BASE + FAIL))
exit_fail () {
exit 1
}
trap 'SIG_RESULT=$FAIL' $SIG_FAIL

SIG_UNRESOLVED=$((SIG_BASE + UNRESOLVED))
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/ftrace/test.d/00basic/basic4.tc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# description: Basic event tracing check
test -f available_events -a -f set_event -a -d events
# check scheduler events are available
grep -q sched available_events && exit 0 || exit $FAIL
grep -q sched available_events && exit_pass || exit_fail
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ do_reset() {
fail() { #msg
do_reset
echo $1
exit $FAIL
exit_fail
}

yield() {
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/ftrace/test.d/event/event-pid.tc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ do_reset() {
fail() { #msg
do_reset
echo $1
exit $FAIL
exit_fail
}

yield() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ do_reset() {
fail() { #msg
do_reset
echo $1
exit $FAIL
exit_fail
}

yield() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ do_reset() {
fail() { #msg
do_reset
echo $1
exit $FAIL
exit_fail
}

yield() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ do_reset() {
fail() { # msg
do_reset
echo $1
exit $FAIL
exit_fail
}

disable_tracing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ do_reset() {
fail() { # msg
do_reset
echo $1
exit $FAIL
exit_fail
}

disable_tracing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ do_reset() {
fail() { # msg
do_reset
echo $1
exit $FAIL
exit_fail
}

yield() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ do_reset() {
fail() { # mesg
do_reset
echo $1
exit $FAIL
exit_fail
}

SLEEP_TIME=".1"
Expand All @@ -48,8 +48,7 @@ test_event_enabled() {

e=`cat $EVENT_ENABLE`
if [ "$e" != $val ]; then
echo "Expected $val but found $e"
exit 1
fail "Expected $val but found $e"
fi
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fail() { # mesg
reset_tracer
echo > set_ftrace_filter
echo $1
exit $FAIL
exit_fail
}

echo "Testing function tracer with profiler:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ do_reset() {
fail() { # mesg
do_reset
echo $1
exit $FAIL
exit_fail
}

do_reset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ do_reset() {
fail() { # mesg
do_reset
echo $1
exit $FAIL
exit_fail
}

SLEEP_TIME=".1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fail() { # mesg
rmdir foo 2>/dev/null
echo $1
set -e
exit $FAIL
exit_fail
}

cd instances
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fail() { # mesg
rmdir x y z 2>/dev/null
echo $1
set -e
exit $FAIL
exit_fail
}

cd instances
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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 1 # this must fail
echo > kprobe_events && exit_fail # this must fail
echo 0 > events/kprobes/myevent/enable
echo > kprobe_events # this must succeed
clear_trace
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ echo 1 > events/kprobes/testprobe/enable
echo 0 > events/kprobes/testprobe/enable
echo "-:testprobe" >> kprobe_events
clear_trace
test -d events/kprobes/testprobe && exit 1 || exit 0
test -d events/kprobes/testprobe && exit_fail || exit_pass

Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ check_types $ARGS

echo "-:testprobe" >> kprobe_events
clear_trace
test -d events/kprobes/testprobe && exit 1 || exit 0
test -d events/kprobes/testprobe && exit_fail || exit_pass
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ echo 1 > events/kprobes/testprobe2/enable
echo 0 > events/kprobes/testprobe2/enable
echo '-:testprobe2' >> kprobe_events
clear_trace
test -d events/kprobes/testprobe2 && exit 1 || exit 0
test -d events/kprobes/testprobe2 && exit_fail || exit_pass
1 change: 1 addition & 0 deletions tools/testing/selftests/ftrace/test.d/template
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Note that all tests are run with "errexit" option.

exit 0 # Return 0 if the test is passed, otherwise return !0
# Or you can call exit_pass for passed test, and exit_fail for failed test.
# If the test could not run because of lack of feature, call exit_unsupported
# If the test returned unclear results, call exit_unresolved
# If the test is a dummy, or a placeholder, call exit_untested
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ do_reset() {
fail() { #msg
do_reset
echo $1
exit $FAIL
exit_fail
}

if [ ! -f set_event -o ! -d events/sched ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ do_reset() {
fail() { #msg
do_reset
echo $1
exit $FAIL
exit_fail
}

if [ ! -f set_event -o ! -d events/sched ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ do_reset() {
fail() { #msg
do_reset
echo $1
exit $FAIL
exit_fail
}

if [ ! -f set_event -o ! -d events/sched ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ do_reset() {
fail() { #msg
do_reset
echo $1
exit $FAIL
exit_fail
}

if [ ! -f set_event -o ! -d events/sched ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ do_reset() {
fail() { #msg
do_reset
echo $1
exit $FAIL
exit_fail
}

if [ ! -f set_event -o ! -d events/sched ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ do_reset() {
fail() { #msg
do_reset
echo $1
exit $FAIL
exit_fail
}

if [ ! -f set_event -o ! -d events/sched ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ do_reset() {
fail() { #msg
do_reset
echo $1
exit $FAIL
exit_fail
}

if [ ! -f set_event -o ! -d events/sched ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ do_reset() {
fail() { #msg
do_reset
echo $1
exit $FAIL
exit_fail
}

if [ ! -f set_event -o ! -d events/sched ]; then
Expand Down

0 comments on commit 42534b1

Please sign in to comment.