xref: /src/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.ret2.d (revision 2be1a816b9ff69588e55be0a84cbe2a31efc0f2f)
112456ea8SJohn Birrell /*
212456ea8SJohn Birrell  * CDDL HEADER START
312456ea8SJohn Birrell  *
412456ea8SJohn Birrell  * The contents of this file are subject to the terms of the
512456ea8SJohn Birrell  * Common Development and Distribution License (the "License").
612456ea8SJohn Birrell  * You may not use this file except in compliance with the License.
712456ea8SJohn Birrell  *
812456ea8SJohn Birrell  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
912456ea8SJohn Birrell  * or http://www.opensolaris.org/os/licensing.
1012456ea8SJohn Birrell  * See the License for the specific language governing permissions
1112456ea8SJohn Birrell  * and limitations under the License.
1212456ea8SJohn Birrell  *
1312456ea8SJohn Birrell  * When distributing Covered Code, include this CDDL HEADER in each
1412456ea8SJohn Birrell  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1512456ea8SJohn Birrell  * If applicable, add the following below this CDDL HEADER, with the
1612456ea8SJohn Birrell  * fields enclosed by brackets "[]" replaced with your own identifying
1712456ea8SJohn Birrell  * information: Portions Copyright [yyyy] [name of copyright owner]
1812456ea8SJohn Birrell  *
1912456ea8SJohn Birrell  * CDDL HEADER END
2012456ea8SJohn Birrell  */
2112456ea8SJohn Birrell 
2212456ea8SJohn Birrell /*
2312456ea8SJohn Birrell  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
2412456ea8SJohn Birrell  * Use is subject to license terms.
2512456ea8SJohn Birrell  */
2612456ea8SJohn Birrell 
2712456ea8SJohn Birrell #pragma ident	"%Z%%M%	%I%	%E% SMI"
2812456ea8SJohn Birrell 
2912456ea8SJohn Birrell /*
3012456ea8SJohn Birrell  * ASSERTION: test that we get the right return value from leaf returns
3112456ea8SJohn Birrell  *
3212456ea8SJohn Birrell  * SECTION: pid provider
3312456ea8SJohn Birrell  */
3412456ea8SJohn Birrell 
3512456ea8SJohn Birrell #pragma D option destructive
3612456ea8SJohn Birrell 
3712456ea8SJohn Birrell BEGIN
3812456ea8SJohn Birrell {
3912456ea8SJohn Birrell 	/*
4012456ea8SJohn Birrell 	 * Wait no more than a second for the first call to getpid(2).
4112456ea8SJohn Birrell 	 */
4212456ea8SJohn Birrell 	timeout = timestamp + 1000000000;
4312456ea8SJohn Birrell }
4412456ea8SJohn Birrell 
4512456ea8SJohn Birrell syscall::getpid:return
4612456ea8SJohn Birrell /pid == $1/
4712456ea8SJohn Birrell {
4812456ea8SJohn Birrell 	i = 0;
4912456ea8SJohn Birrell 	raise(SIGUSR1);
5012456ea8SJohn Birrell 	/*
5112456ea8SJohn Birrell 	 * Wait half a second after raising the signal.
5212456ea8SJohn Birrell 	 */
5312456ea8SJohn Birrell 	timeout = timestamp + 500000000;
5412456ea8SJohn Birrell }
5512456ea8SJohn Birrell 
5612456ea8SJohn Birrell pid$1:a.out:go:return
5712456ea8SJohn Birrell /arg1 == 100/
5812456ea8SJohn Birrell {
5912456ea8SJohn Birrell 	exit(0);
6012456ea8SJohn Birrell }
6112456ea8SJohn Birrell 
6212456ea8SJohn Birrell pid$1:a.out:go:return
6312456ea8SJohn Birrell {
6412456ea8SJohn Birrell 	printf("wrong return value: %d", arg1);
6512456ea8SJohn Birrell 	exit(1);
6612456ea8SJohn Birrell }
6712456ea8SJohn Birrell 
6812456ea8SJohn Birrell profile:::tick-4
6912456ea8SJohn Birrell /timestamp > timeout/
7012456ea8SJohn Birrell {
7112456ea8SJohn Birrell 	trace("test timed out");
7212456ea8SJohn Birrell 	exit(1);
7312456ea8SJohn Birrell }
74