xref: /onnv-gate/usr/src/cmd/dtrace/test/tst/common/usdt/tst.header.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 zero();
422633Sahl	probe one(uintptr_t);
432633Sahl	probe u_nder(char *);
442633Sahl	probe d__ash(int **);
452633Sahl};
462633SahlEOF
472633Sahl
48*2804Stomee$dtrace -h -s prov.d
492633Sahlif [ $? -ne 0 ]; then
502633Sahl	print -u2 "failed to generate header file"
512633Sahl	exit 1
522633Sahlfi
532633Sahl
542633Sahlcat > test.c <<EOF
552633Sahl#include <sys/types.h>
562633Sahl#include "prov.h"
572633Sahl
582633Sahlint
592633Sahlmain(int argc, char **argv)
602633Sahl{
612633Sahl	TEST_PROV_ZERO();
622633Sahl	TEST_PROV_ONE(1);
632633Sahl	TEST_PROV_U_NDER("hi there");
642633Sahl	TEST_PROV_D_ASH(argv);
652633Sahl}
662633SahlEOF
672633Sahl
682633Sahlcc -c test.c
692633Sahlif [ $? -ne 0 ]; then
702633Sahl	print -u2 "failed to compile test.c"
712633Sahl	exit 1
722633Sahlfi
73*2804Stomee$dtrace -G -32 -s prov.d test.o
742633Sahlif [ $? -ne 0 ]; then
752633Sahl	print -u2 "failed to create DOF"
762633Sahl	exit 1
772633Sahlfi
782633Sahlcc -o test test.o prov.o
792633Sahlif [ $? -ne 0 ]; then
802633Sahl	print -u2 "failed to link final executable"
812633Sahl	exit 1
822633Sahlfi
832633Sahl
842633Sahlcd /
852633Sahl/usr/bin/rm -rf $DIR
86