2 # Copyright (C) 2005-2014 Red Hat, Inc.
3 # This file is part of elfutils.
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.
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.
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/>.
19 # This file is sourced by ". $srcdir/test-subr.sh" at the start of
20 # each test script. It defines some functions they use and sets up
21 # canonical sh state for test runs.
25 # Each test runs in its own directory to make sure they can run in parallel.
35 # Tests that trap EXIT (0) themselves should call this explicitly.
38 rm -f $remove_files; cd ..; rmdir $test_dir
44 remove_files="$remove_files $*"
50 bunzip2 -c ${abs_srcdir}/${file}.bz2 > ${file} 2>/dev/null || exit 77
51 remove_files="$remove_files $file"
59 remove_files="$remove_files $outfile"
60 testrun "$@" > $outfile 2>&1 || :
65 outfile="${1##*/}.out"
66 testrun_out $outfile "$@"
68 # diff's exit status will kill the script.
77 # See test-wrapper.sh, which sets the environment for this.
80 ${elfutils_testrun}_testrun "$@"
85 LD_LIBRARY_PATH="${built_library_path}${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"\
95 if [ "x$elfutils_tests_rpath" != xno ]; then
96 echo >&2 installcheck not possible with --enable-tests-rpath
100 ${abs_top_builddir}/src/*)
101 program=${bindir}/`program_transform ${program##*/}`
104 if [ "${libdir}" != /usr/lib ] && [ "${libdir}" != /usr/lib64 ]; then
105 LD_LIBRARY_PATH="${libdir}:${libdir}/elfutils\
106 ${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" \
107 $VALGRIND_CMD $program ${1+"$@"}
109 $VALGRIND_CMD $program ${1+"$@"}
115 echo "$*" | sed "${program_transform_name}"
118 self_test_files=`echo ${abs_top_builddir}/src/addr2line \
119 ${abs_top_builddir}/src/elfcmp ${abs_top_builddir}/src/elflint \
120 ${abs_top_builddir}/src/nm ${abs_top_builddir}/src/objdump \
121 ${abs_top_builddir}/src/readelf \
122 ${abs_top_builddir}/src/size.o ${abs_top_builddir}/src/strip.o \
123 ${abs_top_builddir}/libelf/libelf.so \
124 ${abs_top_builddir}/libdw/libdw.so \
125 ${abs_top_builddir}/backends/libebl_i386.so \
126 ${abs_top_builddir}/backends/libebl_x86_64.so`
128 # Provide a command to run on all self-test files with testrun.
133 for file in $self_test_files; do
135 || { echo "*** failure in $* $file"; exit_status=1; }
138 # Only exit if something failed
139 if test $exit_status != 0; then exit $exit_status; fi
142 # Same as above, but redirects stdout to /dev/null
143 testrun_on_self_quiet()
147 for file in $self_test_files; do
148 testrun $* $file > /dev/null \
149 || { echo "*** failure in $* $file"; exit_status=1; }
152 # Only exit if something failed
153 if test $exit_status != 0; then exit $exit_status; fi