1178476Sjb# 2178476Sjb# CDDL HEADER START 3178476Sjb# 4178476Sjb# The contents of this file are subject to the terms of the 5178476Sjb# Common Development and Distribution License (the "License"). 6178476Sjb# You may not use this file except in compliance with the License. 7178476Sjb# 8178476Sjb# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9178476Sjb# or http://www.opensolaris.org/os/licensing. 10178476Sjb# See the License for the specific language governing permissions 11178476Sjb# and limitations under the License. 12178476Sjb# 13178476Sjb# When distributing Covered Code, include this CDDL HEADER in each 14178476Sjb# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15178476Sjb# If applicable, add the following below this CDDL HEADER, with the 16178476Sjb# fields enclosed by brackets "[]" replaced with your own identifying 17178476Sjb# information: Portions Copyright [yyyy] [name of copyright owner] 18178476Sjb# 19178476Sjb# CDDL HEADER END 20178476Sjb# 21178476Sjb 22178476Sjb# 23178476Sjb# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24178476Sjb# Use is subject to license terms. 25178476Sjb# 26178476Sjb#ident "%Z%%M% %I% %E% SMI" 27178476Sjb 28178476Sjbif [ $# != 1 ]; then 29178476Sjb echo expected one argument: '<'dtrace-path'>' 30178476Sjb exit 2 31178476Sjbfi 32178476Sjb 33178476Sjbfile=out.$$ 34178476Sjbdtrace=$1 35178476Sjb 36178476Sjbrm -f $file 37178476Sjb 38178476Sjbdir=`dirname $tst` 39178476Sjb 40178476Sjb$dtrace -o $file -c $dir/tst.spin.exe -s /dev/stdin <<EOF 41178476Sjb 42178476Sjb #pragma D option quiet 43178476Sjb #pragma D option destructive 44178476Sjb #pragma D option evaltime=main 45178476Sjb 46178476Sjb /* 47178476Sjb * Toss out the first 100 samples to wait for the program to enter 48178476Sjb * its steady state. 49178476Sjb */ 50178476Sjb 51178476Sjb profile-1999 52178476Sjb /pid == \$target && n++ > 100/ 53178476Sjb { 54178476Sjb @total = count(); 55178476Sjb @stacks[ustack(4)] = count(); 56178476Sjb } 57178476Sjb 58178476Sjb tick-1s 59178476Sjb { 60178476Sjb secs++; 61178476Sjb } 62178476Sjb 63178476Sjb tick-1s 64178476Sjb /secs > 5/ 65178476Sjb { 66178476Sjb done = 1; 67178476Sjb } 68178476Sjb 69178476Sjb tick-1s 70178476Sjb /secs > 10/ 71178476Sjb { 72178476Sjb trace("test timed out"); 73178476Sjb exit(1); 74178476Sjb } 75178476Sjb 76178476Sjb profile-1999 77178476Sjb /pid == \$target && done/ 78178476Sjb { 79178476Sjb raise(SIGINT); 80178476Sjb exit(0); 81178476Sjb } 82178476Sjb 83178476Sjb END 84178476Sjb { 85178476Sjb printa("TOTAL %@u\n", @total); 86178476Sjb printa("START%kEND\n", @stacks); 87178476Sjb } 88178476SjbEOF 89178476Sjb 90178476Sjbstatus=$? 91178476Sjbif [ "$status" -ne 0 ]; then 92178476Sjb echo $tst: dtrace failed 93178476Sjb exit $status 94178476Sjbfi 95178476Sjb 96178476Sjbperl /dev/stdin $file <<EOF 97178476Sjb \$_ = <>; 98178476Sjb chomp; 99178476Sjb die "output problem\n" unless /^TOTAL (\d+)/; 100178476Sjb \$count = \$1; 101178476Sjb die "too few samples (\$count)\n" unless \$count >= 1000; 102178476Sjb 103178476Sjb while (<>) { 104178476Sjb chomp; 105178476Sjb 106178476Sjb last if /^$/; 107178476Sjb 108178476Sjb die "expected START at \$.\n" unless /^START/; 109178476Sjb 110178476Sjb 111178476Sjb \$_ = <>; 112178476Sjb chomp; 113178476Sjb die "expected END at \$.\n" unless /\`baz\+/; 114178476Sjb 115178476Sjb \$_ = <>; 116178476Sjb chomp; 117178476Sjb die "expected END at \$.\n" unless /\`bar\+/; 118178476Sjb 119178476Sjb \$_ = <>; 120178476Sjb chomp; 121178476Sjb die "expected END at \$.\n" unless /\`foo\+/; 122178476Sjb 123178476Sjb \$_ = <>; 124178476Sjb chomp; 125178476Sjb die "expected END at \$.\n" unless /\`main\+/; 126178476Sjb 127178476Sjb \$_ = <>; 128178476Sjb chomp; 129178476Sjb die "expected END at \$.\n" unless /^END\$/; 130178476Sjb } 131178476Sjb 132178476SjbEOF 133178476Sjb 134178476Sjbstatus=$? 135178476Sjbif [ "$status" -eq 0 ]; then 136178476Sjb rm -f $file 137178476Sjbfi 138178476Sjb 139178476Sjbexit $status 140