2b6e762c557496a41438c0b105d604f60c593682ahl#
2b6e762c557496a41438c0b105d604f60c593682ahl# CDDL HEADER START
2b6e762c557496a41438c0b105d604f60c593682ahl#
2b6e762c557496a41438c0b105d604f60c593682ahl# The contents of this file are subject to the terms of the
2b6e762c557496a41438c0b105d604f60c593682ahl# Common Development and Distribution License (the "License").
2b6e762c557496a41438c0b105d604f60c593682ahl# You may not use this file except in compliance with the License.
2b6e762c557496a41438c0b105d604f60c593682ahl#
2b6e762c557496a41438c0b105d604f60c593682ahl# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2b6e762c557496a41438c0b105d604f60c593682ahl# or http://www.opensolaris.org/os/licensing.
2b6e762c557496a41438c0b105d604f60c593682ahl# See the License for the specific language governing permissions
2b6e762c557496a41438c0b105d604f60c593682ahl# and limitations under the License.
2b6e762c557496a41438c0b105d604f60c593682ahl#
2b6e762c557496a41438c0b105d604f60c593682ahl# When distributing Covered Code, include this CDDL HEADER in each
2b6e762c557496a41438c0b105d604f60c593682ahl# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2b6e762c557496a41438c0b105d604f60c593682ahl# If applicable, add the following below this CDDL HEADER, with the
2b6e762c557496a41438c0b105d604f60c593682ahl# fields enclosed by brackets "[]" replaced with your own identifying
2b6e762c557496a41438c0b105d604f60c593682ahl# information: Portions Copyright [yyyy] [name of copyright owner]
2b6e762c557496a41438c0b105d604f60c593682ahl#
2b6e762c557496a41438c0b105d604f60c593682ahl# CDDL HEADER END
2b6e762c557496a41438c0b105d604f60c593682ahl#
2b6e762c557496a41438c0b105d604f60c593682ahl
2b6e762c557496a41438c0b105d604f60c593682ahl#
2b6e762c557496a41438c0b105d604f60c593682ahl# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
2b6e762c557496a41438c0b105d604f60c593682ahl# Use is subject to license terms.
2b6e762c557496a41438c0b105d604f60c593682ahl#
2b6e762c557496a41438c0b105d604f60c593682ahl
2b6e762c557496a41438c0b105d604f60c593682ahl# Fake up a scenario where _DTRACE_VERSION is not defined by having our own
2b6e762c557496a41438c0b105d604f60c593682ahl# <unistd.h>. This tests that dtrace -h will produce a header file which can
2b6e762c557496a41438c0b105d604f60c593682ahl# be used on a system where DTrace is not present.
2b6e762c557496a41438c0b105d604f60c593682ahl
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomeeif [ $# != 1 ]; then
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee echo expected one argument: '<'dtrace-path'>'
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee exit 2
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomeefi
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomeedtrace=$1
2b6e762c557496a41438c0b105d604f60c593682ahlDIR=/var/tmp/dtest.$$
2b6e762c557496a41438c0b105d604f60c593682ahl
2b6e762c557496a41438c0b105d604f60c593682ahlmkdir $DIR
2b6e762c557496a41438c0b105d604f60c593682ahlcd $DIR
2b6e762c557496a41438c0b105d604f60c593682ahl
2b6e762c557496a41438c0b105d604f60c593682ahltouch unistd.h
2b6e762c557496a41438c0b105d604f60c593682ahl
2b6e762c557496a41438c0b105d604f60c593682ahlcat > prov.d <<EOF
2b6e762c557496a41438c0b105d604f60c593682ahlprovider test_prov {
2b6e762c557496a41438c0b105d604f60c593682ahl probe go();
2b6e762c557496a41438c0b105d604f60c593682ahl};
2b6e762c557496a41438c0b105d604f60c593682ahlEOF
2b6e762c557496a41438c0b105d604f60c593682ahl
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee$dtrace -h -s prov.d
2b6e762c557496a41438c0b105d604f60c593682ahlif [ $? -ne 0 ]; then
2b6e762c557496a41438c0b105d604f60c593682ahl print -u2 "failed to generate header file"
2b6e762c557496a41438c0b105d604f60c593682ahl exit 1
2b6e762c557496a41438c0b105d604f60c593682ahlfi
2b6e762c557496a41438c0b105d604f60c593682ahl
2b6e762c557496a41438c0b105d604f60c593682ahlcat > test.c <<EOF
2b6e762c557496a41438c0b105d604f60c593682ahl#include "prov.h"
2b6e762c557496a41438c0b105d604f60c593682ahl
2b6e762c557496a41438c0b105d604f60c593682ahlint
2b6e762c557496a41438c0b105d604f60c593682ahlmain(int argc, char **argv)
2b6e762c557496a41438c0b105d604f60c593682ahl{
2b6e762c557496a41438c0b105d604f60c593682ahl TEST_PROV_GO();
2b6e762c557496a41438c0b105d604f60c593682ahl
2b6e762c557496a41438c0b105d604f60c593682ahl if (TEST_PROV_GO_ENABLED()) {
2b6e762c557496a41438c0b105d604f60c593682ahl TEST_PROV_GO();
2b6e762c557496a41438c0b105d604f60c593682ahl }
2b6e762c557496a41438c0b105d604f60c593682ahl
2b6e762c557496a41438c0b105d604f60c593682ahl return (0);
2b6e762c557496a41438c0b105d604f60c593682ahl}
2b6e762c557496a41438c0b105d604f60c593682ahlEOF
2b6e762c557496a41438c0b105d604f60c593682ahl
c090e5dfb10cc96e71e6b0f55bf98c18027b002cBryan Cantrillgcc -I. -m32 -c test.c
2b6e762c557496a41438c0b105d604f60c593682ahlif [ $? -ne 0 ]; then
2b6e762c557496a41438c0b105d604f60c593682ahl print -u2 "failed to compile test.c"
2b6e762c557496a41438c0b105d604f60c593682ahl exit 1
2b6e762c557496a41438c0b105d604f60c593682ahlfi
c090e5dfb10cc96e71e6b0f55bf98c18027b002cBryan Cantrillgcc -m32 -o test test.o
2b6e762c557496a41438c0b105d604f60c593682ahlif [ $? -ne 0 ]; then
2b6e762c557496a41438c0b105d604f60c593682ahl print -u2 "failed to link final executable"
2b6e762c557496a41438c0b105d604f60c593682ahl exit 1
2b6e762c557496a41438c0b105d604f60c593682ahlfi
2b6e762c557496a41438c0b105d604f60c593682ahl
2b6e762c557496a41438c0b105d604f60c593682ahl./test
2b6e762c557496a41438c0b105d604f60c593682ahlstatus=$?
2b6e762c557496a41438c0b105d604f60c593682ahl
2b6e762c557496a41438c0b105d604f60c593682ahlcd /
2b6e762c557496a41438c0b105d604f60c593682ahl/usr/bin/rm -rf $DIR
2b6e762c557496a41438c0b105d604f60c593682ahl
2b6e762c557496a41438c0b105d604f60c593682ahlexit $status