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