#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
#
#
# Copyright (c) 2012, Joyent, Inc.
#
#
# This test validates that the -zassert-deflib option of ld(1) works correctly.
# It requires that some cc is in your path and that you have passed in the path
# to the proto area with the new version of libld.so.4. One thing that we have
# to do is be careful with using LD_LIBRARY_PATH. Setting LD_LIBRARY_PATH does
# not change the default search path so we want to make sure that we use a
# different ISA (e.g. 32-bit vs 64-bit) from the binary we're generating.
#
unalias -a
sh_lib="lib"
sh_cc="cc"
sh_cflags="-m32"
function fatal
{
local msg="$*"
exit 1
}
#
# Validate that everything we need is in our path. That includes having cc
# and the proto area libld.
#
function validate
{
[[ -f $sh_path/$sh_lib/$sh_soname ]] || fatal "missing 32-bit $sh_soname"
[[ -f $sh_path/$sh_lib64/$sh_soname ]] ||
fatal "missing 64-bit $sh_soname"
}
#
# $1 is a series of flags to append
# $2 is expected exit status
# $3 is pre-test message
# $4 is the failure message
#
function run
{
local ret
echo $3
if [[ $? -eq $2 ]]; then
printf "success\n\n"
else
fatal $4
fi
}
sh_path=$1
"Testing basic compilation succeeds with warnings..." \
"failed to compile with warnings"
"Testing basic compilation fails if warning are fatal..." \
"linking succeeeded, expected failure"
"Testing basic exception with fatal warnings..." \
"linking failed despite exception"
"Testing basic exception with fatal warnings..." \
"linking failed despite exception"
"Testing invalid library name..." \
"ld should not allow invalid library name"
"Testing invalid library name..." \
"ld should not allow invalid library name"
"Testing invalid library name..." \
"ld should not allow invalid library name"
"Errors even if one library is under exception path..." \
"one exception shouldn't stop another"
"Multiple exceptions work..." \
"multiple exceptions don't work"
args="-Wl,-zassert-deflib=libc.so -Wl,-zassert-deflib=libelfe.so"
"Exceptions only catch the specific library" \
"exceptions caught the wrong library"
"Exceptions only catch the specific library" \
"exceptions caught the wrong library"
echo "Tests passed."
exit 0