tst.guess32.ksh revision 302408
10SN/A#
27016SN/A# CDDL HEADER START
30SN/A#
40SN/A# The contents of this file are subject to the terms of the
50SN/A# Common Development and Distribution License (the "License").
60SN/A# You may not use this file except in compliance with the License.
72362SN/A#
80SN/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92362SN/A# or http://www.opensolaris.org/os/licensing.
100SN/A# See the License for the specific language governing permissions
110SN/A# and limitations under the License.
120SN/A#
130SN/A# When distributing Covered Code, include this CDDL HEADER in each
140SN/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150SN/A# If applicable, add the following below this CDDL HEADER, with the
160SN/A# fields enclosed by brackets "[]" replaced with your own identifying
170SN/A# information: Portions Copyright [yyyy] [name of copyright owner]
180SN/A#
190SN/A# CDDL HEADER END
200SN/A#
212362SN/A
222362SN/A#
232362SN/A# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
240SN/A# Use is subject to license terms.
250SN/A#
260SN/A# ident	"%Z%%M%	%I%	%E% SMI"
277016SN/A
280SN/Aif [ $# != 1 ]; then
290SN/A	echo expected one argument: '<'dtrace-path'>'
307375SN/A	exit 2
317489SN/Afi
327489SN/A
337016SN/Adtrace=$1
340SN/ADIR=/var/tmp/dtest.$$
350SN/A
360SN/Amkdir $DIR
3712546Savstepancd $DIR
3833SN/A
3912546Savstepancat > prov.d <<EOF
400SN/Aprovider test_prov {
410SN/A	probe go();
420SN/A};
430SN/AEOF
4412546Savstepan
450SN/A$dtrace -h -s prov.d
460SN/Aif [ $? -ne 0 ]; then
470SN/A	print -u2 "failed to generate header file"
4812546Savstepan	exit 1
490SN/Afi
500SN/A
510SN/Acat > test.c <<EOF
520SN/A#include <sys/types.h>
5312546Savstepan#include "prov.h"
540SN/A
550SN/Aint
560SN/Amain(int argc, char **argv)
570SN/A{
5812546Savstepan	if (TEST_PROV_GO_ENABLED()) {
5912546Savstepan		TEST_PROV_GO();
600SN/A	}
6112546Savstepan}
620SN/AEOF
6312546Savstepan
6412546Savstepancc -xarch=generic -c test.c
6512546Savstepanif [ $? -ne 0 ]; then
660SN/A	print -u2 "failed to compile test.c"
670SN/A	exit 1
6812546Savstepanfi
690SN/A$dtrace -G -s prov.d test.o
7012546Savstepanif [ $? -ne 0 ]; then
710SN/A	print -u2 "failed to create DOF"
7212546Savstepan	exit 1
730SN/Afi
7412546Savstepancc -xarch=generic -o test test.o prov.o
7512546Savstepanif [ $? -ne 0 ]; then
7612546Savstepan	print -u2 "failed to link final executable"
7712546Savstepan	exit 1
7812546Savstepanfi
7912546Savstepan
8012546Savstepanscript()
8112546Savstepan{
8212546Savstepan	$dtrace -c ./test -qs /dev/stdin <<EOF
830SN/A	test_prov\$target:::
840SN/A	{
850SN/A		printf("%s:%s:%s\n", probemod, probefunc, probename);
8612546Savstepan	}
870SN/AEOF
880SN/A}
890SN/A
900SN/Ascript
910SN/Astatus=$?
9212546Savstepan
930SN/Acd /
940SN/A/bin/rm -rf $DIR
950SN/A
9612546Savstepanexit $status
970SN/A