From: Steven Rostedt <[email protected]>

The instance selftest creates and removes the "foo" instance while
enabling sched_switch event and reading its trace file. The issue is that
the read of the trace file prevents the removal of foo, and it constantly
fails to remove it. The stress test is not really stressing the situation.

Instead of running the creating and deletion in a loop as a separate
process and sleeping for one second, call it directly in a loop that forces
it to happen 10 times.  Also update the removal to keep trying until it
removes the instance, otherwise if it doesn't remove it then the next mkdir
is a nop.

Convert the reading of the trace file to use "head" instead of "cat" so it
is limited in how much it reads and add a .1 sleep in between reads. This
gives the removal of the instance time to succeed.

Fixes: 91e6f1ce86577 ("ftracetest: Add instance created, delete, read and 
enable event test")
Signed-off-by: Steven Rostedt <[email protected]>
---
 .../ftrace/test.d/instances/instance-event.tc | 26 +++++++++----------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc 
b/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc
index 42422e425107..b0e9d3abbf2f 100644
--- a/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc
+++ b/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc
@@ -25,15 +25,16 @@ if [ $result -ne 0 ]; then
 fi
 
 instance_slam() {
-        while :; do
-                mkdir foo 2> /dev/null
-                rmdir foo 2> /dev/null
-        done
+       mkdir foo 2> /dev/null
+       while ! rmdir foo; do
+               echo could not rmdir foo
+       done
 }
 
 instance_read() {
         while :; do
-                cat foo/trace 1> /dev/null 2>&1
+                head foo/trace 1> /dev/null 2>&1
+               sleep 0.1
         done
 }
 
@@ -43,26 +44,23 @@ instance_set() {
         done 2> /dev/null
 }
 
-instance_slam &
+instance_set &
 p1=$!
 echo $p1
 
-instance_set &
+instance_read &
 p2=$!
 echo $p2
 
-instance_read &
-p3=$!
-echo $p3
-
-sleep 1
+for i in `seq 10`; do
+       instance_slam
+done
 
-kill -1 $p3
 kill -1 $p2
 kill -1 $p1
 
 echo "Wait for processes to finish"
-wait $p1 $p2 $p3
+wait $p1 $p2
 echo "all processes finished, wait for cleanup"
 sleep 1
 
-- 
2.53.0

Reply via email to