tst.nodtrace.ksh revision 303975
1254721Semaste#
2254721Semaste# CDDL HEADER START
3254721Semaste#
4254721Semaste# The contents of this file are subject to the terms of the
5254721Semaste# Common Development and Distribution License (the "License").
6254721Semaste# You may not use this file except in compliance with the License.
7254721Semaste#
8254721Semaste# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9254721Semaste# or http://www.opensolaris.org/os/licensing.
10254721Semaste# See the License for the specific language governing permissions
11254721Semaste# and limitations under the License.
12254721Semaste#
13254721Semaste# When distributing Covered Code, include this CDDL HEADER in each
14254721Semaste# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15254721Semaste# If applicable, add the following below this CDDL HEADER, with the
16254721Semaste# fields enclosed by brackets "[]" replaced with your own identifying
17254721Semaste# information: Portions Copyright [yyyy] [name of copyright owner]
18254721Semaste#
19254721Semaste# CDDL HEADER END
20254721Semaste#
21254721Semaste
22254721Semaste#
23254721Semaste# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24254721Semaste# Use is subject to license terms.
25254721Semaste#
26254721Semaste# ident	"%Z%%M%	%I%	%E% SMI"
27254721Semaste
28254721Semaste# Fake up a scenario where _DTRACE_VERSION is not defined by having our own
29254721Semaste# <unistd.h>. This tests that dtrace -h will produce a header file which can
30254721Semaste# be used on a system where DTrace is not present.
31254721Semaste
32254721Semasteif [ $# != 1 ]; then
33254721Semaste	echo expected one argument: '<'dtrace-path'>'
34254721Semaste	exit 2
35254721Semastefi
36254721Semaste
37254721Semastedtrace=$1
38254721SemasteDIR=/var/tmp/dtest.$$
39254721Semaste
40254721Semastemkdir $DIR
41254721Semastecd $DIR
42254721Semaste
43254721Semastetouch unistd.h
44254721Semaste
45254721Semastecat > prov.d <<EOF
46254721Semasteprovider test_prov {
47254721Semaste	probe go();
48254721Semaste};
49254721SemasteEOF
50254721Semaste
51254721Semaste$dtrace -h -s prov.d
52263367Semasteif [ $? -ne 0 ]; then
53254721Semaste	print -u2 "failed to generate header file"
54254721Semaste	exit 1
55254721Semastefi
56254721Semaste
57254721Semastecat > test.c <<EOF
58254721Semaste#include "prov.h"
59254721Semaste
60254721Semasteint
61254721Semastemain(int argc, char **argv)
62254721Semaste{
63254721Semaste	TEST_PROV_GO();
64254721Semaste
65254721Semaste	if (TEST_PROV_GO_ENABLED()) {
66254721Semaste		TEST_PROV_GO();
67254721Semaste	}
68254721Semaste
69254721Semaste	return (0);
70254721Semaste}
71254721SemasteEOF
72254721Semaste
73cc -I. -xarch=generic -c test.c
74if [ $? -ne 0 ]; then
75	print -u2 "failed to compile test.c"
76	exit 1
77fi
78cc -xarch=generic -o test test.o
79if [ $? -ne 0 ]; then
80	print -u2 "failed to link final executable"
81	exit 1
82fi
83
84./test
85status=$?
86
87cd /
88/bin/rm -rf $DIR
89
90exit $status
91