xref: /onnv-gate/usr/src/cmd/dtrace/test/tst/common/proc/tst.startexit.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
282633Sahl#
292633Sahl# This script tests that the firing order of probes in a process is:
302633Sahl#
312633Sahl#  1.  proc:::start
322633Sahl#  2.  proc:::lwp-start
332633Sahl#  3.  proc:::lwp-exit
342633Sahl#  4.  proc:::exit
352633Sahl#
362633Sahl# If this fails, the script will run indefinitely; it relies on the harness
372633Sahl# to time it out.
382633Sahl#
392633Sahlscript()
402633Sahl{
412633Sahl	$dtrace -s /dev/stdin <<EOF
422633Sahl	proc:::start
432633Sahl	/curpsinfo->pr_ppid == $child/
442633Sahl	{
452633Sahl		self->start = 1;
462633Sahl	}
472633Sahl
482633Sahl	proc:::lwp-start
492633Sahl	/self->start/
502633Sahl	{
512633Sahl		self->lwp_start = 1;
522633Sahl	}
532633Sahl
542633Sahl	proc:::lwp-exit
552633Sahl	/self->lwp_start/
562633Sahl	{
572633Sahl		self->lwp_exit = 1;
582633Sahl	}
592633Sahl
602633Sahl	proc:::exit
612633Sahl	/self->lwp_exit == 1/
622633Sahl	{
632633Sahl		exit(0);
642633Sahl	}
652633SahlEOF
662633Sahl}
672633Sahl
682633Sahlsleeper()
692633Sahl{
702633Sahl	while true; do
712633Sahl		/usr/bin/sleep 1
722633Sahl	done
732633Sahl}
742633Sahl
752804Stomeeif [ $# != 1 ]; then
762804Stomee	echo expected one argument: '<'dtrace-path'>'
772804Stomee	exit 2
782804Stomeefi
792804Stomee
802804Stomeedtrace=$1
812633Sahl
822633Sahlsleeper &
832633Sahlchild=$!
842633Sahl
852633Sahlscript
862633Sahlstatus=$?
872633Sahl
882633Sahlkill $child
892633Sahlexit $status
90