License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-2.6/btrfs-unstable.git] / tools / testing / selftests / ftrace / test.d / instances / instance.tc
blobddda622033664a50af8556df1d50c863f07f5866
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
3 # description: Test creation and deletion of trace instances
5 if [ ! -d instances ] ; then
6 echo "no instance directory with this kernel"
7 exit_unsupported;
8 fi
10 fail() { # mesg
11 rmdir x y z 2>/dev/null
12 echo $1
13 set -e
14 exit $FAIL
17 cd instances
19 # we don't want to fail on error
20 set +e
22 mkdir x
23 rmdir x
24 result=$?
26 if [ $result -ne 0 ]; then
27 echo "instance rmdir not supported"
28 exit_unsupported
31 instance_slam() {
32 while :; do
33 mkdir x
34 mkdir y
35 mkdir z
36 rmdir x
37 rmdir y
38 rmdir z
39 done 2>/dev/null
42 instance_slam &
43 p1=$!
44 echo $p1
46 instance_slam &
47 p2=$!
48 echo $p2
50 instance_slam &
51 p3=$!
52 echo $p3
54 instance_slam &
55 p4=$!
56 echo $p4
58 instance_slam &
59 p5=$!
60 echo $p5
62 ls -lR >/dev/null
63 sleep 1
65 kill -1 $p1
66 kill -1 $p2
67 kill -1 $p3
68 kill -1 $p4
69 kill -1 $p5
71 echo "Wait for processes to finish"
72 wait $p1 $p2 $p3 $p4 $p5
73 echo "all processes finished, wait for cleanup"
75 mkdir x y z
76 ls x y z
77 rmdir x y z
78 for d in x y z; do
79 if [ -d $d ]; then
80 fail "instance $d still exists"
82 done
84 set -e
86 exit 0