-
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.
ftracetest: Add instance created, delete, read and enable event test
Add a new ftrace test that creates three threads. One that creates and removes an ftrace instance, one that reads the instance, and one that enables and disables events in the instance. This is a stress test for accessing and removing instances at the same time. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
- Loading branch information
Steven Rostedt (Red Hat)
committed
May 9, 2016
1 parent
0fc1b09
commit 91e6f1c
Showing
1 changed file
with
143 additions
and
0 deletions.
There are no files selected for viewing
143 changes: 143 additions & 0 deletions
143
tools/testing/selftests/ftrace/test.d/instances/instance-event.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,143 @@ | ||
#!/bin/sh | ||
# description: Test creation and deletion of trace instances while setting an event | ||
|
||
if [ ! -d instances ] ; then | ||
echo "no instance directory with this kernel" | ||
exit_unsupported; | ||
fi | ||
|
||
fail() { # mesg | ||
rmdir foo 2>/dev/null | ||
echo $1 | ||
set -e | ||
exit $FAIL | ||
} | ||
|
||
cd instances | ||
|
||
# we don't want to fail on error | ||
set +e | ||
|
||
mkdir x | ||
rmdir x | ||
result=$? | ||
|
||
if [ $result -ne 0 ]; then | ||
echo "instance rmdir not supported" | ||
exit_unsupported | ||
fi | ||
|
||
instance_slam() { | ||
while :; do | ||
mkdir foo 2> /dev/null | ||
rmdir foo 2> /dev/null | ||
done | ||
} | ||
|
||
instance_read() { | ||
while :; do | ||
cat foo/trace 1> /dev/null 2>&1 | ||
done | ||
} | ||
|
||
instance_set() { | ||
while :; do | ||
echo 1 > foo/events/sched/sched_switch | ||
done 2> /dev/null | ||
} | ||
|
||
instance_slam & | ||
p1=$! | ||
echo $p1 | ||
|
||
instance_set & | ||
p2=$! | ||
echo $p2 | ||
|
||
instance_read & | ||
p3=$! | ||
echo $p3 | ||
|
||
sleep 1 | ||
|
||
kill -1 $p3 | ||
kill -1 $p2 | ||
kill -1 $p1 | ||
|
||
echo "Wait for processes to finish" | ||
wait $p1 $p2 $p3 | ||
echo "all processes finished, wait for cleanup" | ||
sleep 1 | ||
|
||
mkdir foo | ||
ls foo > /dev/null | ||
rmdir foo | ||
if [ -d foo ]; then | ||
fail "foo still exists" | ||
fi | ||
exit 0 | ||
|
||
|
||
|
||
|
||
instance_slam() { | ||
while :; do | ||
mkdir x | ||
mkdir y | ||
mkdir z | ||
rmdir x | ||
rmdir y | ||
rmdir z | ||
done 2>/dev/null | ||
} | ||
|
||
instance_slam & | ||
x=`jobs -l` | ||
p1=`echo $x | cut -d' ' -f2` | ||
echo $p1 | ||
|
||
instance_slam & | ||
x=`jobs -l | tail -1` | ||
p2=`echo $x | cut -d' ' -f2` | ||
echo $p2 | ||
|
||
instance_slam & | ||
x=`jobs -l | tail -1` | ||
p3=`echo $x | cut -d' ' -f2` | ||
echo $p3 | ||
|
||
instance_slam & | ||
x=`jobs -l | tail -1` | ||
p4=`echo $x | cut -d' ' -f2` | ||
echo $p4 | ||
|
||
instance_slam & | ||
x=`jobs -l | tail -1` | ||
p5=`echo $x | cut -d' ' -f2` | ||
echo $p5 | ||
|
||
ls -lR >/dev/null | ||
sleep 1 | ||
|
||
kill -1 $p1 | ||
kill -1 $p2 | ||
kill -1 $p3 | ||
kill -1 $p4 | ||
kill -1 $p5 | ||
|
||
echo "Wait for processes to finish" | ||
wait $p1 $p2 $p3 $p4 $p5 | ||
echo "all processes finished, wait for cleanup" | ||
|
||
mkdir x y z | ||
ls x y z | ||
rmdir x y z | ||
for d in x y z; do | ||
if [ -d $d ]; then | ||
fail "instance $d still exists" | ||
fi | ||
done | ||
|
||
set -e | ||
|
||
exit 0 |