Linux 4.8-rc8
[linux/fpc-iii.git] / tools / testing / selftests / ftrace / test.d / instances / instance-event.tc
blob4c5a061a5b4e6d522396714de21f64b871e23ab4
1 #!/bin/sh
2 # description: Test creation and deletion of trace instances while setting an event
4 if [ ! -d instances ] ; then
5 echo "no instance directory with this kernel"
6 exit_unsupported;
7 fi
9 fail() { # mesg
10 rmdir foo 2>/dev/null
11 echo $1
12 set -e
13 exit $FAIL
16 cd instances
18 # we don't want to fail on error
19 set +e
21 mkdir x
22 rmdir x
23 result=$?
25 if [ $result -ne 0 ]; then
26 echo "instance rmdir not supported"
27 exit_unsupported
30 instance_slam() {
31 while :; do
32 mkdir foo 2> /dev/null
33 rmdir foo 2> /dev/null
34 done
37 instance_read() {
38 while :; do
39 cat foo/trace 1> /dev/null 2>&1
40 done
43 instance_set() {
44 while :; do
45 echo 1 > foo/events/sched/sched_switch
46 done 2> /dev/null
49 instance_slam &
50 p1=$!
51 echo $p1
53 instance_set &
54 p2=$!
55 echo $p2
57 instance_read &
58 p3=$!
59 echo $p3
61 sleep 1
63 kill -1 $p3
64 kill -1 $p2
65 kill -1 $p1
67 echo "Wait for processes to finish"
68 wait $p1 $p2 $p3
69 echo "all processes finished, wait for cleanup"
70 sleep 1
72 mkdir foo
73 ls foo > /dev/null
74 rmdir foo
75 if [ -d foo ]; then
76 fail "foo still exists"
78 exit 0
83 instance_slam() {
84 while :; do
85 mkdir x
86 mkdir y
87 mkdir z
88 rmdir x
89 rmdir y
90 rmdir z
91 done 2>/dev/null
94 instance_slam &
95 p1=$!
96 echo $p1
98 instance_slam &
99 p2=$!
100 echo $p2
102 instance_slam &
103 p3=$!
104 echo $p3
106 instance_slam &
107 p4=$!
108 echo $p4
110 instance_slam &
111 p5=$!
112 echo $p5
114 ls -lR >/dev/null
115 sleep 1
117 kill -1 $p1
118 kill -1 $p2
119 kill -1 $p3
120 kill -1 $p4
121 kill -1 $p5
123 echo "Wait for processes to finish"
124 wait $p1 $p2 $p3 $p4 $p5
125 echo "all processes finished, wait for cleanup"
127 mkdir x y z
128 ls x y z
129 rmdir x y z
130 for d in x y z; do
131 if [ -d $d ]; then
132 fail "instance $d still exists"
134 done
136 set -e
138 exit 0