xref: /linux/tools/testing/selftests/ftrace/test.d/instances/instance.tc (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# description: Test creation and deletion of trace instances
4# requires: instances
5
6fail() { # mesg
7    rmdir x y z 2>/dev/null
8    echo $1
9    set -e
10    exit_fail
11}
12
13cd instances
14
15# we don't want to fail on error
16set +e
17
18mkdir x
19rmdir x
20result=$?
21
22if [ $result -ne 0 ]; then
23    echo "instance rmdir not supported"
24    exit_unsupported
25fi
26
27instance_slam() {
28    while :; do
29	mkdir x
30	mkdir y
31	mkdir z
32	rmdir x
33	rmdir y
34	rmdir z
35    done 2>/dev/null
36}
37
38instance_slam &
39p1=$!
40echo $p1
41
42instance_slam &
43p2=$!
44echo $p2
45
46instance_slam &
47p3=$!
48echo $p3
49
50instance_slam &
51p4=$!
52echo $p4
53
54instance_slam &
55p5=$!
56echo $p5
57
58ls -lR >/dev/null
59sleep 1
60
61kill -1 $p1
62kill -1 $p2
63kill -1 $p3
64kill -1 $p4
65kill -1 $p5
66
67echo "Wait for processes to finish"
68wait $p1 $p2 $p3 $p4 $p5
69echo "all processes finished, wait for cleanup"
70
71mkdir x y z
72ls x y z
73rmdir x y z
74for d in x y z; do
75        if [ -d $d ]; then
76                fail "instance $d still exists"
77        fi
78done
79
80set -e
81
82exit 0
83