tst.stop2.d revision 256281
190792Sgshapiro/*
290792Sgshapiro * CDDL HEADER START
390792Sgshapiro *
490792Sgshapiro * The contents of this file are subject to the terms of the
590792Sgshapiro * Common Development and Distribution License (the "License").
690792Sgshapiro * You may not use this file except in compliance with the License.
790792Sgshapiro *
890792Sgshapiro * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
990792Sgshapiro * or http://www.opensolaris.org/os/licensing.
1090792Sgshapiro * See the License for the specific language governing permissions
1190792Sgshapiro * and limitations under the License.
1290792Sgshapiro *
1390792Sgshapiro * When distributing Covered Code, include this CDDL HEADER in each
1490792Sgshapiro * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1590792Sgshapiro * If applicable, add the following below this CDDL HEADER, with the
1690792Sgshapiro * fields enclosed by brackets "[]" replaced with your own identifying
1790792Sgshapiro * information: Portions Copyright [yyyy] [name of copyright owner]
1890792Sgshapiro *
1990792Sgshapiro * CDDL HEADER END
2090792Sgshapiro */
2190792Sgshapiro
2290792Sgshapiro/*
2390792Sgshapiro * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
2490792Sgshapiro * Use is subject to license terms.
2590792Sgshapiro */
2690792Sgshapiro
2790792Sgshapiro#pragma ident	"%Z%%M%	%I%	%E% SMI"
2890792Sgshapiro
2990792Sgshapiro/*
3090792Sgshapiro * ASSERTION:
3190792Sgshapiro * 	Positive test for stop
3290792Sgshapiro *
3390792Sgshapiro * SECTION: Actions and Subroutines/stop()
3490792Sgshapiro */
3590792Sgshapiro
3690792Sgshapiro#pragma D option destructive
3790792Sgshapiro
3890792SgshapiroBEGIN
3990792Sgshapiro{
4090792Sgshapiro	/*
4190792Sgshapiro	 * Wait no more than a second for the process to call getpid().
4290792Sgshapiro	 */
4390792Sgshapiro	timeout = timestamp + 1000000000;
4490792Sgshapiro	stopped = 0;
4590792Sgshapiro}
4690792Sgshapiro
4790792Sgshapirosyscall::getpid:entry
4890792Sgshapiro/pid == $1 && stopped == 1/
4990792Sgshapiro{
5090792Sgshapiro	trace("looks like it's still going");
5190792Sgshapiro	exit(1);
5290792Sgshapiro}
5390792Sgshapiro
5490792Sgshapirosyscall::getpid:return
5590792Sgshapiro/pid == $1 && stopped == 0/
5690792Sgshapiro{
5790792Sgshapiro	stop();
5890792Sgshapiro	trace("stopped");
5990792Sgshapiro	stopped = 1;
6090792Sgshapiro	/*
6190792Sgshapiro	 * Wait for a quarter second before declaring victory.
6290792Sgshapiro	 */
6390792Sgshapiro	timeout = timestamp + 1000000000 / 4;
6490792Sgshapiro}
6590792Sgshapiro
6690792Sgshapiroprofile:::tick-8
6790792Sgshapiro/timestamp > timeout && stopped == 1/
6890792Sgshapiro{
6990792Sgshapiro	trace("looks like it really stopped");
7090792Sgshapiro	exit(0);
7190792Sgshapiro}
7290792Sgshapiro
7390792Sgshapiroprofile:::tick-8
7490792Sgshapiro/timestamp > timeout/
7590792Sgshapiro{
7690792Sgshapiro	trace("timed out");
7790792Sgshapiro	exit(1);
7890792Sgshapiro}
7990792Sgshapiro