xref: /onnv-gate/usr/src/cmd/dtrace/test/tst/common/pid/tst.manypids.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
282804Stomeeif [ $# != 1 ]; then
292804Stomee	echo expected one argument: '<'dtrace-path'>'
302804Stomee	exit 2
312804Stomeefi
322804Stomee
332804Stomeedtrace=$1
342633Sahl
352633Sahlset -A pids
362633Sahl
372633Sahlfor lib in `ls -1 /lib/lib*.so.1 | grep -v ld.so.1`; do
382633Sahl	preload=$lib:${preload}
392633Sahldone
402633Sahl
412633Sahlexport LD_PRELOAD=$preload
422633Sahl
432633Sahllet numkids=100
442633Sahllet i=0
452633Sahl
462633Sahltmpfile=/tmp/dtest.$$
472633Sahl
482633Sahlwhile [ "$i" -lt "$numkids" ]; do
492633Sahl	sleep 500 &
502633Sahl	pids[$i]=$!
512633Sahl	let i=i+1
522633Sahldone
532633Sahl
542633Sahlexport LD_PRELOAD=
552633Sahl
562633Sahllet i=0
572633Sahl
582633Sahlecho "tick-1sec\n{\n\texit(0);\n}\n" > $tmpfile
592633Sahl
602633Sahlwhile [ "$i" -lt "$numkids" ]; do
612633Sahl	echo "pid${pids[$i]}::malloc:entry\n{}\n" >> $tmpfile
622633Sahl	let i=i+1
632633Sahldone
642633Sahl
652633Sahl$dtrace -s $tmpfile
662633Sahlstatus=$?
672633Sahl
682633Sahlrm $tmpfile
692633Sahlpkill sleep
702633Sahlexit $status
71