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 27if [ $# != 1 ]; then 28 echo expected one argument: '<'dtrace-path'>' 29 exit 2 30fi 31 32file=out.$$ 33dtrace=$1 34 35rm -f $file 36 37dir=`/bin/dirname $tst` 38 39$dtrace -o $file -c $dir/tst.spin.exe -s /dev/stdin <<EOF 40 41 #pragma D option quiet 42 #pragma D option destructive 43 #pragma D option evaltime=main 44 45 /* 46 * Toss out the first 100 samples to wait for the program to enter 47 * its steady state. 48 */ 49 50 profile-1999 51 /pid == \$target && n++ > 100/ 52 { 53 @total = count(); 54 @stacks[ustack(4)] = count(); 55 } 56 57 tick-1s 58 { 59 secs++; 60 } 61 62 tick-1s 63 /secs > 5/ 64 { 65 done = 1; 66 } 67 68 tick-1s 69 /secs > 10/ 70 { 71 trace("test timed out"); 72 exit(1); 73 } 74 75 profile-1999 76 /pid == \$target && done/ 77 { 78 raise(SIGINT); 79 exit(0); 80 } 81 82 END 83 { 84 printa("TOTAL %@u\n", @total); 85 printa("START%kEND\n", @stacks); 86 } 87EOF 88 89status=$? 90if [ "$status" -ne 0 ]; then 91 echo $tst: dtrace failed 92 exit $status 93fi 94 95perl /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; 101 102 while (<>) { 103 chomp; 104 105 last if /^$/; 106 107 die "expected START at \$.\n" unless /^START/; 108 109 110 \$_ = <>; 111 chomp; 112 die "expected END at \$.\n" unless /\`baz\+/; 113 114 \$_ = <>; 115 chomp; 116 die "expected END at \$.\n" unless /\`bar\+/; 117 118 \$_ = <>; 119 chomp; 120 die "expected END at \$.\n" unless /\`foo\+/; 121 122 \$_ = <>; 123 chomp; 124 die "expected END at \$.\n" unless /\`main\+/; 125 126 \$_ = <>; 127 chomp; 128 die "expected END at \$.\n" unless /^END\$/; 129 } 130 131EOF 132 133status=$? 134if [ "$status" -eq 0 ]; then 135 rm -f $file 136fi 137 138exit $status 139