]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh
Update to bmake-20200704
[FreeBSD/FreeBSD.git] / cddl / contrib / opensolaris / cmd / dtrace / test / tst / common / usdt / tst.sameprovmulti.ksh
1 #
2 # This file and its contents are supplied under the terms of the
3 # Common Development and Distribution License ("CDDL"), version 1.0.
4 # You may only use this file in accordance with the terms of version
5 # 1.0 of the CDDL.
6 #
7 # A full copy of the text of the CDDL should have accompanied this
8 # source.  A copy of the CDDL is also available via the Internet at
9 # http://www.illumos.org/license/CDDL.
10 #
11
12 #
13 # Copyright (c) 2015, Joyent, Inc. All rights reserved.
14 #
15
16 #
17 # This test assures that we can have the same provider name across multiple
18 # probe definitions, and that the result will be the union of those
19 # definitions.  In particular, libusdt depends on this when (for example)
20 # node modules that create a provider are loaded multiple times due to
21 # being included by different modules.
22 #
23
24 if [ $# != 1 ]; then
25         echo expected one argument: '<'dtrace-path'>'
26         exit 2
27 fi
28
29 dtrace=$1
30 DIR=/var/tmp/dtest.$$
31
32 mkdir $DIR
33 cd $DIR
34
35 cat > test.c <<EOF
36 #include <unistd.h>
37
38 void
39 main()
40 {
41 EOF
42
43 objs=
44
45 for oogle in bagnoogle stalloogle cockoogle; do
46         cat > $oogle.c <<EOF
47 #include <sys/sdt.h>
48
49 void
50 $oogle()
51 {
52         DTRACE_PROBE(doogle, $oogle);
53 }
54 EOF
55
56         cat > $oogle.d <<EOF
57 provider doogle {
58         probe $oogle();
59 };
60 EOF
61
62         cc -c $oogle.c
63
64         if [ $? -ne 0 ]; then
65                 print -u2 "failed to compile $oogle.c"
66                 exit 1
67         fi
68
69         $dtrace -G -s $oogle.d $oogle.o -o $oogle.d.o
70
71         if [ $? -ne 0 ]; then
72                 print -u2 "failed to process $oogle.d"
73                 exit 1
74         fi
75
76         objs="$objs $oogle.o $oogle.d.o"
77         echo $oogle'();' >> test.c
78 done
79
80 echo "}" >> test.c
81
82 cc -o test test.c $objs
83
84 if [ $? -ne 0 ]; then
85         print -u2 "failed to compile test.c"
86         exit 1
87 fi
88
89 $dtrace -n 'doogle$target:::{@[probename] = count()}' \
90     -n 'END{printa("%-10s %@d\n", @)}' -x quiet -x aggsortkey -Zc ./test
91
92 if [ $? -ne 0 ]; then
93         print -u2 "failed to execute test"
94         exit 1
95 fi
96
97 cd /
98 rm -rf $DIR
99 exit 0