8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / dtrace / test / tst / common / ustack / tst.spin.ksh
blob57c13d5abee449b67b3f29de42021ac817d625c8
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 2006 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
27 if [ $# != 1 ]; then
28 echo expected one argument: '<'dtrace-path'>'
29 exit 2
32 file=out.$$
33 dtrace=$1
35 rm -f $file
37 dir=`/bin/dirname $tst`
39 $dtrace -o $file -c $dir/tst.spin.exe -s /dev/stdin <<EOF
41 #pragma D option quiet
42 #pragma D option destructive
43 #pragma D option evaltime=main
46 * Toss out the first 100 samples to wait for the program to enter
47 * its steady state.
50 profile-1999
51 /pid == \$target && n++ > 100/
53 @total = count();
54 @stacks[ustack(4)] = count();
57 tick-1s
59 secs++;
62 tick-1s
63 /secs > 5/
65 done = 1;
68 tick-1s
69 /secs > 10/
71 trace("test timed out");
72 exit(1);
75 profile-1999
76 /pid == \$target && done/
78 raise(SIGINT);
79 exit(0);
82 END
84 printa("TOTAL %@u\n", @total);
85 printa("START%kEND\n", @stacks);
87 EOF
89 status=$?
90 if [ "$status" -ne 0 ]; then
91 echo $tst: dtrace failed
92 exit $status
95 perl /dev/stdin $file <<EOF
96 \$_ = <>;
97 chomp;
98 die "output problem\n" unless /^TOTAL (\d+)/;
99 \$count = \$1;
100 die "too few samples (\$count)\n" unless \$count >= 1000;
102 while (<>) {
103 chomp;
105 last if /^$/;
107 die "expected START at \$.\n" unless /^START/;
110 \$_ = <>;
111 chomp;
112 die "expected END at \$.\n" unless /\`baz\+/;
114 \$_ = <>;
115 chomp;
116 die "expected END at \$.\n" unless /\`bar\+/;
118 \$_ = <>;
119 chomp;
120 die "expected END at \$.\n" unless /\`foo\+/;
122 \$_ = <>;
123 chomp;
124 die "expected END at \$.\n" unless /\`main\+/;
126 \$_ = <>;
127 chomp;
128 die "expected END at \$.\n" unless /^END\$/;
133 status=$?
134 if [ "$status" -eq 0 ]; then
135 rm -f $file
138 exit $status