1*694a0093SPedro F. Giffuni# 2*694a0093SPedro F. Giffuni# CDDL HEADER START 3*694a0093SPedro F. Giffuni# 4*694a0093SPedro F. Giffuni# The contents of this file are subject to the terms of the 5*694a0093SPedro F. Giffuni# Common Development and Distribution License (the "License"). 6*694a0093SPedro F. Giffuni# You may not use this file except in compliance with the License. 7*694a0093SPedro F. Giffuni# 8*694a0093SPedro F. Giffuni# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*694a0093SPedro F. Giffuni# or http://www.opensolaris.org/os/licensing. 10*694a0093SPedro F. Giffuni# See the License for the specific language governing permissions 11*694a0093SPedro F. Giffuni# and limitations under the License. 12*694a0093SPedro F. Giffuni# 13*694a0093SPedro F. Giffuni# When distributing Covered Code, include this CDDL HEADER in each 14*694a0093SPedro F. Giffuni# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*694a0093SPedro F. Giffuni# If applicable, add the following below this CDDL HEADER, with the 16*694a0093SPedro F. Giffuni# fields enclosed by brackets "[]" replaced with your own identifying 17*694a0093SPedro F. Giffuni# information: Portions Copyright [yyyy] [name of copyright owner] 18*694a0093SPedro F. Giffuni# 19*694a0093SPedro F. Giffuni# CDDL HEADER END 20*694a0093SPedro F. Giffuni# 21*694a0093SPedro F. Giffuni 22*694a0093SPedro F. Giffuni# 23*694a0093SPedro F. Giffuni# Copyright (c) 2011, Joyent Inc. All rights reserved. 24*694a0093SPedro F. Giffuni# Use is subject to license terms. 25*694a0093SPedro F. Giffuni# 26*694a0093SPedro F. Giffuni 27*694a0093SPedro F. Giffuni# 28*694a0093SPedro F. Giffuni# This test verifies that we only use the first entry of a file with a given 29*694a0093SPedro F. Giffuni# name in the library path 30*694a0093SPedro F. Giffuni# 31*694a0093SPedro F. Giffuni 32*694a0093SPedro F. Giffuniif [ $# != 1 ]; then 33*694a0093SPedro F. Giffuni echo expected one argument: '<'dtrace-path'>' 34*694a0093SPedro F. Giffuni exit 2 35*694a0093SPedro F. Giffunifi 36*694a0093SPedro F. Giffuni 37*694a0093SPedro F. Giffunifirstinc=${TMPDIR:-/tmp}/firstinc.$$ 38*694a0093SPedro F. Giffunisecondinc=${TMPDIR:-/tmp}/secondinc.$$ 39*694a0093SPedro F. Giffuniexpexit=23 40*694a0093SPedro F. Giffuni 41*694a0093SPedro F. Giffunisetup_include() 42*694a0093SPedro F. Giffuni{ 43*694a0093SPedro F. Giffuni mkdir $firstinc 44*694a0093SPedro F. Giffuni mkdir $secondinc 45*694a0093SPedro F. Giffuni cat > $firstinc/lib.d <<EOF 46*694a0093SPedro F. Giffuniinline int foobar = $expexit; 47*694a0093SPedro F. Giffuni#pragma D binding "1.0" foobar 48*694a0093SPedro F. GiffuniEOF 49*694a0093SPedro F. Giffuni cat > $secondinc/lib.d <<EOF 50*694a0093SPedro F. Giffuniinline int foobar = 42; 51*694a0093SPedro F. Giffuni#pragma D binding "1.0" foobar 52*694a0093SPedro F. GiffuniEOF 53*694a0093SPedro F. Giffuni} 54*694a0093SPedro F. Giffuni 55*694a0093SPedro F. Giffuniclean() 56*694a0093SPedro F. Giffuni{ 57*694a0093SPedro F. Giffuni rm -rf $firstinc 58*694a0093SPedro F. Giffuni rm -rf $secondinc 59*694a0093SPedro F. Giffuni} 60*694a0093SPedro F. Giffuni 61*694a0093SPedro F. Giffunifail() 62*694a0093SPedro F. Giffuni{ 63*694a0093SPedro F. Giffuni echo "$@" 64*694a0093SPedro F. Giffuni clean 65*694a0093SPedro F. Giffuni exit 1 66*694a0093SPedro F. Giffuni} 67*694a0093SPedro F. Giffuni 68*694a0093SPedro F. Giffunisetup_include 69*694a0093SPedro F. Giffuni 70*694a0093SPedro F. Giffunidtrace -L$firstinc -L$secondinc -e -n 'BEGIN{ exit(foobar) }' 71*694a0093SPedro F. Giffuni[[ $? != 0 ]] && fail "Failed to compile with same file in include path twice" 72*694a0093SPedro F. Giffunidtrace -L$firstinc -L$secondinc -n 'BEGIN{ exit(foobar) }' 73*694a0093SPedro F. Giffunistatus=$? 74*694a0093SPedro F. Giffuni[[ $status != $expexit ]] && fail "Exited with unexpected status code: $status" 75*694a0093SPedro F. Giffuniclean 76*694a0093SPedro F. Giffuniexit 0 77