19512fe85Sahl#!/bin/ksh -p 29512fe85Sahl# 39512fe85Sahl# CDDL HEADER START 49512fe85Sahl# 59512fe85Sahl# The contents of this file are subject to the terms of the 69512fe85Sahl# Common Development and Distribution License (the "License"). 79512fe85Sahl# You may not use this file except in compliance with the License. 89512fe85Sahl# 99512fe85Sahl# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 109512fe85Sahl# or http://www.opensolaris.org/os/licensing. 119512fe85Sahl# See the License for the specific language governing permissions 129512fe85Sahl# and limitations under the License. 139512fe85Sahl# 149512fe85Sahl# When distributing Covered Code, include this CDDL HEADER in each 159512fe85Sahl# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 169512fe85Sahl# If applicable, add the following below this CDDL HEADER, with the 179512fe85Sahl# fields enclosed by brackets "[]" replaced with your own identifying 189512fe85Sahl# information: Portions Copyright [yyyy] [name of copyright owner] 199512fe85Sahl# 209512fe85Sahl# CDDL HEADER END 219512fe85Sahl# 229512fe85Sahl 239512fe85Sahl# 249512fe85Sahl# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 259512fe85Sahl# Use is subject to license terms. 269512fe85Sahl# 279512fe85Sahl 2823b5c241Stomeeif [ $# != 1 ]; then 2923b5c241Stomee echo expected one argument: '<'dtrace-path'>' 3023b5c241Stomee exit 2 3123b5c241Stomeefi 3223b5c241Stomee 3323b5c241Stomeedtrace=$1 349512fe85SahlDIR=/var/tmp/dtest.$$ 359512fe85Sahl 369512fe85Sahlmkdir $DIR 379512fe85Sahlcd $DIR 389512fe85Sahl 399512fe85Sahlcat > prov.d <<EOF 409512fe85Sahlprovider test_prov { 419512fe85Sahl probe go(); 429512fe85Sahl}; 439512fe85SahlEOF 449512fe85Sahl 4523b5c241Stomee$dtrace -h -s prov.d 469512fe85Sahlif [ $? -ne 0 ]; then 479512fe85Sahl print -u2 "failed to generate header file" 489512fe85Sahl exit 1 499512fe85Sahlfi 509512fe85Sahl 519512fe85Sahlcat > test.c <<EOF 529512fe85Sahl#include <sys/types.h> 539512fe85Sahl#include "prov.h" 549512fe85Sahl 559512fe85Sahlint 569512fe85Sahlmain(int argc, char **argv) 579512fe85Sahl{ 589512fe85Sahl TEST_PROV_GO(); 599512fe85Sahl 609512fe85Sahl return (0); 619512fe85Sahl} 629512fe85SahlEOF 639512fe85Sahl 64*a386cc11SRobert Mustacchigcc -m32 -c test.c 659512fe85Sahlif [ $? -ne 0 ]; then 669512fe85Sahl print -u2 "failed to compile test.c" 679512fe85Sahl exit 1 689512fe85Sahlfi 6923b5c241Stomee$dtrace -G -32 -s prov.d test.o 709512fe85Sahlif [ $? -ne 0 ]; then 719512fe85Sahl print -u2 "failed to create DOF" 729512fe85Sahl exit 1 739512fe85Sahlfi 74*a386cc11SRobert Mustacchigcc -m32 -o test test.o prov.o 759512fe85Sahlif [ $? -ne 0 ]; then 769512fe85Sahl print -u2 "failed to link final executable" 779512fe85Sahl exit 1 789512fe85Sahlfi 799512fe85Sahl 809512fe85Sahlscript() { 8123b5c241Stomee $dtrace -c 'ppriv -e -s A=basic ./test' -Zqs /dev/stdin <<EOF 829512fe85Sahl test_prov\$target::: 839512fe85Sahl { 849512fe85Sahl printf("%s:%s:%s\n", probemod, probefunc, probename); 859512fe85Sahl } 869512fe85SahlEOF 879512fe85Sahl} 889512fe85Sahl 899512fe85Sahlscript 909512fe85Sahlstatus=$? 919512fe85Sahl 929512fe85Sahlcd / 939512fe85Sahl/usr/bin/rm -rf $DIR 949512fe85Sahl 959512fe85Sahlexit $status 96