12b6e762cSahl#
22b6e762cSahl# CDDL HEADER START
32b6e762cSahl#
42b6e762cSahl# The contents of this file are subject to the terms of the
52b6e762cSahl# Common Development and Distribution License (the "License").
62b6e762cSahl# You may not use this file except in compliance with the License.
72b6e762cSahl#
82b6e762cSahl# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92b6e762cSahl# or http://www.opensolaris.org/os/licensing.
102b6e762cSahl# See the License for the specific language governing permissions
112b6e762cSahl# and limitations under the License.
122b6e762cSahl#
132b6e762cSahl# When distributing Covered Code, include this CDDL HEADER in each
142b6e762cSahl# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
152b6e762cSahl# If applicable, add the following below this CDDL HEADER, with the
162b6e762cSahl# fields enclosed by brackets "[]" replaced with your own identifying
172b6e762cSahl# information: Portions Copyright [yyyy] [name of copyright owner]
182b6e762cSahl#
192b6e762cSahl# CDDL HEADER END
202b6e762cSahl#
212b6e762cSahl
222b6e762cSahl#
232b6e762cSahl# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
242b6e762cSahl# Use is subject to license terms.
252b6e762cSahl#
262b6e762cSahl
2723b5c241Stomeeif [ $# != 1 ]; then
2823b5c241Stomee	echo expected one argument: '<'dtrace-path'>'
2923b5c241Stomee	exit 2
3023b5c241Stomeefi
3123b5c241Stomee
3223b5c241Stomeedtrace=$1
332b6e762cSahlDIR=/var/tmp/dtest.$$
342b6e762cSahl
352b6e762cSahlmkdir $DIR
362b6e762cSahlcd $DIR
372b6e762cSahl
382b6e762cSahlcat > prov.d <<EOF
392b6e762cSahlprovider test_prov {
402b6e762cSahl	probe go();
412b6e762cSahl};
422b6e762cSahlEOF
432b6e762cSahl
4423b5c241Stomee$dtrace -h -s prov.d
452b6e762cSahlif [ $? -ne 0 ]; then
462b6e762cSahl	print -u2 "failed to generate header file"
472b6e762cSahl	exit 1
482b6e762cSahlfi
492b6e762cSahl
502b6e762cSahlcat > test.c <<EOF
512b6e762cSahl#include <sys/types.h>
522b6e762cSahl#include "prov.h"
532b6e762cSahl
542b6e762cSahlint
552b6e762cSahlmain(int argc, char **argv)
562b6e762cSahl{
572b6e762cSahl	if (TEST_PROV_GO_ENABLED()) {
582b6e762cSahl		TEST_PROV_GO();
592b6e762cSahl	}
602b6e762cSahl}
612b6e762cSahlEOF
622b6e762cSahl
63*c090e5dfSBryan Cantrillgcc -m32 -c test.c
642b6e762cSahlif [ $? -ne 0 ]; then
652b6e762cSahl	print -u2 "failed to compile test.c"
662b6e762cSahl	exit 1
672b6e762cSahlfi
6823b5c241Stomee$dtrace -G -s prov.d test.o
692b6e762cSahlif [ $? -ne 0 ]; then
702b6e762cSahl	print -u2 "failed to create DOF"
712b6e762cSahl	exit 1
722b6e762cSahlfi
73*c090e5dfSBryan Cantrillgcc -m32 -o test test.o prov.o
742b6e762cSahlif [ $? -ne 0 ]; then
752b6e762cSahl	print -u2 "failed to link final executable"
762b6e762cSahl	exit 1
772b6e762cSahlfi
782b6e762cSahl
792b6e762cSahlscript()
802b6e762cSahl{
8123b5c241Stomee	$dtrace -c ./test -qs /dev/stdin <<EOF
822b6e762cSahl	test_prov\$target:::
832b6e762cSahl	{
842b6e762cSahl		printf("%s:%s:%s\n", probemod, probefunc, probename);
852b6e762cSahl	}
862b6e762cSahlEOF
872b6e762cSahl}
882b6e762cSahl
892b6e762cSahlscript
902b6e762cSahlstatus=$?
912b6e762cSahl
922b6e762cSahlcd /
932b6e762cSahl/usr/bin/rm -rf $DIR
942b6e762cSahl
952b6e762cSahlexit $status
96