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  ;;
48*)
49  if [ $elfutils_testrun = built ]; then
50    LD_LIBRARY_PATH="$built_library_path$old_path"
51  elif [ $elfutils_tests_rpath = yes ]; then
52    echo >&2 installcheck not possible with --enable-tests-rpath
53    exit 77
54  elif [ "x$libdir" != x/usr/lib ] && [ "x$libdir" != x/usr/lib64 ]; then
55    LD_LIBRARY_PATH="${libdir}:${libdir}/elfutils$old_path"
56  fi
57  export LD_LIBRARY_PATH
58  ;;
59esac
60
61if [ "x$VALGRIND_CMD" != "x" ]; then
62  export VALGRIND_CMD
63fi
64
65exec "$@"
66