xref: /onnv-gate/usr/src/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh (revision 2804:e8e3422f18c2)
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#
232633Sahl# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
242633Sahl# Use is subject to license terms.
252633Sahl#
262633Sahl#ident	"%Z%%M%	%I%	%E% SMI"
272633Sahl
28*2804Stomeeif [ $# != 1 ]; then
29*2804Stomee	echo expected one argument: '<'dtrace-path'>'
30*2804Stomee	exit 2
31*2804Stomeefi
32*2804Stomee
33*2804Stomeedtrace=$1
342633SahlDIR=/var/tmp/dtest.$$
352633Sahl
362633Sahlmkdir $DIR
372633Sahlcd $DIR
382633Sahl
392633Sahlcat > prov.d <<EOF
402633Sahlprovider test_prov {
412633Sahl	probe go();
422633Sahl};
432633SahlEOF
442633Sahl
45*2804Stomee$dtrace -h -s prov.d
462633Sahlif [ $? -ne 0 ]; then
472633Sahl	print -u2 "failed to generate header file"
482633Sahl	exit 1
492633Sahlfi
502633Sahl
512633Sahlcat > test.c <<EOF
522633Sahl#include <sys/types.h>
532633Sahl#include "prov.h"
542633Sahl
552633Sahlint
562633Sahlmain(int argc, char **argv)
572633Sahl{
582633Sahl	if (TEST_PROV_GO_ENABLED()) {
592633Sahl		TEST_PROV_GO();
602633Sahl	}
612633Sahl}
622633SahlEOF
632633Sahl
642633Sahlcc -c test.c
652633Sahlif [ $? -ne 0 ]; then
662633Sahl	print -u2 "failed to compile test.c"
672633Sahl	exit 1
682633Sahlfi
69*2804Stomee$dtrace -G -32 -s prov.d test.o
702633Sahlif [ $? -ne 0 ]; then
712633Sahl	print -u2 "failed to create DOF"
722633Sahl	exit 1
732633Sahlfi
742633Sahlcc -o test test.o prov.o
752633Sahlif [ $? -ne 0 ]; then
762633Sahl	print -u2 "failed to link final executable"
772633Sahl	exit 1
782633Sahlfi
792633Sahl
802633Sahlscript()
812633Sahl{
82*2804Stomee	$dtrace -c ./test -qs /dev/stdin <<EOF
832633Sahl	test_prov\$target:::
842633Sahl	{
852633Sahl		printf("%s:%s:%s\n", probemod, probefunc, probename);
862633Sahl	}
872633SahlEOF
882633Sahl}
892633Sahl
902633Sahlscript
912633Sahlstatus=$?
922633Sahl
932633Sahlcd /
942633Sahl/usr/bin/rm -rf $DIR
952633Sahl
962633Sahlexit $status
97