diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2015-11-11 10:20:51 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2015-11-24 09:29:14 -0500 |
commit | 3cbd6a43be932e56907abd21091314dc044175f2 (patch) | |
tree | 907d0c73b877c21bd0a2c4197c38a5db582353a5 | |
parent | bd1b7cd360f529394936f28746eb4aaa12d6770a (diff) |
ftracetest: Add instance create and delete test
Create a test to test instance creation and deletion. Several tasks are
created that create 3 directories and delete them. The tasks all create the
same directories. This places a stress on the code that creates and deletes
instances.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | tools/testing/selftests/ftrace/test.d/instances/instance.tc | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/tools/testing/selftests/ftrace/test.d/instances/instance.tc b/tools/testing/selftests/ftrace/test.d/instances/instance.tc new file mode 100644 index 000000000000..773e276ff90b --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/instances/instance.tc | |||
@@ -0,0 +1,90 @@ | |||
1 | #!/bin/sh | ||
2 | # description: Test creation and deletion of trace instances | ||
3 | |||
4 | if [ ! -d instances ] ; then | ||
5 | echo "no instance directory with this kernel" | ||
6 | exit_unsupported; | ||
7 | fi | ||
8 | |||
9 | fail() { # mesg | ||
10 | rmdir x y z 2>/dev/null | ||
11 | echo $1 | ||
12 | set -e | ||
13 | exit $FAIL | ||
14 | } | ||
15 | |||
16 | cd instances | ||
17 | |||
18 | # we don't want to fail on error | ||
19 | set +e | ||
20 | |||
21 | mkdir x | ||
22 | rmdir x | ||
23 | result=$? | ||
24 | |||
25 | if [ $result -ne 0 ]; then | ||
26 | echo "instance rmdir not supported" | ||
27 | exit_unsupported | ||
28 | fi | ||
29 | |||
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 | ||
39 | } | ||
40 | |||
41 | instance_slam & | ||
42 | x=`jobs -l` | ||
43 | p1=`echo $x | cut -d' ' -f2` | ||
44 | echo $p1 | ||
45 | |||
46 | instance_slam & | ||
47 | x=`jobs -l | tail -1` | ||
48 | p2=`echo $x | cut -d' ' -f2` | ||
49 | echo $p2 | ||
50 | |||
51 | instance_slam & | ||
52 | x=`jobs -l | tail -1` | ||
53 | p3=`echo $x | cut -d' ' -f2` | ||
54 | echo $p3 | ||
55 | |||
56 | instance_slam & | ||
57 | x=`jobs -l | tail -1` | ||
58 | p4=`echo $x | cut -d' ' -f2` | ||
59 | echo $p4 | ||
60 | |||
61 | instance_slam & | ||
62 | x=`jobs -l | tail -1` | ||
63 | p5=`echo $x | cut -d' ' -f2` | ||
64 | echo $p5 | ||
65 | |||
66 | ls -lR >/dev/null | ||
67 | sleep 1 | ||
68 | |||
69 | kill -1 $p1 | ||
70 | kill -1 $p2 | ||
71 | kill -1 $p3 | ||
72 | kill -1 $p4 | ||
73 | kill -1 $p5 | ||
74 | |||
75 | echo "Wait for processes to finish" | ||
76 | wait $p1 $p2 $p3 $p4 $p5 | ||
77 | echo "all processes finished, wait for cleanup" | ||
78 | |||
79 | mkdir x y z | ||
80 | ls x y z | ||
81 | rmdir x y z | ||
82 | for d in x y z; do | ||
83 | if [ -d $d ]; then | ||
84 | fail "instance $d still exists" | ||
85 | fi | ||
86 | done | ||
87 | |||
88 | set -e | ||
89 | |||
90 | exit 0 | ||