8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / dtrace / test / tst / common / misc / tst.dofmax.ksh
blob22c267dcfc3953bdaa69f4dd4f21fabd2aafc11f
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.
26 let j=8
28 enable()
30 prog=/var/tmp/dtest.$$.d
31 err=/var/tmp/dtest.$$.err
33 nawk -v nprobes=$1 'BEGIN { \
34 for (i = 0; i < nprobes - 1; i++) { \
35 printf("dtrace:::BEGIN,\n"); \
36 } \
38 printf("dtrace:::BEGIN { exit(0); }\n"); \
39 }' /dev/null > $prog
41 dtrace -qs $prog > /dev/null 2> $err
43 if [[ "$?" -eq 0 ]]; then
44 return 0
45 else
46 if ! grep "DIF program exceeds maximum program size" $err \
47 1> /dev/null 2>&1 ; then
48 echo "failed to enable $prog: `cat $err`"
49 exit 1
52 return 1
57 # First, establish an upper bound
59 let upper=1
61 while enable $upper ; do
62 let lower=upper
63 let upper=upper+upper
64 echo success at $lower, raised to $upper
65 done
68 # Now search for the highest value that can be enabled
70 while [[ "$lower" -lt "$upper" ]]; do
71 let guess=$(((lower + upper) / 2))
72 echo "lower is $lower; upper is $upper; guess is $guess\c"
74 if enable $guess ; then
75 if [[ $((upper - lower)) -le 2 ]]; then
76 let upper=guess
79 echo " (success)"
80 let lower=guess
81 else
82 echo " (failure)"
83 let upper=guess
85 done
87 let expected=10000
89 if [[ "$lower" -lt "$expected" ]]; then
90 echo "expected support for enablings of at least $expected probes; \c"
91 echo "found $lower"
92 exit 1
95 echo "maximum supported enabled probes found to be $lower"
96 exit 0