-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tracing/selftest: Add selftests to test trace_marker histogram triggers
Add a couple of tests that test the trace_marker histogram triggers. One does a straight histogram test, the other will create a synthetic event and test the latency between two different writes (using filters to differentiate between them). Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Reviewed-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
- Loading branch information
Steven Rostedt (VMware)
committed
May 29, 2018
1 parent
922a418
commit c349d4a
Showing
2 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-hist.tc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/sh | ||
# SPDX-License-Identifier: GPL-2.0 | ||
# 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 | ||
} | ||
|
||
if [ ! -f set_event ]; then | ||
echo "event tracing is not supported" | ||
exit_unsupported | ||
fi | ||
|
||
if [ ! -d events/ftrace/print ]; then | ||
echo "event trace_marker is not supported" | ||
exit_unsupported | ||
fi | ||
|
||
if [ ! -f events/ftrace/print/trigger ]; then | ||
echo "event trigger is not supported" | ||
exit_unsupported | ||
fi | ||
|
||
if [ ! -f events/ftrace/print/hist ]; then | ||
echo "hist trigger is not supported" | ||
exit_unsupported | ||
fi | ||
|
||
do_reset | ||
|
||
echo "Test histogram trace_marker tigger" | ||
|
||
echo 'hist:keys=common_pid' > events/ftrace/print/trigger | ||
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 |
66 changes: 66 additions & 0 deletions
66
tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-synthetic.tc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/sh | ||
# SPDX-License-Identifier: GPL-2.0 | ||
# 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 | ||
} | ||
|
||
if [ ! -f set_event ]; then | ||
echo "event tracing is not supported" | ||
exit_unsupported | ||
fi | ||
|
||
if [ ! -f synthetic_events ]; then | ||
echo "synthetic events not supported" | ||
exit_unsupported | ||
fi | ||
|
||
if [ ! -d events/ftrace/print ]; then | ||
echo "event trace_marker is not supported" | ||
exit_unsupported | ||
fi | ||
|
||
if [ ! -f events/ftrace/print/trigger ]; then | ||
echo "event trigger is not supported" | ||
exit_unsupported | ||
fi | ||
|
||
if [ ! -f events/ftrace/print/hist ]; then | ||
echo "hist trigger is not supported" | ||
exit_unsupported | ||
fi | ||
|
||
do_reset | ||
|
||
echo "Test histogram trace_marker to trace_marker latency histogram trigger" | ||
|
||
echo 'latency u64 lat' > synthetic_events | ||
echo 'hist:keys=common_pid:ts0=common_timestamp.usecs if buf == "start"' > events/ftrace/print/trigger | ||
echo 'hist:keys=common_pid:lat=common_timestamp.usecs-$ts0:onmatch(ftrace.print).latency($lat) if buf == "end"' >> events/ftrace/print/trigger | ||
echo 'hist:keys=common_pid,lat:sort=lat' > events/synthetic/latency/trigger | ||
echo -n "start" > trace_marker | ||
echo -n "end" > trace_marker | ||
|
||
cnt=`grep 'hitcount: *1$' events/ftrace/print/hist | wc -l` | ||
|
||
if [ $cnt -ne 2 ]; then | ||
fail "hist trace_marker trigger did not trigger correctly" | ||
fi | ||
|
||
grep 'hitcount: *1$' events/synthetic/latency/hist > /dev/null || \ | ||
fail "hist trigger did not trigger " | ||
|
||
do_reset | ||
|
||
exit 0 |