159874Speter#
259874Speter# CDDL HEADER START
3206363Sjkim#
4206363Sjkim# The contents of this file are subject to the terms of the
542120Sdes# Common Development and Distribution License (the "License").
6206363Sjkim# You may not use this file except in compliance with the License.
7206363Sjkim#
881322Speter# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9206363Sjkim# or http://www.opensolaris.org/os/licensing.
10206363Sjkim# See the License for the specific language governing permissions
11206363Sjkim# and limitations under the License.
12206363Sjkim#
13206363Sjkim# When distributing Covered Code, include this CDDL HEADER in each
14206363Sjkim# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15206363Sjkim# If applicable, add the following below this CDDL HEADER, with the
16206363Sjkim# fields enclosed by brackets "[]" replaced with your own identifying
17206363Sjkim# information: Portions Copyright [yyyy] [name of copyright owner]
18206363Sjkim#
19206363Sjkim# CDDL HEADER END
20206363Sjkim#
21206363Sjkim
22206363Sjkim#
23206363Sjkim# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24206363Sjkim# Use is subject to license terms.
25206363Sjkim#
26206363Sjkim# ident	"%Z%%M%	%I%	%E% SMI"
27206363Sjkim
28206363Sjkim#
29206363Sjkim# Make sure temporary symbols generated due to DTrace probes in static
30206363Sjkim# functions are removed in the final link step.
31206363Sjkim#
32206363Sjkim
33206363Sjkimif [ $# != 1 ]; then
34206363Sjkim	echo expected one argument: '<'dtrace-path'>'
35206363Sjkim	exit 2
36206363Sjkimfi
37206363Sjkim
38206363Sjkimdtrace=$1
39206363SjkimDIR=/var/tmp/dtest.$$
40206363Sjkim
41206363Sjkimmkdir $DIR
42206363Sjkimcd $DIR
43206363Sjkim
44206363Sjkimcat > prov.d <<EOF
45206363Sjkimprovider test_prov {
46206363Sjkim	probe go();
47206363Sjkim};
48206363SjkimEOF
49206363Sjkim
50206363Sjkim$dtrace -h -s prov.d
51206363Sjkimif [ $? -ne 0 ]; then
52206363Sjkim	print -u2 "failed to generate header file"
53206363Sjkim	exit 1
54206363Sjkimfi
55206363Sjkim
56206363Sjkimcat > test.c <<EOF
57206363Sjkim#include <sys/types.h>
58206363Sjkim#include "prov.h"
59206363Sjkim
60206363Sjkimstatic void
61206363Sjkimfoo(void)
62206363Sjkim{
63206363Sjkim	TEST_PROV_GO();
64206363Sjkim}
65206363Sjkim
66206363Sjkimint
67206363Sjkimmain(int argc, char **argv)
68206363Sjkim{
69206363Sjkim	foo();
70206363Sjkim
71206363Sjkim	return (0);
72206363Sjkim}
73206363SjkimEOF
74206363Sjkim
75206363Sjkimcc -c test.c
76206363Sjkimif [ $? -ne 0 ]; then
77206363Sjkim	print -u2 "failed to compile test.c"
78206363Sjkim	exit 1
79206363Sjkimfi
80206363Sjkim$dtrace -G -s prov.d test.o
81206363Sjkimif [ $? -ne 0 ]; then
82206363Sjkim	print -u2 "failed to create DOF"
83206363Sjkim	exit 1
84206363Sjkimfi
85206363Sjkimcc -o test test.o prov.o
86206363Sjkimif [ $? -ne 0 ]; then
87206363Sjkim	print -u2 "failed to link final executable"
88206363Sjkim	exit 1
89206363Sjkimfi
90206363Sjkim
91206363Sjkimnm test.o | grep \$dtrace > /dev/null
92206363Sjkimif [ $? -ne 0 ]; then
93206363Sjkim	print -u2 "no temporary symbols in the object file"
94206363Sjkim	exit 1
95206363Sjkimfi
96206363Sjkim
97206363Sjkimnm test | grep \$dtrace > /dev/null
98206363Sjkimif [ $? -eq 0 ]; then
99206363Sjkim	print -u2 "failed to eliminate temporary symbols"
100206363Sjkim	exit 1
101206363Sjkimfi
102206363Sjkim
103206363Sjkimcd /
104206363Sjkim/bin/rm -rf $DIR
105206363Sjkim
106206363Sjkimexit 0
107206363Sjkim