drm/panel-edp: Add STA 116QHD024002
[drm/drm-misc.git] / tools / testing / selftests / ftrace / test.d / instances / instance-event.tc
blob42422e4251078729bb773d859283a0954c656f27
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
3 # description: Test creation and deletion of trace instances while setting an event
4 # requires: instances
6 fail() { # mesg
7 rmdir foo 2>/dev/null
8 echo $1
9 set -e
10 exit_fail
13 cd instances
15 # we don't want to fail on error
16 set +e
18 mkdir x
19 rmdir x
20 result=$?
22 if [ $result -ne 0 ]; then
23 echo "instance rmdir not supported"
24 exit_unsupported
27 instance_slam() {
28 while :; do
29 mkdir foo 2> /dev/null
30 rmdir foo 2> /dev/null
31 done
34 instance_read() {
35 while :; do
36 cat foo/trace 1> /dev/null 2>&1
37 done
40 instance_set() {
41 while :; do
42 echo 1 > foo/events/sched/sched_switch/enable
43 done 2> /dev/null
46 instance_slam &
47 p1=$!
48 echo $p1
50 instance_set &
51 p2=$!
52 echo $p2
54 instance_read &
55 p3=$!
56 echo $p3
58 sleep 1
60 kill -1 $p3
61 kill -1 $p2
62 kill -1 $p1
64 echo "Wait for processes to finish"
65 wait $p1 $p2 $p3
66 echo "all processes finished, wait for cleanup"
67 sleep 1
69 mkdir foo
70 ls foo > /dev/null
71 rmdir foo
72 if [ -d foo ]; then
73 fail "foo still exists"
76 mkdir foo
77 echo "schedule:enable_event:sched:sched_switch" > foo/set_ftrace_filter
78 rmdir foo
79 if [ -d foo ]; then
80 fail "foo still exists"
82 if grep -q "schedule:enable_event:sched:sched_switch" ../set_ftrace_filter; then
83 echo "Older kernel detected. Cleanup filter"
84 echo '!schedule:enable_event:sched:sched_switch' > ../set_ftrace_filter
87 instance_slam() {
88 while :; do
89 mkdir x
90 mkdir y
91 mkdir z
92 rmdir x
93 rmdir y
94 rmdir z
95 done 2>/dev/null
98 instance_slam &
99 p1=$!
100 echo $p1
102 instance_slam &
103 p2=$!
104 echo $p2
106 instance_slam &
107 p3=$!
108 echo $p3
110 instance_slam &
111 p4=$!
112 echo $p4
114 instance_slam &
115 p5=$!
116 echo $p5
118 ls -lR >/dev/null
119 sleep 1
121 kill -1 $p1
122 kill -1 $p2
123 kill -1 $p3
124 kill -1 $p4
125 kill -1 $p5
127 echo "Wait for processes to finish"
128 wait $p1 $p2 $p3 $p4 $p5
129 echo "all processes finished, wait for cleanup"
131 mkdir x y z
132 ls x y z
133 rmdir x y z
134 for d in x y z; do
135 if [ -d $d ]; then
136 fail "instance $d still exists"
138 done
140 set -e
142 exit 0