1*7304104dSAndroid Build Coastguard Worker#! /bin/sh 2*7304104dSAndroid Build Coastguard Worker# Copyright (C) 2005-2012 Red Hat, Inc. 3*7304104dSAndroid Build Coastguard Worker# This file is part of elfutils. 4*7304104dSAndroid Build Coastguard Worker# 5*7304104dSAndroid Build Coastguard Worker# This file is free software; you can redistribute it and/or modify 6*7304104dSAndroid Build Coastguard Worker# it under the terms of the GNU General Public License as published by 7*7304104dSAndroid Build Coastguard Worker# the Free Software Foundation; either version 3 of the License, or 8*7304104dSAndroid Build Coastguard Worker# (at your option) any later version. 9*7304104dSAndroid Build Coastguard Worker# 10*7304104dSAndroid Build Coastguard Worker# elfutils is distributed in the hope that it will be useful, but 11*7304104dSAndroid Build Coastguard Worker# WITHOUT ANY WARRANTY; without even the implied warranty of 12*7304104dSAndroid Build Coastguard Worker# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*7304104dSAndroid Build Coastguard Worker# GNU General Public License for more details. 14*7304104dSAndroid Build Coastguard Worker# 15*7304104dSAndroid Build Coastguard Worker# You should have received a copy of the GNU General Public License 16*7304104dSAndroid Build Coastguard Worker# along with this program. If not, see <http://www.gnu.org/licenses/>. 17*7304104dSAndroid Build Coastguard Worker 18*7304104dSAndroid Build Coastguard Worker 19*7304104dSAndroid Build Coastguard Worker# We don't compile in an rpath because we want "make installcheck" to 20*7304104dSAndroid Build Coastguard Worker# use the installed libraries. So for local test runs we need to point 21*7304104dSAndroid Build Coastguard Worker# the library path at this build. 22*7304104dSAndroid Build Coastguard Worker 23*7304104dSAndroid Build Coastguard Worker# This wrapper script is called by the makefile, in one of two ways: 24*7304104dSAndroid Build Coastguard Worker# $(srcdir)/test-wrapper.sh ../libelf:... run-test.sh ... 25*7304104dSAndroid Build Coastguard Worker# or: 26*7304104dSAndroid Build Coastguard Worker# $(srcdir)/test-wrapper.sh installed s,^,eu-, run-test.sh ... 27*7304104dSAndroid Build Coastguard Worker 28*7304104dSAndroid Build Coastguard Workerif [ "$1" = installed ]; then 29*7304104dSAndroid Build Coastguard Worker shift 30*7304104dSAndroid Build Coastguard Worker elfutils_tests_rpath=$1 31*7304104dSAndroid Build Coastguard Worker shift 32*7304104dSAndroid Build Coastguard Worker program_transform_name="$1" 33*7304104dSAndroid Build Coastguard Worker shift 34*7304104dSAndroid Build Coastguard Worker elfutils_testrun=installed 35*7304104dSAndroid Build Coastguard Workerelse 36*7304104dSAndroid Build Coastguard Worker built_library_path="$1" 37*7304104dSAndroid Build Coastguard Worker shift 38*7304104dSAndroid Build Coastguard Worker elfutils_testrun=built 39*7304104dSAndroid Build Coastguard Workerfi 40*7304104dSAndroid Build Coastguard Worker 41*7304104dSAndroid Build Coastguard Workerold_path="${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" 42*7304104dSAndroid Build Coastguard Worker 43*7304104dSAndroid Build Coastguard Workercase "$1" in 44*7304104dSAndroid Build Coastguard Worker*.sh) 45*7304104dSAndroid Build Coastguard Worker export built_library_path program_transform_name elfutils_testrun 46*7304104dSAndroid Build Coastguard Worker export elfutils_tests_rpath 47*7304104dSAndroid Build Coastguard Worker is_shell_script="yes" 48*7304104dSAndroid Build Coastguard Worker ;; 49*7304104dSAndroid Build Coastguard Worker*) 50*7304104dSAndroid Build Coastguard Worker if [ $elfutils_testrun = built ]; then 51*7304104dSAndroid Build Coastguard Worker LD_LIBRARY_PATH="$built_library_path$old_path" 52*7304104dSAndroid Build Coastguard Worker elif [ $elfutils_tests_rpath = yes ]; then 53*7304104dSAndroid Build Coastguard Worker echo >&2 installcheck not possible with --enable-tests-rpath 54*7304104dSAndroid Build Coastguard Worker exit 77 55*7304104dSAndroid Build Coastguard Worker elif [ "x$libdir" != x/usr/lib ] && [ "x$libdir" != x/usr/lib64 ]; then 56*7304104dSAndroid Build Coastguard Worker LD_LIBRARY_PATH="${libdir}:${libdir}/elfutils$old_path" 57*7304104dSAndroid Build Coastguard Worker fi 58*7304104dSAndroid Build Coastguard Worker export LD_LIBRARY_PATH 59*7304104dSAndroid Build Coastguard Worker is_shell_script="no" 60*7304104dSAndroid Build Coastguard Worker ;; 61*7304104dSAndroid Build Coastguard Workeresac 62*7304104dSAndroid Build Coastguard Worker 63*7304104dSAndroid Build Coastguard Workerif [ "x$VALGRIND_CMD" != "x" ]; then 64*7304104dSAndroid Build Coastguard Worker export VALGRIND_CMD 65*7304104dSAndroid Build Coastguard Workerfi 66*7304104dSAndroid Build Coastguard Worker 67*7304104dSAndroid Build Coastguard Worker# When it is a run-*.sh script the VALGRIND_CMD will be passed on 68*7304104dSAndroid Build Coastguard Worker# otherwise we'll need to run the binary explicitly under valgrind. 69*7304104dSAndroid Build Coastguard Workerif [ "x$is_shell_script" = xyes ]; then 70*7304104dSAndroid Build Coastguard Worker exec "$@" 71*7304104dSAndroid Build Coastguard Workerelse 72*7304104dSAndroid Build Coastguard Worker exec $VALGRIND_CMD "$@" 73*7304104dSAndroid Build Coastguard Workerfi 74