xref: /onnv-gate/usr/src/cmd/dtrace/test/tst/common/profile-n/tst.func.ksh (revision 4926:0c0bcae7290e)
12633Sahl#
22633Sahl# CDDL HEADER START
32633Sahl#
42633Sahl# The contents of this file are subject to the terms of the
52633Sahl# Common Development and Distribution License (the "License").
62633Sahl# You may not use this file except in compliance with the License.
72633Sahl#
82633Sahl# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92633Sahl# or http://www.opensolaris.org/os/licensing.
102633Sahl# See the License for the specific language governing permissions
112633Sahl# and limitations under the License.
122633Sahl#
132633Sahl# When distributing Covered Code, include this CDDL HEADER in each
142633Sahl# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
152633Sahl# If applicable, add the following below this CDDL HEADER, with the
162633Sahl# fields enclosed by brackets "[]" replaced with your own identifying
172633Sahl# information: Portions Copyright [yyyy] [name of copyright owner]
182633Sahl#
192633Sahl# CDDL HEADER END
202633Sahl#
212633Sahl
222633Sahl#
23*4926Sjhaslam# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
242633Sahl# Use is subject to license terms.
252633Sahl#
26*4926Sjhaslam# ident	"%Z%%M%	%I%	%E% SMI"
272633Sahl
282633Sahlscript()
292633Sahl{
302633Sahl	$dtrace -qs /dev/stdin <<EOF
312633Sahl	profile-1234hz
322633Sahl	/arg0 != 0/
332633Sahl	{
342633Sahl		@[func(arg0)] = count();
352633Sahl	}
362633Sahl
372633Sahl	tick-100ms
382633Sahl	/i++ == 50/
392633Sahl	{
402633Sahl		exit(0);
412633Sahl	}
422633SahlEOF
432633Sahl}
442633Sahl
452633Sahlspinny()
462633Sahl{
472633Sahl	while true; do
482633Sahl		/usr/bin/date > /dev/null
492633Sahl	done
502633Sahl}
512633Sahl
522804Stomeeif [ $# != 1 ]; then
532804Stomee	echo expected one argument: '<'dtrace-path'>'
542804Stomee	exit 2
552804Stomeefi
562804Stomee
572804Stomeedtrace=$1
582633Sahl
592633Sahlspinny &
602633Sahlchild=$!
612633Sahl
622633Sahl#
632633Sahl# This is gutsy -- we're assuming that mutex_enter(9F) will show up in the
642633Sahl# output.  This is most likely _not_ to show up in the output if the
652633Sahl# platform does not support arbitrary resolution interval timers -- but
662633Sahl# the above script was stress-tested down to 100 hertz and still ran
672633Sahl# successfully on all platforms, so one is hopeful that this test will pass
682633Sahl# even in that case.
692633Sahl#
702633Sahlscript | tee /dev/fd/2 | grep mutex_enter > /dev/null
712633Sahlstatus=$?
722633Sahl
732633Sahlkill $child
742633Sahlexit $status
75