1237834Smm# 2237834Smm# CDDL HEADER START 3237834Smm# 4237834Smm# The contents of this file are subject to the terms of the 5237834Smm# Common Development and Distribution License (the "License"). 6237834Smm# You may not use this file except in compliance with the License. 7237834Smm# 8237834Smm# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9237834Smm# or http://www.opensolaris.org/os/licensing. 10237834Smm# See the License for the specific language governing permissions 11237834Smm# and limitations under the License. 12237834Smm# 13237834Smm# When distributing Covered Code, include this CDDL HEADER in each 14237834Smm# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15237834Smm# If applicable, add the following below this CDDL HEADER, with the 16237834Smm# fields enclosed by brackets "[]" replaced with your own identifying 17237834Smm# information: Portions Copyright [yyyy] [name of copyright owner] 18237834Smm# 19237834Smm# CDDL HEADER END 20237834Smm# 21237834Smm 22237834Smm# 23237834Smm# Copyright (c) 2011, Joyent Inc. All rights reserved. 24237834Smm# Use is subject to license terms. 25237834Smm# 26237834Smm 27237834Smm# 28237834Smm# This test verifies that we only use the first entry of a file with a given 29237834Smm# name in the library path 30237834Smm# 31237834Smm 32237834Smmif [ $# != 1 ]; then 33237834Smm echo expected one argument: '<'dtrace-path'>' 34237834Smm exit 2 35237834Smmfi 36237834Smm 37237834Smmfirstinc=${TMPDIR:-/tmp}/firstinc.$$ 38237834Smmsecondinc=${TMPDIR:-/tmp}/secondinc.$$ 39237834Smmexpexit=23 40237834Smm 41237834Smmsetup_include() 42237834Smm{ 43237834Smm mkdir $firstinc 44237834Smm mkdir $secondinc 45237834Smm cat > $firstinc/lib.d <<EOF 46237834Smminline int foobar = $expexit; 47237834Smm#pragma D binding "1.0" foobar 48237834SmmEOF 49237834Smm cat > $secondinc/lib.d <<EOF 50237834Smminline int foobar = 42; 51237834Smm#pragma D binding "1.0" foobar 52237834SmmEOF 53237834Smm} 54237834Smm 55237834Smmclean() 56237834Smm{ 57237834Smm rm -rf $firstinc 58237834Smm rm -rf $secondinc 59237834Smm} 60237834Smm 61237834Smmfail() 62237834Smm{ 63237834Smm echo "$@" 64237834Smm clean 65237834Smm exit 1 66237834Smm} 67237834Smm 68237834Smmsetup_include 69237834Smm 70237834Smmdtrace -L$firstinc -L$secondinc -e -n 'BEGIN{ exit(foobar) }' 71237834Smm[[ $? != 0 ]] && fail "Failed to compile with same file in include path twice" 72237834Smmdtrace -L$firstinc -L$secondinc -n 'BEGIN{ exit(foobar) }' 73237834Smmstatus=$? 74237834Smm[[ $status != $expexit ]] && fail "Exited with unexpected status code: $status" 75237834Smmclean 76237834Smmexit 0 77