xref: /illumos-gate/usr/src/cmd/dtrace/test/tst/common/usdt/tst.eliminate.ksh (revision a386cc11a86ecb60f5a48078d22c1500e2ad003e)
1823b63e1Sahl#
2823b63e1Sahl# CDDL HEADER START
3823b63e1Sahl#
4823b63e1Sahl# The contents of this file are subject to the terms of the
5823b63e1Sahl# Common Development and Distribution License (the "License").
6823b63e1Sahl# You may not use this file except in compliance with the License.
7823b63e1Sahl#
8823b63e1Sahl# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9823b63e1Sahl# or http://www.opensolaris.org/os/licensing.
10823b63e1Sahl# See the License for the specific language governing permissions
11823b63e1Sahl# and limitations under the License.
12823b63e1Sahl#
13823b63e1Sahl# When distributing Covered Code, include this CDDL HEADER in each
14823b63e1Sahl# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15823b63e1Sahl# If applicable, add the following below this CDDL HEADER, with the
16823b63e1Sahl# fields enclosed by brackets "[]" replaced with your own identifying
17823b63e1Sahl# information: Portions Copyright [yyyy] [name of copyright owner]
18823b63e1Sahl#
19823b63e1Sahl# CDDL HEADER END
20823b63e1Sahl#
21823b63e1Sahl
22823b63e1Sahl#
23823b63e1Sahl# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24823b63e1Sahl# Use is subject to license terms.
25823b63e1Sahl#
26823b63e1Sahl
27823b63e1Sahl#
28823b63e1Sahl# Make sure temporary symbols generated due to DTrace probes in static
29823b63e1Sahl# functions are removed in the final link step.
30823b63e1Sahl#
31823b63e1Sahl
32823b63e1Sahlif [ $# != 1 ]; then
33823b63e1Sahl	echo expected one argument: '<'dtrace-path'>'
34823b63e1Sahl	exit 2
35823b63e1Sahlfi
36823b63e1Sahl
37823b63e1Sahldtrace=$1
38823b63e1SahlDIR=/var/tmp/dtest.$$
39823b63e1Sahl
40823b63e1Sahlmkdir $DIR
41823b63e1Sahlcd $DIR
42823b63e1Sahl
43823b63e1Sahlcat > prov.d <<EOF
44823b63e1Sahlprovider test_prov {
45823b63e1Sahl	probe go();
46823b63e1Sahl};
47823b63e1SahlEOF
48823b63e1Sahl
49823b63e1Sahl$dtrace -h -s prov.d
50823b63e1Sahlif [ $? -ne 0 ]; then
51823b63e1Sahl	print -u2 "failed to generate header file"
52823b63e1Sahl	exit 1
53823b63e1Sahlfi
54823b63e1Sahl
55823b63e1Sahlcat > test.c <<EOF
56823b63e1Sahl#include <sys/types.h>
57823b63e1Sahl#include "prov.h"
58823b63e1Sahl
59823b63e1Sahlstatic void
60823b63e1Sahlfoo(void)
61823b63e1Sahl{
62823b63e1Sahl	TEST_PROV_GO();
63823b63e1Sahl}
64823b63e1Sahl
65823b63e1Sahlint
66823b63e1Sahlmain(int argc, char **argv)
67823b63e1Sahl{
68823b63e1Sahl	foo();
69823b63e1Sahl
70823b63e1Sahl	return (0);
71823b63e1Sahl}
72823b63e1SahlEOF
73823b63e1Sahl
74*a386cc11SRobert Mustacchigcc -m32 -c test.c
75823b63e1Sahlif [ $? -ne 0 ]; then
76823b63e1Sahl	print -u2 "failed to compile test.c"
77823b63e1Sahl	exit 1
78823b63e1Sahlfi
79823b63e1Sahl$dtrace -G -32 -s prov.d test.o
80823b63e1Sahlif [ $? -ne 0 ]; then
81823b63e1Sahl	print -u2 "failed to create DOF"
82823b63e1Sahl	exit 1
83823b63e1Sahlfi
84*a386cc11SRobert Mustacchigcc -m32 -o test test.o prov.o
85823b63e1Sahlif [ $? -ne 0 ]; then
86823b63e1Sahl	print -u2 "failed to link final executable"
87823b63e1Sahl	exit 1
88823b63e1Sahlfi
89823b63e1Sahl
90823b63e1Sahlnm test.o | grep \$dtrace > /dev/null
91823b63e1Sahlif [ $? -ne 0 ]; then
92823b63e1Sahl	print -u2 "no temporary symbols in the object file"
93823b63e1Sahl	exit 1
94823b63e1Sahlfi
95823b63e1Sahl
96823b63e1Sahlnm test | grep \$dtrace > /dev/null
97823b63e1Sahlif [ $? -eq 0 ]; then
98823b63e1Sahl	print -u2 "failed to eliminate temporary symbols"
99823b63e1Sahl	exit 1
100823b63e1Sahlfi
101823b63e1Sahl
102823b63e1Sahlcd /
103823b63e1Sahl/usr/bin/rm -rf $DIR
104823b63e1Sahl
105823b63e1Sahlexit 0
106