tst.depth.ksh revision 2633:71bab08d24b2
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 2006 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26#ident	"%Z%%M%	%I%	%E% SMI"
27
28file=out.$$
29dtrace=/usr/sbin/dtrace
30
31rm -f $file
32
33$dtrace -o $file -c date -s /dev/stdin <<EOF
34
35	#pragma D option quiet
36	#pragma D option bufsize=1M
37	#pragma D option bufpolicy=fill
38
39	pid\$target:::entry,
40	pid\$target:::return,
41	pid\$target:a.out::,
42	syscall:::return,
43	profile:::profile-997
44	/pid == \$target/
45	{
46        	printf("START %s:%s:%s:%s\n",
47            	probeprov, probemod, probefunc, probename);
48        	trace(ustackdepth);
49        	ustack(100);
50        	trace("END\n");
51	}
52
53	tick-1sec
54	/n++ == 10/
55	{
56		trace("test timed out...");
57		exit(1);
58	}
59EOF
60
61status=$?
62if [ "$status" -ne 0 ]; then
63	echo $tst: dtrace failed
64	exit $status
65fi
66
67perl /dev/stdin $file <<EOF
68	while (<>) {
69		chomp;
70
71		last if /^\$/;
72
73		die "expected START at \$.\n" unless /^START/;
74
75		\$_ = <>;
76		chomp;
77		die "expected depth (\$_) at \$.\n" unless /^(\d+)\$/;
78		\$depth = \$1;
79
80		for (\$i = 0; \$i < \$depth; \$i++) {
81			\$_ = <>;
82			chomp;
83			die "unexpected END at \$.\n" if /^END/;
84		}
85
86		\$_ = <>;
87		chomp;
88		die "expected END at \$.\n" unless /^END\$/;
89	}
90EOF
91
92status=$?
93
94count=`wc -l $file | cut -f1 -do`
95if [ "$count" -lt 1000 ]; then
96	echo $tst: output was too short
97	status=1
98fi
99
100
101if [ "$status" -eq 0 ]; then
102	rm -f $file
103fi
104
105exit $status
106