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