Linux 4.8-rc8
[linux/fpc-iii.git] / tools / testing / selftests / ftrace / test.d / instances / instance.tc
blob1e1abe0ad354267507dc0514351d651e19fd1fb6
1 #!/bin/sh
2 # description: Test creation and deletion of trace instances
4 if [ ! -d instances ] ; then
5 echo "no instance directory with this kernel"
6 exit_unsupported;
7 fi
9 fail() { # mesg
10 rmdir x y z 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 x
33 mkdir y
34 mkdir z
35 rmdir x
36 rmdir y
37 rmdir z
38 done 2>/dev/null
41 instance_slam &
42 p1=$!
43 echo $p1
45 instance_slam &
46 p2=$!
47 echo $p2
49 instance_slam &
50 p3=$!
51 echo $p3
53 instance_slam &
54 p4=$!
55 echo $p4
57 instance_slam &
58 p5=$!
59 echo $p5
61 ls -lR >/dev/null
62 sleep 1
64 kill -1 $p1
65 kill -1 $p2
66 kill -1 $p3
67 kill -1 $p4
68 kill -1 $p5
70 echo "Wait for processes to finish"
71 wait $p1 $p2 $p3 $p4 $p5
72 echo "all processes finished, wait for cleanup"
74 mkdir x y z
75 ls x y z
76 rmdir x y z
77 for d in x y z; do
78 if [ -d $d ]; then
79 fail "instance $d still exists"
81 done
83 set -e
85 exit 0