dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / dtrace / test / tst / common / privs / tst.providers.ksh
blob94c3722f78b7413050bd5e81640e869a151de0f8
2 # CDDL HEADER START
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.
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.
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]
19 # CDDL HEADER END
23 # Copyright (c) 2012, Joyent, Inc. All rights reserved.
27 # First, make sure that we can successfully enable the io provider
29 if ! dtrace -P io -n BEGIN'{exit(0)}' > /dev/null 2>&1 ; then
30 echo failed to enable io provider with full privs
31 exit 1
34 ppriv -s A=basic,dtrace_proc,dtrace_user $$
37 # Now make sure that we cannot enable the io provider with reduced privs
39 if ! dtrace -x errtags -P io -n BEGIN'{exit(1)}' 2>&1 | \
40 grep D_PDESC_ZERO > /dev/null 2>&1 ; then
41 echo successfully enabled the io provider with reduced privs
42 exit 1
46 # Keeping our reduced privs, we want to assure that we can see every provider
47 # that we think we should be able to see -- and that we can see curpsinfo
48 # state but can't otherwise see arguments.
50 /usr/sbin/dtrace -wq -Cs /dev/stdin <<EOF
52 int seen[string];
53 int err;
55 #define CANENABLE(provider) \
56 provider::: \
57 /err == 0 && progenyof(\$pid) && !seen["provider"]/ \
58 { \
59 trace(arg0); \
60 printf("\nsuccessful trace of arg0 in %s:%s:%s:%s\n", \
61 probeprov, probemod, probefunc, probename); \
62 exit(++err); \
63 } \
65 provider::: \
66 /progenyof(\$pid)/ \
67 { \
68 seen["provider"]++; \
69 } \
71 provider::: \
72 /progenyof(\$pid)/ \
73 { \
74 errstr = "provider"; \
75 this->ignore = stringof(curpsinfo->pr_psargs); \
76 errstr = ""; \
77 } \
79 END \
80 /err == 0 && !seen["provider"]/ \
81 { \
82 printf("no probes from provider\n"); \
83 exit(++err); \
84 } \
86 END \
87 /err == 0/ \
88 { \
89 printf("saw %d probes from provider\n", seen["provider"]); \
92 CANENABLE(proc)
93 CANENABLE(sched)
94 CANENABLE(vminfo)
95 CANENABLE(sysinfo)
97 BEGIN
100 * We'll kick off a system of a do-nothing command -- which should be
101 * enough to kick proc, sched, vminfo and sysinfo probes.
103 system("echo > /dev/null");
106 ERROR
107 /err == 0 && errstr != ""/
109 printf("fatal error: couldn't read curpsinfo->pr_psargs in ");
110 printf("%s-provided probe\n", errstr);
111 exit(++err);
114 proc:::exit
115 /progenyof(\$pid)/
117 exit(0);
120 tick-10ms
121 /i++ > 500/
123 printf("exit probe did not seem to fire\n");
124 exit(++err);