]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / cddl / contrib / opensolaris / cmd / dtrace / test / tst / common / usdt / tst.entryreturn.ksh
1 #
2 # CDDL HEADER START
3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
12 #
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 #
19 # CDDL HEADER END
20 #
21
22 #
23 # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24 # Use is subject to license terms.
25 #
26 # ident "%Z%%M% %I%     %E% SMI"
27
28 if [ $# != 1 ]; then
29         echo expected one argument: '<'dtrace-path'>'
30         exit 2
31 fi
32
33 dtrace=$1
34 DIR=/var/tmp/dtest.$$
35
36 mkdir $DIR
37 cd $DIR
38
39 cat > test.c <<EOF
40 #include <sys/sdt.h>
41
42 int
43 main(int argc, char **argv)
44 {
45         DTRACE_PROBE(test_prov, entry);
46         DTRACE_PROBE(test_prov, __entry);
47         DTRACE_PROBE(test_prov, foo__entry);
48         DTRACE_PROBE(test_prov, carpentry);
49         DTRACE_PROBE(test_prov, miniatureturn);
50         DTRACE_PROBE(test_prov, foo__return);
51         DTRACE_PROBE(test_prov, __return);
52         /*
53          * Unfortunately, a "return" probe is not currently possible due to
54          * the conflict with a reserved word.
55          */
56         DTRACE_PROBE(test_prov, done);
57 }
58 EOF
59
60 cat > prov.d <<EOF
61 provider test_prov {
62         probe entry();
63         probe __entry();
64         probe foo__entry();
65         probe carpentry();
66         probe miniatureturn();
67         probe foo__return();
68         probe __return();
69         probe done();
70 };
71 EOF
72
73 cc -c test.c
74 if [ $? -ne 0 ]; then
75         print -u2 "failed to compile test.c"
76         exit 1
77 fi
78 $dtrace -G -32 -s prov.d test.o
79 if [ $? -ne 0 ]; then
80         print -u2 "failed to create DOF"
81         exit 1
82 fi
83 cc -o test test.o prov.o
84 if [ $? -ne 0 ]; then
85         print -u2 "failed to link final executable"
86         exit 1
87 fi
88
89 script()
90 {
91         $dtrace -wqZFs /dev/stdin <<EOF
92         BEGIN
93         {
94                 system("$DIR/test");
95                 printf("\n");
96         }
97
98         test_prov*:::done
99         /progenyof(\$pid)/
100         {
101                 exit(0);
102         }
103
104         test_prov*:::
105         /progenyof(\$pid)/
106         {
107                 printf("\n");
108         }
109 EOF
110 }
111
112 script | cut -c5-
113 status=$?
114
115 cd /
116 /bin/rm -rf $DIR
117
118 exit $status