]> git.proxmox.com Git - mirror_ubuntu-kernels.git/blob - tools/testing/selftests/ftrace/test.d/instances/instance.tc
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-kernels.git] / tools / testing / selftests / ftrace / test.d / instances / instance.tc
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
3 # description: Test creation and deletion of trace instances
4
5 if [ ! -d instances ] ; then
6 echo "no instance directory with this kernel"
7 exit_unsupported;
8 fi
9
10 fail() { # mesg
11 rmdir x y z 2>/dev/null
12 echo $1
13 set -e
14 exit $FAIL
15 }
16
17 cd instances
18
19 # we don't want to fail on error
20 set +e
21
22 mkdir x
23 rmdir x
24 result=$?
25
26 if [ $result -ne 0 ]; then
27 echo "instance rmdir not supported"
28 exit_unsupported
29 fi
30
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
40 }
41
42 instance_slam &
43 p1=$!
44 echo $p1
45
46 instance_slam &
47 p2=$!
48 echo $p2
49
50 instance_slam &
51 p3=$!
52 echo $p3
53
54 instance_slam &
55 p4=$!
56 echo $p4
57
58 instance_slam &
59 p5=$!
60 echo $p5
61
62 ls -lR >/dev/null
63 sleep 1
64
65 kill -1 $p1
66 kill -1 $p2
67 kill -1 $p3
68 kill -1 $p4
69 kill -1 $p5
70
71 echo "Wait for processes to finish"
72 wait $p1 $p2 $p3 $p4 $p5
73 echo "all processes finished, wait for cleanup"
74
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"
81 fi
82 done
83
84 set -e
85
86 exit 0