19512fe85Sahl# 29512fe85Sahl# CDDL HEADER START 39512fe85Sahl# 49512fe85Sahl# The contents of this file are subject to the terms of the 59512fe85Sahl# Common Development and Distribution License (the "License"). 69512fe85Sahl# You may not use this file except in compliance with the License. 79512fe85Sahl# 89512fe85Sahl# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 99512fe85Sahl# or http://www.opensolaris.org/os/licensing. 109512fe85Sahl# See the License for the specific language governing permissions 119512fe85Sahl# and limitations under the License. 129512fe85Sahl# 139512fe85Sahl# When distributing Covered Code, include this CDDL HEADER in each 149512fe85Sahl# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 159512fe85Sahl# If applicable, add the following below this CDDL HEADER, with the 169512fe85Sahl# fields enclosed by brackets "[]" replaced with your own identifying 179512fe85Sahl# information: Portions Copyright [yyyy] [name of copyright owner] 189512fe85Sahl# 199512fe85Sahl# CDDL HEADER END 209512fe85Sahl# 219512fe85Sahl 229512fe85Sahl# 239512fe85Sahl# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 249512fe85Sahl# Use is subject to license terms. 259512fe85Sahl# 269512fe85Sahl 2723b5c241Stomeeif [ $# != 1 ]; then 2823b5c241Stomee echo expected one argument: '<'dtrace-path'>' 2923b5c241Stomee exit 2 3023b5c241Stomeefi 3123b5c241Stomee 329512fe85Sahlfile=out.$$ 3323b5c241Stomeedtrace=$1 349512fe85Sahl 359512fe85Sahlrm -f $file 369512fe85Sahl 37*6a1af1a6SRichard Lowedir=`/bin/dirname $tst` 389512fe85Sahl 399512fe85Sahl$dtrace -o $file -c $dir/tst.spin.exe -s /dev/stdin <<EOF 409512fe85Sahl 419512fe85Sahl #pragma D option quiet 429512fe85Sahl #pragma D option destructive 439512fe85Sahl #pragma D option evaltime=main 449512fe85Sahl 459512fe85Sahl /* 469512fe85Sahl * Toss out the first 100 samples to wait for the program to enter 479512fe85Sahl * its steady state. 489512fe85Sahl */ 499512fe85Sahl 509512fe85Sahl profile-1999 519512fe85Sahl /pid == \$target && n++ > 100/ 529512fe85Sahl { 539512fe85Sahl @total = count(); 549512fe85Sahl @stacks[ustack(4)] = count(); 559512fe85Sahl } 569512fe85Sahl 579512fe85Sahl tick-1s 589512fe85Sahl { 599512fe85Sahl secs++; 609512fe85Sahl } 619512fe85Sahl 629512fe85Sahl tick-1s 639512fe85Sahl /secs > 5/ 649512fe85Sahl { 659512fe85Sahl done = 1; 669512fe85Sahl } 679512fe85Sahl 689512fe85Sahl tick-1s 699512fe85Sahl /secs > 10/ 709512fe85Sahl { 719512fe85Sahl trace("test timed out"); 729512fe85Sahl exit(1); 739512fe85Sahl } 749512fe85Sahl 759512fe85Sahl profile-1999 769512fe85Sahl /pid == \$target && done/ 779512fe85Sahl { 789512fe85Sahl raise(SIGINT); 799512fe85Sahl exit(0); 809512fe85Sahl } 819512fe85Sahl 829512fe85Sahl END 839512fe85Sahl { 849512fe85Sahl printa("TOTAL %@u\n", @total); 859512fe85Sahl printa("START%kEND\n", @stacks); 869512fe85Sahl } 879512fe85SahlEOF 889512fe85Sahl 899512fe85Sahlstatus=$? 909512fe85Sahlif [ "$status" -ne 0 ]; then 919512fe85Sahl echo $tst: dtrace failed 929512fe85Sahl exit $status 939512fe85Sahlfi 949512fe85Sahl 959512fe85Sahlperl /dev/stdin $file <<EOF 969512fe85Sahl \$_ = <>; 979512fe85Sahl chomp; 989512fe85Sahl die "output problem\n" unless /^TOTAL (\d+)/; 999512fe85Sahl \$count = \$1; 1009512fe85Sahl die "too few samples (\$count)\n" unless \$count >= 1000; 1019512fe85Sahl 1029512fe85Sahl while (<>) { 1039512fe85Sahl chomp; 1049512fe85Sahl 1059512fe85Sahl last if /^$/; 1069512fe85Sahl 1079512fe85Sahl die "expected START at \$.\n" unless /^START/; 1089512fe85Sahl 1099512fe85Sahl 1109512fe85Sahl \$_ = <>; 1119512fe85Sahl chomp; 1129512fe85Sahl die "expected END at \$.\n" unless /\`baz\+/; 1139512fe85Sahl 1149512fe85Sahl \$_ = <>; 1159512fe85Sahl chomp; 1169512fe85Sahl die "expected END at \$.\n" unless /\`bar\+/; 1179512fe85Sahl 1189512fe85Sahl \$_ = <>; 1199512fe85Sahl chomp; 1209512fe85Sahl die "expected END at \$.\n" unless /\`foo\+/; 1219512fe85Sahl 1229512fe85Sahl \$_ = <>; 1239512fe85Sahl chomp; 1249512fe85Sahl die "expected END at \$.\n" unless /\`main\+/; 1259512fe85Sahl 1269512fe85Sahl \$_ = <>; 1279512fe85Sahl chomp; 1289512fe85Sahl die "expected END at \$.\n" unless /^END\$/; 1299512fe85Sahl } 1309512fe85Sahl 1319512fe85SahlEOF 1329512fe85Sahl 1339512fe85Sahlstatus=$? 1349512fe85Sahlif [ "$status" -eq 0 ]; then 1359512fe85Sahl rm -f $file 1369512fe85Sahlfi 1379512fe85Sahl 1389512fe85Sahlexit $status 139