1259698Sdim# 2259698Sdim# CDDL HEADER START 3259698Sdim# 4259698Sdim# The contents of this file are subject to the terms of the 5259698Sdim# Common Development and Distribution License (the "License"). 6259698Sdim# You may not use this file except in compliance with the License. 7259698Sdim# 8259698Sdim# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9259698Sdim# or http://www.opensolaris.org/os/licensing. 10259698Sdim# See the License for the specific language governing permissions 11259698Sdim# and limitations under the License. 12259698Sdim# 13259698Sdim# When distributing Covered Code, include this CDDL HEADER in each 14259698Sdim# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15259698Sdim# If applicable, add the following below this CDDL HEADER, with the 16259698Sdim# fields enclosed by brackets "[]" replaced with your own identifying 17259698Sdim# information: Portions Copyright [yyyy] [name of copyright owner] 18259698Sdim# 19259698Sdim# CDDL HEADER END 20259698Sdim# 21259698Sdim 22259698Sdim# 23259698Sdim# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24259698Sdim# Use is subject to license terms. 25259698Sdim# 26259698Sdim# ident "%Z%%M% %I% %E% SMI" 27259698Sdim 28259698Sdimif [ $# != 1 ]; then 29259698Sdim echo expected one argument: '<'dtrace-path'>' 30259698Sdim exit 2 31259698Sdimfi 32259698Sdim 33259698Sdimdtrace=$1 34259698SdimDIR=/var/tmp/dtest.$$ 35259698Sdim 36259698Sdimmkdir $DIR 37259698Sdimcd $DIR 38259698Sdim 39259698Sdimcat > prov.d <<EOF 40259698Sdimprovider test_prov { 41259698Sdim probe go(); 42259698Sdim}; 43259698SdimEOF 44259698Sdim 45259698Sdim$dtrace -h -s prov.d 46259698Sdimif [ $? -ne 0 ]; then 47259698Sdim print -u2 "failed to generate header file" 48259698Sdim exit 1 49259698Sdimfi 50259698Sdim 51259698Sdimcat > test.c <<EOF 52259698Sdim#include <sys/types.h> 53259698Sdim#include "prov.h" 54259698Sdim 55259698Sdimint 56259698Sdimmain(int argc, char **argv) 57259698Sdim{ 58259698Sdim if (TEST_PROV_GO_ENABLED()) { 59259698Sdim TEST_PROV_GO(); 60259698Sdim } 61259698Sdim} 62259698SdimEOF 63259698Sdim 64259698Sdimcc -xarch=generic -c test.c 65259698Sdimif [ $? -ne 0 ]; then 66259698Sdim print -u2 "failed to compile test.c" 67259698Sdim exit 1 68259698Sdimfi 69259698Sdim$dtrace -G -s prov.d test.o 70259698Sdimif [ $? -ne 0 ]; then 71259698Sdim print -u2 "failed to create DOF" 72259698Sdim exit 1 73259698Sdimfi 74259698Sdimcc -xarch=generic -o test test.o prov.o 75259698Sdimif [ $? -ne 0 ]; then 76259698Sdim print -u2 "failed to link final executable" 77259698Sdim exit 1 78259698Sdimfi 79259698Sdim 80259698Sdimscript() 81259698Sdim{ 82259698Sdim $dtrace -c ./test -qs /dev/stdin <<EOF 83259698Sdim test_prov\$target::: 84259698Sdim { 85259698Sdim printf("%s:%s:%s\n", probemod, probefunc, probename); 86259698Sdim } 87259698SdimEOF 88259698Sdim} 89259698Sdim 90259698Sdimscript 91259698Sdimstatus=$? 92259698Sdim 93259698Sdimcd / 94259698Sdim/bin/rm -rf $DIR 95259698Sdim 96259698Sdimexit $status 97259698Sdim