commit 9cab7a070d6f4f84da7b1dd71df52bddbfca1c38
Author: Mark Wielaard <mjw@redhat.com>
Date:   Fri Apr 26 23:44:25 2013 +0200

    Enable automake parallel-tests for make check.
    
    The parallel-tests option was introduced in automake 1.11 and is the
    default since automake 1.13. All tests can now be ran in parallel with
    make check -j. To enable this all tests are ran in their own temporary
    directory so they don't stomp on each others input or output files.
    On my machine (4 cores) make check takes ~20 seconds, but now with
    make check -j8 takes only ~4 seconds.
    
    ChangeLog:
    
           * configure.ac (AM_INIT_AUTOMAKE): Request parallel-tests.
    
    tests/ChangeLog:
    
           * Makefile.am (installed_TESTS_ENVIRONMENT): Export environment,
           remove wrapper.
           (TESTS_ENVIRONMENT): Likewise.
           (installed_LOG_COMPILER): New variable defining wrapper.
           (LOG_COMPILER): Likewise.
           * run-*.sh: Fixup location of input and output files.
           * test-subr.sh: Create test_dir, pushd to execute test in.
           (trap): Remove test_dir.
           (testfiles): Use abs_srcdir.
           (installed_testrun): Match on abs_builddir or abs_top_builddir.
           (self_test_files): Adjust path.
    
    Signed-off-by: Mark Wielaard <mjw@redhat.com>

diff --git a/ChangeLog b/ChangeLog
index 26b41c2..1fdcb58 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-04-26  Mark Wielaard  <mjw@redhat.com>
+
+	* configure.ac (AM_INIT_AUTOMAKE): Request parallel-tests.
+
 2013-04-25  Mark Wielaard  <mjw@redhat.com>
 
 	* .gitignore: Add config/test-driver as installed by automake 1.13.
diff --git a/configure.ac b/configure.ac
index fd30c27..d7c75ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,7 @@ AC_COPYRIGHT([Copyright (C) 1996-2012 Red Hat, Inc.])
 AC_PREREQ(2.63)			dnl Minimum Autoconf version required.
 
 dnl We use GNU make extensions; automake 1.10 defaults to -Wportability.
-AM_INIT_AUTOMAKE([gnits 1.11 -Wno-portability dist-bzip2 no-dist-gzip])
+AM_INIT_AUTOMAKE([gnits 1.11 -Wno-portability dist-bzip2 no-dist-gzip parallel-tests])
 AM_MAINTAINER_MODE
 
 dnl Unique ID for this build.
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 2a065ee..2cbe801 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,17 @@
+2013-04-26  Mark Wielaard  <mjw@redhat.com>
+
+	* Makefile.am (installed_TESTS_ENVIRONMENT): Export environment,
+	remove wrapper.
+	(TESTS_ENVIRONMENT): Likewise.
+	(installed_LOG_COMPILER): New variable defining wrapper.
+	(LOG_COMPILER): Likewise.
+	* run-*.sh: Fixup location of input and output files.
+	* test-subr.sh: Create test_dir, pushd to execute test in.
+	(trap): Remove test_dir.
+	(testfiles): Use abs_srcdir.
+	(installed_testrun): Match on abs_builddir or abs_top_builddir.
+	(self_test_files): Adjust path.
+
 2013-04-24  Mark Wielaard  <mjw@redhat.com>
 
 	* Makefile.am: Use AM_CPPFLAGS instead of INCLUDES.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e10da8a..4b57703 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -201,26 +201,41 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
 	     testfile-dwfl-report-elf-align-shlib.so.bz2
 
 if USE_VALGRIND
-valgrind_cmd="valgrind -q --trace-children=yes --error-exitcode=1 --run-libc-freeres=no"
+valgrind_cmd='valgrind -q --trace-children=yes --error-exitcode=1 --run-libc-freeres=no'
 endif
 
-installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir) \
-			      bindir=$(DESTDIR)$(bindir) \
-			      LC_ALL=C LANG=C \
-			      VALGRIND_CMD=$(valgrind_cmd) \
-			      $(srcdir)/test-wrapper.sh \
-			      installed $(tests_rpath) \
-			      $(program_transform_name)
+
+installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir); \
+			      bindir=$(DESTDIR)$(bindir); \
+			      LC_ALL=C; LANG=C; \
+			      VALGRIND_CMD=$(valgrind_cmd); \
+			      abs_srcdir=$(abs_srcdir); \
+			      abs_builddir=$(abs_builddir); \
+			      abs_top_builddir=$(abs_top_builddir); \
+			      export abs_srcdir; export abs_builddir; \
+			      export abs_top_builddir; \
+			      export libdir; export bindir; \
+			      export LC_ALL; export LANG; export VALGRIND_CMD;
+installed_LOG_COMPILER = $(abs_srcdir)/test-wrapper.sh \
+			 installed $(tests_rpath) \
+			 '$(program_transform_name)'
 if STANDALONE
 TESTS_ENVIRONMENT = $(installed_TESTS_ENVIRONMENT)
+LOG_COMPILER = $(installed_LOG_COMPILER)
 else !STANDALONE
-TESTS_ENVIRONMENT = LC_ALL=C LANG=C VALGRIND_CMD=$(valgrind_cmd) \
-		    $(srcdir)/test-wrapper.sh \
-		    ../libdw:../backends:../libelf:../libasm
+TESTS_ENVIRONMENT = LC_ALL=C; LANG=C; VALGRIND_CMD=$(valgrind_cmd); \
+		    abs_srcdir=$(abs_srcdir);  abs_builddir=$(abs_builddir); \
+		    abs_top_builddir=$(abs_top_builddir); \
+		    export abs_srcdir; export abs_builddir; \
+		    export abs_top_builddir; \
+		    export LC_ALL; export LANG; export VALGRIND_CMD;
+LOG_COMPILER = $(abs_srcdir)/test-wrapper.sh \
+	       $(abs_top_builddir)/libdw:$(abs_top_builddir)/backends:$(abs_top_builddir)/libelf:$(abs_top_builddir)/libasm
 
 installcheck-local:
 	$(MAKE) $(AM_MAKEFLAGS) \
-		TESTS_ENVIRONMENT='$(installed_TESTS_ENVIRONMENT)' check-TESTS
+		TESTS_ENVIRONMENT="$(installed_TESTS_ENVIRONMENT)" \
+		LOG_COMPILER="$(installed_LOG_COMPILER)" check-TESTS
 endif !STANDALONE
 
 if MUDFLAP
diff --git a/tests/run-addrname-test.sh b/tests/run-addrname-test.sh
index 99abf9d..9351fb2 100755
--- a/tests/run-addrname-test.sh
+++ b/tests/run-addrname-test.sh
@@ -19,7 +19,7 @@
 
 testfiles testfile34 testfile38 testfile41 testfile49
 
-testrun_compare ../src/addr2line -f -e testfile34 \
+testrun_compare ${abs_top_builddir}/src/addr2line -f -e testfile34 \
 				 0x08048074 0x08048075 0x08048076 \
 				 0x08049078 0x08048080 0x08049080 <<\EOF
 foo
@@ -36,7 +36,7 @@ _end
 ??:0
 EOF
 
-testrun_compare ../src/addr2line -S -e testfile38 0x02 0x10a 0x211 0x31a <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile38 0x02 0x10a 0x211 0x31a <<\EOF
 t1_global_outer+0x2
 ??:0
 t2_global_symbol+0x2
@@ -47,7 +47,7 @@ t3_global_after_0+0x1
 ??:0
 EOF
 
-testrun_compare ../src/addr2line -S -e testfile41 0x1 0x104 <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile41 0x1 0x104 <<\EOF
 small_global_at_large_global+0x1
 ??:0
 small_global_first_at_large_global+0x1
@@ -69,7 +69,7 @@ cat > testmaps <<EOF
 ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
 EOF
 
-testrun_compare ../src/addr2line -S -M testmaps 0x40047c 0x10009db <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S -M testmaps 0x40047c 0x10009db <<\EOF
 caller+0x14
 /home/drepper/local/elfutils-build/20050425/v.c:11
 foo+0xb
@@ -135,7 +135,7 @@ EOF
 #	nop #10
 #	.size local_outer, . - local_outer
 #	nop #11
-testrun_compare ../src/addr2line -S -e testfile49 \
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile49 \
     		0 1 2 3 4 5 6 7 8 9 \
 		0x100 0x101 0x102 0x103 0x104 0x105 \
 		0x106 0x107 0x108 0x109 0x10a 0x10b \
@@ -277,7 +277,7 @@ EOF
 #	local l0local2, 0
 #	offset 12
 testfiles testfile64
-testrun_compare ../src/addr2line -S -e testfile64 1 4 5 8 9 12 <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile64 1 4 5 8 9 12 <<\EOF
 gglobal2
 ??:0
 g0global2
@@ -293,13 +293,13 @@ l0local2
 EOF
 
 testfiles testfile65
-testrun_compare ../src/addr2line -S --core=testfile65 0x7fff94bffa30 <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S --core=testfile65 0x7fff94bffa30 <<\EOF
 __vdso_time
 ??:0
 EOF
 
 testfiles testfile69.core testfile69.so
-testrun_compare ../src/addr2line --core=./testfile69.core -S 0x7f0bc6a33535 0x7f0bc6a33546 <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line --core=./testfile69.core -S 0x7f0bc6a33535 0x7f0bc6a33546 <<\EOF
 libstatic+0x9
 ??:0
 libglobal+0x9
@@ -307,11 +307,11 @@ libglobal+0x9
 EOF
 
 testfiles testfile70.exec testfile70.core
-testrun_compare ../src/addr2line -S -e testfile70.exec --core=testfile70.core 0x7ff2cfe9b6b5 <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile70.exec --core=testfile70.core 0x7ff2cfe9b6b5 <<\EOF
 main+0x9
 ??:0
 EOF
-testrun_compare ../src/addr2line -S --core=testfile70.core -e testfile70.exec 0x7ff2cfe9b6b5 <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S --core=testfile70.core -e testfile70.exec 0x7ff2cfe9b6b5 <<\EOF
 main+0x9
 ??:0
 EOF
diff --git a/tests/run-addrscopes.sh b/tests/run-addrscopes.sh
index 38b9d88..4f5c9d7 100755
--- a/tests/run-addrscopes.sh
+++ b/tests/run-addrscopes.sh
@@ -19,7 +19,7 @@
 
 testfiles testfile22
 
-testrun_compare ./addrscopes -e testfile22 0x8048353 <<\EOF
+testrun_compare ${abs_builddir}/addrscopes -e testfile22 0x8048353 <<\EOF
 0x8048353:
     tests/foo.c (0x11): 0x8048348 (tests/foo.c:5) .. 0x804837e (tests/foo.c:16)
         global                        [    be]
@@ -30,7 +30,7 @@ EOF
 test_cleanup
 
 testfiles testfile24
-testrun_compare ./addrscopes -e testfile24 0x804834e <<\EOF
+testrun_compare ${abs_builddir}/addrscopes -e testfile24 0x804834e <<\EOF
 0x804834e:
     inline-test.c (0x11): 0x8048348 (/home/roland/build/stock-elfutils/inline-test.c:7) .. 0x8048364 (/home/roland/build/stock-elfutils/inline-test.c:16)
         add (0x1d): 0x804834e (/home/roland/build/stock-elfutils/inline-test.c:3) .. 0x8048350 (/home/roland/build/stock-elfutils/inline-test.c:9)
diff --git a/tests/run-alldts.sh b/tests/run-alldts.sh
index d8b87c2..a405fd5 100755
--- a/tests/run-alldts.sh
+++ b/tests/run-alldts.sh
@@ -18,9 +18,9 @@
 . $srcdir/test-subr.sh
 
 # This will produce "testfile-alldts" file
-testrun ./alldts
+testrun ${abs_builddir}/alldts
 
-testrun_compare ../src/readelf -d testfile-alldts <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf -d testfile-alldts <<\EOF
 
 Dynamic segment contains 66 entries:
  Addr: 0x000001a0  Offset: 0x000078  Link to section: [ 0] ''
diff --git a/tests/run-allfcts.sh b/tests/run-allfcts.sh
index 4d0ec61..30f7dd4 100755
--- a/tests/run-allfcts.sh
+++ b/tests/run-allfcts.sh
@@ -20,7 +20,7 @@
 
 testfiles testfile testfile2 testfile8
 
-testrun_compare ./allfcts testfile testfile2 testfile8 <<\EOF
+testrun_compare ${abs_builddir}/allfcts testfile testfile2 testfile8 <<\EOF
 /home/drepper/gnu/new-bu/build/ttt/m.c:5:main
 /home/drepper/gnu/new-bu/build/ttt/b.c:4:bar
 /home/drepper/gnu/new-bu/build/ttt/f.c:3:foo
diff --git a/tests/run-allregs.sh b/tests/run-allregs.sh
index 7790fd0..885a1d1 100755
--- a/tests/run-allregs.sh
+++ b/tests/run-allregs.sh
@@ -22,7 +22,7 @@ regs_test()
   tempfiles good.regs
   cat > good.regs
   testfiles "$@"
-  for f; do testrun_compare ./allregs -e $f < good.regs; done
+  for f; do testrun_compare ${abs_builddir}/allregs -e $f < good.regs; done
   test_cleanup
 }
 
diff --git a/tests/run-arextract.sh b/tests/run-arextract.sh
index 668b363..44f4a52 100755
--- a/tests/run-arextract.sh
+++ b/tests/run-arextract.sh
@@ -20,14 +20,14 @@
 
 tempfiles arextract.test
 
-archive=../libelf/libelf.a
+archive=${abs_top_builddir}/libelf/libelf.a
 if test -f $archive; then
     # The file is really available (i.e., no shared-only built).
     echo -n "Extracting symbols... $ac_c"
 
     # The files we are looking at.
-    for f in ../libelf/*.o; do
-	testrun ./arextract $archive `basename $f` arextract.test || exit 1
+    for f in ${abs_top_builddir}/libelf/*.o; do
+	testrun ${abs_builddir}/arextract $archive `basename $f` arextract.test || exit 1
 	cmp $f arextract.test || {
 	    echo "Extraction of $1 failed"
 	    exit 1
diff --git a/tests/run-arsymtest.sh b/tests/run-arsymtest.sh
index 89c7821..dc016e1 100755
--- a/tests/run-arsymtest.sh
+++ b/tests/run-arsymtest.sh
@@ -18,7 +18,7 @@
 
 . $srcdir/test-subr.sh
 
-lib=../libelf/libelf.a
+lib=${abs_top_builddir}/libelf/libelf.a
 okfile=arsymtest.ok
 tmpfile=arsymtest.tmp
 testfile=arsymtest.test
@@ -33,7 +33,7 @@ if test -f $lib; then
     sort > $okfile
 
     # Now run our program using libelf.
-    testrun ./arsymtest $lib $tmpfile || exit 1
+    testrun ${abs_builddir}/arsymtest $lib $tmpfile || exit 1
     sort $tmpfile > $testfile
 
     # Compare the outputs.
diff --git a/tests/run-bug1-test.sh b/tests/run-bug1-test.sh
index f651051..1e78a18 100755
--- a/tests/run-bug1-test.sh
+++ b/tests/run-bug1-test.sh
@@ -19,7 +19,7 @@
 
 testfiles testfile28 testfile28.rdwr
 
-testrun ./rdwrmmap testfile28
+testrun ${abs_builddir}/rdwrmmap testfile28
 
 cmp testfile28 testfile28.rdwr
 
@@ -27,7 +27,7 @@ test_cleanup
 
 testfiles testfile29 testfile29.rdwr
 
-testrun ./rdwrmmap testfile29
+testrun ${abs_builddir}/rdwrmmap testfile29
 
 cmp testfile29 testfile29.rdwr
 
diff --git a/tests/run-disasm-x86-64.sh b/tests/run-disasm-x86-64.sh
index 96e14d9..a6be62b 100755
--- a/tests/run-disasm-x86-64.sh
+++ b/tests/run-disasm-x86-64.sh
@@ -23,6 +23,6 @@ case "`uname -m`" in
     tempfiles testfile45.o
     testfiles testfile45.S testfile45.expect
     gcc -m64 -c -o testfile45.o testfile45.S
-    testrun_compare ../src/objdump -d testfile45.o < testfile45.expect
+    testrun_compare ${abs_top_builddir}/src/objdump -d testfile45.o < testfile45.expect
     ;;
 esac
diff --git a/tests/run-disasm-x86.sh b/tests/run-disasm-x86.sh
index 399664c..28a3df7 100755
--- a/tests/run-disasm-x86.sh
+++ b/tests/run-disasm-x86.sh
@@ -23,6 +23,6 @@ case "`uname -m`" in
     tempfiles testfile44.o
     testfiles testfile44.S testfile44.expect
     gcc -m32 -c -o testfile44.o testfile44.S
-    testrun_compare ../src/objdump -d testfile44.o < testfile44.expect
+    testrun_compare ${abs_top_builddir}/src/objdump -d testfile44.o < testfile44.expect
     ;;
 esac
diff --git a/tests/run-dwarf-getmacros.sh b/tests/run-dwarf-getmacros.sh
index b748b0f..ddb58e8 100755
--- a/tests/run-dwarf-getmacros.sh
+++ b/tests/run-dwarf-getmacros.sh
@@ -19,7 +19,7 @@
 
 testfiles testfile51
 
-testrun_compare ./dwarf-getmacros testfile51 0xb <<\EOF
+testrun_compare ${abs_builddir}/dwarf-getmacros testfile51 0xb <<\EOF
 __STDC__ 1
 __STDC_HOSTED__ 1
 __GNUC__ 4
@@ -152,7 +152,7 @@ __DECIMAL_BID_FORMAT__ 1
 macro1 ble
 EOF
 
-testrun_compare ./dwarf-getmacros testfile51 0x84 <<\EOF
+testrun_compare ${abs_builddir}/dwarf-getmacros testfile51 0x84 <<\EOF
 __STDC__ 1
 __STDC_HOSTED__ 1
 __GNUC__ 4
diff --git a/tests/run-dwarf-getstring.sh b/tests/run-dwarf-getstring.sh
index c765f75..f18f628 100755
--- a/tests/run-dwarf-getstring.sh
+++ b/tests/run-dwarf-getstring.sh
@@ -19,7 +19,7 @@
 
 testfiles testfile11
 
-testrun_compare ./dwarf-getstring testfile11 <<\EOF
+testrun_compare ${abs_builddir}/dwarf-getstring testfile11 <<\EOF
 _ZNSbIwSt11char_traitsIwESaIwEE13_S_copy_charsEPwS3_S3_
 itimerspec
 _G_int32_t
diff --git a/tests/run-dwfl-addr-sect.sh b/tests/run-dwfl-addr-sect.sh
index 85424fd..80da008 100755
--- a/tests/run-dwfl-addr-sect.sh
+++ b/tests/run-dwfl-addr-sect.sh
@@ -19,13 +19,13 @@
 
 testfiles testfile43 testfile50
 
-testrun_compare ./dwfl-addr-sect -e testfile43 0x64 0x8 0x98 <<\EOF
+testrun_compare ${abs_builddir}/dwfl-addr-sect -e testfile43 0x64 0x8 0x98 <<\EOF
 address 0x64 => module "" section 4 + 0
 address 0x8 => module "" section 1 + 0x8
 address 0x98 => module "" section 7 + 0
 EOF
 
-testrun_compare ./dwfl-addr-sect -e testfile50 0x1 <<\EOF
+testrun_compare ${abs_builddir}/dwfl-addr-sect -e testfile50 0x1 <<\EOF
 address 0x1 => module "" section 1 + 0x1
 EOF
 
diff --git a/tests/run-dwfl-bug-offline-rel.sh b/tests/run-dwfl-bug-offline-rel.sh
index 3e19a58..fa476c4 100755
--- a/tests/run-dwfl-bug-offline-rel.sh
+++ b/tests/run-dwfl-bug-offline-rel.sh
@@ -19,7 +19,7 @@
 
 testfiles testfile36 testfile36.debug
 
-testrun_compare ./dwflmodtest -e testfile36 <<\EOF
+testrun_compare ${abs_builddir}/dwflmodtest -e testfile36 <<\EOF
 module:                                00000000..00002308 testfile36 (null)
 module:                                00000000 DWARF 0 (no error)
 module:                                00000000..00002308 testfile36 testfile36.debug
diff --git a/tests/run-dwfl-report-elf-align.sh b/tests/run-dwfl-report-elf-align.sh
index d032aba..3849753 100755
--- a/tests/run-dwfl-report-elf-align.sh
+++ b/tests/run-dwfl-report-elf-align.sh
@@ -38,7 +38,7 @@ testfiles testfile-dwfl-report-elf-align-shlib.so
 # 0x7f3560c92585 = 0x7f3560c92000 + 0x585
 # where 0x585 is any address inside the shlib function: 0x57c .. 0x57c + 11 -1
 
-testrun ./dwfl-report-elf-align ./testfile-dwfl-report-elf-align-shlib.so \
+testrun ${abs_builddir}/dwfl-report-elf-align ./testfile-dwfl-report-elf-align-shlib.so \
 				0x7f3560c92000 0x7f3560c92585 shlib
 
 exit 0
diff --git a/tests/run-dwfllines.sh b/tests/run-dwfllines.sh
index df7d16f..b384de0 100755
--- a/tests/run-dwfllines.sh
+++ b/tests/run-dwfllines.sh
@@ -19,7 +19,7 @@
 
 testfiles testfile testfile2
 
-testrun_compare ./dwfllines -e testfile <<\EOF
+testrun_compare ${abs_builddir}/dwfllines -e testfile <<\EOF
 mod:  CU: [b] m.c
 0 0x804842c /home/drepper/gnu/new-bu/build/ttt/m.c:5:0
  time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
@@ -51,7 +51,7 @@ mod:  CU: [15fc] f.c
  time: 0, len: 0, idx: 0, b: 1, e: 1, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
 EOF
 
-testrun_compare ./dwfllines -e testfile2 <<\EOF
+testrun_compare ${abs_builddir}/dwfllines -e testfile2 <<\EOF
 mod:  CU: [b] b.c
 0 0x10000470 /shoggoth/drepper/b.c:4:0
  time: 0, len: 0, idx: 0, b: 1, e: 0, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
@@ -83,6 +83,6 @@ mod:  CU: [9e4] m.c
  time: 0, len: 0, idx: 0, b: 1, e: 1, pe: 0, eb: 0, block: 0, isa: 0, disc: 0
 EOF
 
-testrun_on_self_quiet ./dwfllines -e
+testrun_on_self_quiet ${abs_builddir}/dwfllines -e
 
 exit 0
diff --git a/tests/run-dwflsyms.sh b/tests/run-dwflsyms.sh
index 56a7580..c440bf7 100755
--- a/tests/run-dwflsyms.sh
+++ b/tests/run-dwflsyms.sh
@@ -177,21 +177,21 @@ cat > testfile.minsym.in <<\EOF
 EOF
 
 cat testfile.symtab.in \
-  | testrun_compare ./dwflsyms -e testfilebaztab
+  | testrun_compare ${abs_builddir}/dwflsyms -e testfilebaztab
 
 cat testfile.symtab.in \
-  | testrun_compare ./dwflsyms -e testfilebazdbg
+  | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazdbg
 
 cat testfile.dynsym.in \
-  | testrun_compare ./dwflsyms -e testfilebazdyn
+  | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazdyn
 
 cat testfile.symtab.in \
-  | testrun_compare ./dwflsyms -e testfilebazmdb
+  | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazmdb
 
 cat testfile.minsym.in \
-  | testrun_compare ./dwflsyms -e testfilebazmin
+  | testrun_compare ${abs_builddir}/dwflsyms -e testfilebazmin
 
-testrun_compare ./dwflsyms -e testfilebasmin <<\EOF
+testrun_compare ${abs_builddir}/dwflsyms -e testfilebasmin <<\EOF
    0: NOTYPE	LOCAL	 (0) 0
    1: FUNC	LOCAL	foo (18) 0x400168
    2: SECTION	LOCAL	 (0) 0x400120
diff --git a/tests/run-early-offscn.sh b/tests/run-early-offscn.sh
index 55a38f9..3757bcf 100755
--- a/tests/run-early-offscn.sh
+++ b/tests/run-early-offscn.sh
@@ -19,6 +19,6 @@
 
 testfiles testfile
 
-testrun ./early-offscn testfile 0x500
+testrun ${abs_builddir}/early-offscn testfile 0x500
 
 exit 0
diff --git a/tests/run-ecp-test.sh b/tests/run-ecp-test.sh
index d68a873..d5e376a 100755
--- a/tests/run-ecp-test.sh
+++ b/tests/run-ecp-test.sh
@@ -21,7 +21,7 @@
 testfiles testfile10
 tempfiles testfile10.tmp
 
-testrun ./ecp testfile10 testfile10.tmp
+testrun ${abs_builddir}/ecp testfile10 testfile10.tmp
 
 cmp testfile10 testfile10.tmp
 
diff --git a/tests/run-ecp-test2.sh b/tests/run-ecp-test2.sh
index a9acbe9..864e0a5 100755
--- a/tests/run-ecp-test2.sh
+++ b/tests/run-ecp-test2.sh
@@ -21,6 +21,6 @@
 testfiles testfile2
 tempfiles testfile2.tmp
 
-testrun ./ecp testfile2 testfile2.tmp
+testrun ${abs_builddir}/ecp testfile2 testfile2.tmp
 
 exit 0
diff --git a/tests/run-elf_cntl_gelf_getshdr.sh b/tests/run-elf_cntl_gelf_getshdr.sh
index 41a7d15..d134119 100755
--- a/tests/run-elf_cntl_gelf_getshdr.sh
+++ b/tests/run-elf_cntl_gelf_getshdr.sh
@@ -18,13 +18,13 @@
 . $srcdir/test-subr.sh
 
 # However we open the elf file, the shdrs should be the same.
-testrun ./test-elf_cntl_gelf_getshdr READ test-elf_cntl_gelf_getshdr \
+testrun ${abs_builddir}/test-elf_cntl_gelf_getshdr READ ${abs_builddir}/test-elf_cntl_gelf_getshdr \
   > test_shdr.out
 
-testrun_compare ./test-elf_cntl_gelf_getshdr MMAP test-elf_cntl_gelf_getshdr \
+testrun_compare ${abs_builddir}/test-elf_cntl_gelf_getshdr MMAP ${abs_builddir}/test-elf_cntl_gelf_getshdr \
   < test_shdr.out
 
-testrun_compare ./test-elf_cntl_gelf_getshdr FDREAD test-elf_cntl_gelf_getshdr \
+testrun_compare ${abs_builddir}/test-elf_cntl_gelf_getshdr FDREAD ${abs_builddir}/test-elf_cntl_gelf_getshdr \
   < test_shdr.out
 
 rm -f test_shdr.out
diff --git a/tests/run-elflint-self.sh b/tests/run-elflint-self.sh
index 4b01008..013109d 100755
--- a/tests/run-elflint-self.sh
+++ b/tests/run-elflint-self.sh
@@ -18,4 +18,4 @@
 
 . $srcdir/test-subr.sh
 
-testrun_on_self ../src/elflint --quiet --gnu-ld
+testrun_on_self ${abs_top_builddir}/src/elflint --quiet --gnu-ld
diff --git a/tests/run-elflint-test.sh b/tests/run-elflint-test.sh
index 5a5c622..68615b9 100755
--- a/tests/run-elflint-test.sh
+++ b/tests/run-elflint-test.sh
@@ -20,24 +20,24 @@
 
 testfiles testfile18
 
-testrun_compare ../src/elflint --gnu-ld testfile18 <<\EOF
+testrun_compare ${abs_top_builddir}/src/elflint --gnu-ld testfile18 <<\EOF
 section [ 8] '.rela.dyn': relocation 1: copy relocation against symbol of type FUNC
 EOF
 
 testfiles testfile32
-testrun ../src/elflint -q testfile32
+testrun ${abs_top_builddir}/src/elflint -q testfile32
 
 testfiles testfile33
-testrun ../src/elflint -q testfile33
+testrun ${abs_top_builddir}/src/elflint -q testfile33
 
 testfiles testfile42
-testrun ../src/elflint -q --gnu-ld testfile42
+testrun ${abs_top_builddir}/src/elflint -q --gnu-ld testfile42
 
 testfiles testfile46
-testrun ../src/elflint -q testfile46
+testrun ${abs_top_builddir}/src/elflint -q testfile46
 
 # see also run-readelf-d.sh
 testfiles testlib_dynseg.so
-testrun ../src/elflint -q --gnu-ld testlib_dynseg.so
+testrun ${abs_top_builddir}/src/elflint -q --gnu-ld testlib_dynseg.so
 
 exit 0
diff --git a/tests/run-find-prologues.sh b/tests/run-find-prologues.sh
index 78caa8c..160f07d 100755
--- a/tests/run-find-prologues.sh
+++ b/tests/run-find-prologues.sh
@@ -20,13 +20,13 @@
 testfiles testfile testfile11 testfile22 testfile24 \
 	  testfile25 testfile3 testfile4 testfile5 testfile6
 
-testrun_compare ./find-prologues -e testfile <<\EOF
+testrun_compare ${abs_builddir}/find-prologues -e testfile <<\EOF
 main             0x000000000804842c 0x0000000008048432
 bar              0x000000000804845c 0x000000000804845f
 foo              0x0000000008048468 0x000000000804846b
 EOF
 
-testrun_compare ./find-prologues -e testfile11 <<\EOF
+testrun_compare ${abs_builddir}/find-prologues -e testfile11 <<\EOF
 main             0x00000000080489b8 0x00000000080489cd
 gnu_obj_2        0x0000000008048c9e 0x0000000008048ca4
 gnu_obj_3        0x0000000008048cd8 0x0000000008048cde
@@ -37,27 +37,27 @@ gnu_obj_1        0x0000000008048d8a 0x0000000008048d8d
 ~invalid_argument 0x0000000008048db2 0x0000000008048db8
 EOF
 
-testrun_compare ./find-prologues -e testfile22 <<\EOF
+testrun_compare ${abs_builddir}/find-prologues -e testfile22 <<\EOF
 function         0x0000000008048348 0x000000000804834e
 main             0x000000000804835b 0x0000000008048377
 EOF
 
-testrun_compare ./find-prologues -e testfile24 <<\EOF
+testrun_compare ${abs_builddir}/find-prologues -e testfile24 <<\EOF
 incr             0x0000000008048348 0x000000000804834e
 main             0x0000000008048354 0x0000000008048360
 EOF
 
-testrun_compare ./find-prologues -e testfile25 <<\EOF
+testrun_compare ${abs_builddir}/find-prologues -e testfile25 <<\EOF
 incr             0x0000000008048348 0x000000000804834c
 EOF
 
-testrun_compare ./find-prologues -e testfile3 <<\EOF
+testrun_compare ${abs_builddir}/find-prologues -e testfile3 <<\EOF
 main             0x000000000804842c 0x0000000008048433
 bar              0x0000000008048458 0x000000000804845b
 foo              0x0000000008048464 0x0000000008048467
 EOF
 
-testrun_compare ./find-prologues -e testfile4 <<\EOF
+testrun_compare ${abs_builddir}/find-prologues -e testfile4 <<\EOF
 get              0x00000000080493fc 0x0000000008049402
 main             0x0000000008049498 0x000000000804949e
 a                0x000000000804d85c 0x000000000804d85c
@@ -65,13 +65,13 @@ __tfPCc          0x000000000804d86c 0x000000000804d872
 __tfCc           0x000000000804d8a4 0x000000000804d8a4
 EOF
 
-testrun_compare ./find-prologues -e testfile5 <<\EOF
+testrun_compare ${abs_builddir}/find-prologues -e testfile5 <<\EOF
 bar              0x000000000804842c 0x000000000804842f
 foo              0x0000000008048438 0x000000000804843b
 main             0x0000000008048444 0x000000000804844a
 EOF
 
-testrun_compare ./find-prologues -e testfile6 <<\EOF
+testrun_compare ${abs_builddir}/find-prologues -e testfile6 <<\EOF
 main             0x00000000080489b8 0x00000000080489cd
 gnu_obj_2        0x0000000008048c9e 0x0000000008048ca4
 gnu_obj_3        0x0000000008048cd8 0x0000000008048cde
diff --git a/tests/run-funcscopes.sh b/tests/run-funcscopes.sh
index a0e48c1..d236f5c 100755
--- a/tests/run-funcscopes.sh
+++ b/tests/run-funcscopes.sh
@@ -19,7 +19,7 @@
 
 testfiles testfile25
 
-testrun_compare ./funcscopes -e testfile25 incr <<\EOF
+testrun_compare ${abs_builddir}/funcscopes -e testfile25 incr <<\EOF
 testfile25: 0x8048000 .. 0x8049528
     inline-test.c (0x11): 0x8048348 (/home/roland/build/stock-elfutils/inline-test.c:7) .. 0x804834f (/home/roland/build/stock-elfutils/inline-test.c:9)
         incr (0x2e): 0x8048348 (/home/roland/build/stock-elfutils/inline-test.c:7) .. 0x804834f (/home/roland/build/stock-elfutils/inline-test.c:9)
diff --git a/tests/run-get-aranges.sh b/tests/run-get-aranges.sh
index f3949f4..62cae5f 100755
--- a/tests/run-get-aranges.sh
+++ b/tests/run-get-aranges.sh
@@ -20,7 +20,7 @@
 
 testfiles testfile testfile2
 
-testrun_compare ./get-aranges testfile testfile2 <<\EOF
+testrun_compare ${abs_builddir}/get-aranges testfile testfile2 <<\EOF
 0x804842b: not in range
 CU name: "m.c"
 CU name: "m.c"
diff --git a/tests/run-get-files.sh b/tests/run-get-files.sh
index 6eadcd5..a2f2373 100755
--- a/tests/run-get-files.sh
+++ b/tests/run-get-files.sh
@@ -20,7 +20,7 @@
 
 testfiles testfile testfile2
 
-testrun_compare ./get-files testfile testfile2 <<\EOF
+testrun_compare ${abs_builddir}/get-files testfile testfile2 <<\EOF
 cuhl = 11, o = 0, asz = 4, osz = 4, ncu = 191
  dirs[0] = "/home/drepper/gnu/new-bu/build/ttt"
  file[0] = "???"
diff --git a/tests/run-get-lines.sh b/tests/run-get-lines.sh
index 8c8c71e..5a220ca 100755
--- a/tests/run-get-lines.sh
+++ b/tests/run-get-lines.sh
@@ -20,7 +20,7 @@
 
 testfiles testfile testfile2
 
-testrun_compare ./get-lines testfile testfile2 <<\EOF
+testrun_compare ${abs_builddir}/get-lines testfile testfile2 <<\EOF
 cuhl = 11, o = 0, asz = 4, osz = 4, ncu = 191
  5 lines
 804842c: /home/drepper/gnu/new-bu/build/ttt/m.c:5:0: is_stmt:yes, end_seq:no, bb:no, prologue:no, epilogue:no
diff --git a/tests/run-get-pubnames.sh b/tests/run-get-pubnames.sh
index a8a1759..912793e 100755
--- a/tests/run-get-pubnames.sh
+++ b/tests/run-get-pubnames.sh
@@ -20,7 +20,7 @@
 
 testfiles testfile testfile2
 
-testrun_compare ./get-pubnames testfile testfile2 <<\EOF
+testrun_compare ${abs_builddir}/get-pubnames testfile testfile2 <<\EOF
  [ 0] "main", die: 104, cu: 11
 CU name: "m.c"
 object name: "main"
diff --git a/tests/run-line2addr.sh b/tests/run-line2addr.sh
index 768cf69..3b6c445 100755
--- a/tests/run-line2addr.sh
+++ b/tests/run-line2addr.sh
@@ -20,28 +20,28 @@
 
 testfiles testfile testfile2 testfile8 testfile14 testfile23
 
-testrun_compare ./line2addr -e testfile f.c:4 testfile f.c:8 <<\EOF
+testrun_compare ${abs_builddir}/line2addr -e testfile f.c:4 testfile f.c:8 <<\EOF
 f.c:4 -> 0x804846b (/home/drepper/gnu/new-bu/build/ttt/f.c:4)
 EOF
 
-testrun_compare ./line2addr -e testfile2 m.c:6 b.c:1 <<\EOF
+testrun_compare ${abs_builddir}/line2addr -e testfile2 m.c:6 b.c:1 <<\EOF
 m.c:6 -> 0x100004cc (/shoggoth/drepper/m.c:6)
 b.c:1 -> 0x10000470 (/shoggoth/drepper/b.c:4)
 EOF
 
-testrun_compare ./line2addr -e testfile8 strip.c:953 strip.c:365 <<\EOF
+testrun_compare ${abs_builddir}/line2addr -e testfile8 strip.c:953 strip.c:365 <<\EOF
 strip.c:953 -> (.text)+0x169f (/home/drepper/gnu/elfutils/build/src/../../src/strip.c:953)
 strip.c:953 -> (.text)+0x16aa (/home/drepper/gnu/elfutils/build/src/../../src/strip.c:953)
 strip.c:365 -> (.text)+0x278b (/home/drepper/gnu/elfutils/build/src/../../src/strip.c:365)
 strip.c:365 -> (.text)+0x2797 (/home/drepper/gnu/elfutils/build/src/../../src/strip.c:365)
 EOF
 
-testrun_compare ./line2addr -e testfile14 v.c:6 <<\EOF
+testrun_compare ${abs_builddir}/line2addr -e testfile14 v.c:6 <<\EOF
 v.c:6 -> 0x400468 (/home/drepper/local/elfutils-build/20050425/v.c:6)
 v.c:6 -> 0x400487 (/home/drepper/local/elfutils-build/20050425/v.c:6)
 EOF
 
-testrun_compare ./line2addr -e testfile23 foo.c:2 foo.c:6 <<\EOF
+testrun_compare ${abs_builddir}/line2addr -e testfile23 foo.c:2 foo.c:6 <<\EOF
 foo.c:2 -> (.init.text)+0xc (/home/roland/stock-elfutils-build/foo.c:2)
 foo.c:6 -> (.text)+0xc (/home/roland/stock-elfutils-build/foo.c:6)
 EOF
diff --git a/tests/run-low_high_pc.sh b/tests/run-low_high_pc.sh
index eb6f8cf..ab5f2c3 100755
--- a/tests/run-low_high_pc.sh
+++ b/tests/run-low_high_pc.sh
@@ -25,10 +25,10 @@
 # gcc -g -o main main.c
 testfiles testfile_low_high_pc
 
-testrun ./low_high_pc -e ./testfile_low_high_pc
-testrun ./low_high_pc -e ./low_high_pc
-testrun ./low_high_pc -e ../src/strip
-testrun ./low_high_pc -e ../src/strip.o
-testrun ./low_high_pc -e ../libelf/libelf.so
+testrun ${abs_builddir}/low_high_pc -e ./testfile_low_high_pc
+testrun ${abs_builddir}/low_high_pc -e ${abs_builddir}/low_high_pc
+testrun ${abs_builddir}/low_high_pc -e ${abs_top_builddir}/src/strip
+testrun ${abs_builddir}/low_high_pc -e ${abs_top_builddir}/src/strip.o
+testrun ${abs_builddir}/low_high_pc -e ${abs_top_builddir}/libelf/libelf.so
 
 exit 0
diff --git a/tests/run-macro-test.sh b/tests/run-macro-test.sh
index 70a16ed..c160968 100755
--- a/tests/run-macro-test.sh
+++ b/tests/run-macro-test.sh
@@ -34,14 +34,14 @@ testfiles testfile-macinfo testfile-macros
 
 status=0
 
-testrun ../src/readelf --debug-dump=info testfile-macinfo \
+testrun ${abs_top_builddir}/src/readelf --debug-dump=info testfile-macinfo \
 	| grep macro_info > readelf.macros.out ||
   { echo "*** failure readelf --debug-dump=info testfile-macinfo"; status=1; }
 testrun_compare cat readelf.macros.out <<\EOF
            macro_info           (sec_offset) 0
 EOF
 
-testrun ../src/readelf --debug-dump=info testfile-macros \
+testrun ${abs_top_builddir}/src/readelf --debug-dump=info testfile-macros \
 	| grep GNU_macros > readelf.macros.out ||
   { echo "*** failure readelf --debug-dump=info testfile-macros"; status=1; }
 testrun_compare cat readelf.macros.out <<\EOF
diff --git a/tests/run-native-test.sh b/tests/run-native-test.sh
index ed7672f..b543922 100755
--- a/tests/run-native-test.sh
+++ b/tests/run-native-test.sh
@@ -70,8 +70,8 @@ native_test()
   test $native -eq 0 || testrun "$@" -p $native > /dev/null
 }
 
-native_test ./allregs
-native_test ./funcretval
+native_test ${abs_builddir}/allregs
+native_test ${abs_builddir}/funcretval
 
 # We do this explicitly rather than letting the trap 0 cover it,
 # because as of version 3.1 bash prints the "Killed" report for
diff --git a/tests/run-nm-self.sh b/tests/run-nm-self.sh
index 0fe0ec6..d2c1246 100755
--- a/tests/run-nm-self.sh
+++ b/tests/run-nm-self.sh
@@ -20,7 +20,7 @@
 for what_arg in --debug-syms --defined-only --dynamic --extern-only; do
   for format_arg in --format=bsd --format=sysv --format=posix; do
     for out_arg in --numeric-sort --no-sort --reverse-sort; do
-      testrun_on_self_quiet ../src/nm $what_arg $format_arg $out_arg
+      testrun_on_self_quiet ${abs_top_builddir}/src/nm $what_arg $format_arg $out_arg
     done
   done
 done
diff --git a/tests/run-prelink-addr-test.sh b/tests/run-prelink-addr-test.sh
index 588261f..3398c0d 100755
--- a/tests/run-prelink-addr-test.sh
+++ b/tests/run-prelink-addr-test.sh
@@ -47,7 +47,7 @@ EOF
 # Prior to commit 1743d7f, libdwfl would fail on the second address,
 # because it didn't notice that prelink added a 0x20-byte offset from
 # what the .debug file reports.
-testrun_compare ../src/addr2line -S -M testmaps52-32 \
+testrun_compare ${abs_top_builddir}/src/addr2line -S -M testmaps52-32 \
     0x11140c 0x4100042d 0x4200040e <<\EOF
 foo
 /home/jistone/src/elfutils/tests/testfile52-32.c:2
@@ -76,7 +76,7 @@ cat > testmaps52-64 <<EOF
 3800200000-3800201000 rw-p 00000000 fd:11 3 `pwd`/testfile52-64.noshdrs.so
 EOF
 
-testrun_compare ../src/addr2line -S -M testmaps52-64 \
+testrun_compare ${abs_top_builddir}/src/addr2line -S -M testmaps52-64 \
     0x100000056c 0x300000056d 0x380000056e <<\EOF
 foo
 /home/jistone/src/elfutils/tests/testfile52-64.c:2
@@ -97,7 +97,7 @@ EOF
 # prelink -N testfile53-32.prelink
 testfiles testfile53-32 testfile53-32.debug testfile53-32.prelink
 
-testrun_compare ../src/addr2line -S -e testfile53-32 0x8048394 0x8048395 <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile53-32 0x8048394 0x8048395 <<\EOF
 main
 /home/jistone/src/elfutils/tests/testfile53-32.c:2
 main+0x1
@@ -105,7 +105,7 @@ main+0x1
 EOF
 
 # prelink shuffled some of the sections, but .text is in the same place.
-testrun_compare ../src/addr2line -S -e testfile53-32.prelink 0x8048396 0x8048397 <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile53-32.prelink 0x8048396 0x8048397 <<\EOF
 main+0x2
 /home/jistone/src/elfutils/tests/testfile53-32.c:2
 main+0x3
@@ -116,14 +116,14 @@ EOF
 # prelink section shuffling.
 testfiles testfile53-64 testfile53-64.debug testfile53-64.prelink
 
-testrun_compare ../src/addr2line -S -e testfile53-64 0x400474 0x400475 <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile53-64 0x400474 0x400475 <<\EOF
 main
 /home/jistone/src/elfutils/tests/testfile53-64.c:2
 main+0x1
 /home/jistone/src/elfutils/tests/testfile53-64.c:2
 EOF
 
-testrun_compare ../src/addr2line -S -e testfile53-64.prelink 0x400476 0x400477 <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile53-64.prelink 0x400476 0x400477 <<\EOF
 main+0x2
 /home/jistone/src/elfutils/tests/testfile53-64.c:2
 main+0x3
@@ -159,7 +159,7 @@ cat > testmaps54-32 <<EOF
 42001000-42002000 rw-p 00000000 fd:01 3 `pwd`/testfile54-32.noshdrs.so
 EOF
 
-testrun_compare ../src/addr2line -S -M testmaps54-32 \
+testrun_compare ${abs_top_builddir}/src/addr2line -S -M testmaps54-32 \
     0x1111fc 0x1122a4 0x410001fd 0x410012a5 0x420001fe <<\EOF
 foo
 ??:0
@@ -193,7 +193,7 @@ cat > testmaps54-64 <<EOF
 3800200000-3800201000 rw-p 00000000 fd:11 3 `pwd`/testfile54-64.noshdrs.so
 EOF
 
-testrun_compare ../src/addr2line -S -M testmaps54-64 \
+testrun_compare ${abs_top_builddir}/src/addr2line -S -M testmaps54-64 \
     0x10000002f8 0x1000200448 0x30000002f9 0x3000200449 0x38000002fa <<\EOF
 foo
 ??:0
@@ -218,7 +218,7 @@ EOF
 # prelink -N testfile55-32.prelink
 testfiles testfile55-32 testfile55-32.debug testfile55-32.prelink
 
-testrun_compare ../src/addr2line -S -e testfile55-32 0x80483b4 0x80483b5 <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile55-32 0x80483b4 0x80483b5 <<\EOF
 main
 /home/jistone/src/elfutils/tests/testfile55-32.c:2
 main+0x1
@@ -227,7 +227,7 @@ EOF
 
 # prelink splits .bss into .dynbss+.bss, so the start of .bss changes, but the
 # total size remains the same, and .text doesn't move at all.
-testrun_compare ../src/addr2line -S -e testfile55-32.prelink 0x80483b6 0x80483b7 <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile55-32.prelink 0x80483b6 0x80483b7 <<\EOF
 main+0x2
 /home/jistone/src/elfutils/tests/testfile55-32.c:2
 main+0x3
@@ -237,14 +237,14 @@ EOF
 # Repeat testfile55 in 64-bit
 testfiles testfile55-64 testfile55-64.debug testfile55-64.prelink
 
-testrun_compare ../src/addr2line -S -e testfile55-64 0x4004b4 0x4004b5 <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile55-64 0x4004b4 0x4004b5 <<\EOF
 main
 /home/jistone/src/elfutils/tests/testfile55-64.c:2
 main+0x1
 /home/jistone/src/elfutils/tests/testfile55-64.c:2
 EOF
 
-testrun_compare ../src/addr2line -S -e testfile55-64.prelink 0x4004b6 0x4004b7 <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile55-64.prelink 0x4004b6 0x4004b7 <<\EOF
 main+0x2
 /home/jistone/src/elfutils/tests/testfile55-64.c:2
 main+0x3
diff --git a/tests/run-ranlib-test.sh b/tests/run-ranlib-test.sh
index ce109cf..0b34cbb 100755
--- a/tests/run-ranlib-test.sh
+++ b/tests/run-ranlib-test.sh
@@ -30,7 +30,7 @@ EOF
 
 cp ranlib-test.a ranlib-test.a-copy
 
-testrun ../src/ranlib ranlib-test.a
+testrun ${abs_top_builddir}/src/ranlib ranlib-test.a
 
 # The ranlib call should not have changed anything.
 cmp ranlib-test.a ranlib-test.a-copy
diff --git a/tests/run-ranlib-test2.sh b/tests/run-ranlib-test2.sh
index 75d00b3..dbc57ec 100755
--- a/tests/run-ranlib-test2.sh
+++ b/tests/run-ranlib-test2.sh
@@ -23,7 +23,7 @@ indexed=${indexed:-testfile19.index}
 
 testfiles $original $indexed
 
-testrun ../src/ranlib $original
+testrun ${abs_top_builddir}/src/ranlib $original
 
 if test -z "$noindex"; then
   # The date in the index is different.  The reference file has it blanked
diff --git a/tests/run-readelf-aranges.sh b/tests/run-readelf-aranges.sh
index a610fca..3fc3c54 100755
--- a/tests/run-readelf-aranges.sh
+++ b/tests/run-readelf-aranges.sh
@@ -111,7 +111,7 @@
 
 testfiles testfilefoobarbaz
 
-testrun_compare ../src/readelf --debug-dump=aranges testfilefoobarbaz <<EOF
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=aranges testfilefoobarbaz <<EOF
 
 DWARF section [27] '.debug_aranges' at offset 0x1044:
 
@@ -148,7 +148,7 @@ Table at offset 72:
    0x08048340 <nobaz>..0x0804834a <nobaz+0xa>
 EOF
 
-testrun_compare ../src/readelf --debug-dump=decodedaranges testfilefoobarbaz <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=decodedaranges testfilefoobarbaz <<\EOF
 
 DWARF section [27] '.debug_aranges' at offset 0x1044 contains 5 entries:
  [0] start: 0x080482f0, length:    52, CU DIE offset:     11
diff --git a/tests/run-readelf-d.sh b/tests/run-readelf-d.sh
index 3e4b7bf..d0b6ed2 100755
--- a/tests/run-readelf-d.sh
+++ b/tests/run-readelf-d.sh
@@ -32,7 +32,7 @@
 
 testfiles testlib_dynseg.so
 
-testrun_compare ../src/readelf -d testlib_dynseg.so <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf -d testlib_dynseg.so <<\EOF
 
 Dynamic segment contains 28 entries:
  Addr: 0x00000000000017e0  Offset: 0x0007e0  Link to section: [ 3] '.dynstr'
diff --git a/tests/run-readelf-dwz-multi.sh b/tests/run-readelf-dwz-multi.sh
index ca939f3..44d2475 100755
--- a/tests/run-readelf-dwz-multi.sh
+++ b/tests/run-readelf-dwz-multi.sh
@@ -78,7 +78,7 @@
 testfiles libtestfile_multi_shared.so testfile_multi_main testfile_multi.dwz
 testfiles testfile-dwzstr testfile-dwzstr.multi
 
-testrun_compare ../src/readelf --debug-dump=info testfile_multi_main <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=info testfile_multi_main <<\EOF
 
 DWARF section [28] '.debug_info' at offset 0x1078:
  [Offset]
@@ -136,7 +136,7 @@ DWARF section [28] '.debug_info' at offset 0x1078:
              type                 (ref_udata) [    2b]
 EOF
 
-testrun_compare ../src/readelf --debug-dump=info libtestfile_multi_shared.so <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=info libtestfile_multi_shared.so <<\EOF
 
 DWARF section [25] '.debug_info' at offset 0x106c:
  [Offset]
@@ -173,7 +173,7 @@ DWARF section [25] '.debug_info' at offset 0x106c:
                 [   0] fbreg -24
 EOF
 
-testrun_compare ../src/readelf --debug-dump=info testfile-dwzstr <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=info testfile-dwzstr <<\EOF
 
 DWARF section [28] '.debug_info' at offset 0x1088:
  [Offset]
diff --git a/tests/run-readelf-gdb_index.sh b/tests/run-readelf-gdb_index.sh
index 31c94c1..fcbc3c5 100755
--- a/tests/run-readelf-gdb_index.sh
+++ b/tests/run-readelf-gdb_index.sh
@@ -65,7 +65,7 @@
 
 testfiles testfilegdbindex5 testfilegdbindex7
 
-testrun_compare ../src/readelf --debug-dump=gdb_index testfilegdbindex5 <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=gdb_index testfilegdbindex5 <<\EOF
 
 GDB section [33] '.gdb_index' at offset 0xe76 contains 8383 bytes :
  Version:         5
@@ -96,7 +96,7 @@ GDB section [33] '.gdb_index' at offset 0xe76 contains 8383 bytes :
  [ 754] symbol: int, CUs: 0
 EOF
 
-testrun_compare ../src/readelf --debug-dump=gdb_index testfilegdbindex7 <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=gdb_index testfilegdbindex7 <<\EOF
 
 GDB section [33] '.gdb_index' at offset 0xe76 contains 8399 bytes :
  Version:         7
diff --git a/tests/run-readelf-line.sh b/tests/run-readelf-line.sh
index f0e491d..32bcf9d 100755
--- a/tests/run-readelf-line.sh
+++ b/tests/run-readelf-line.sh
@@ -22,7 +22,7 @@
 
 testfiles testfilefoobarbaz
 
-testrun_compare ../src/readelf --debug-dump=line testfilefoobarbaz <<EOF
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=line testfilefoobarbaz <<EOF
 
 DWARF section [30] '.debug_line' at offset 0x15f6:
 
@@ -197,7 +197,7 @@ Line number statements:
  [   10e] extended opcode 1:  end of sequence
 EOF
 
-testrun_compare ../src/readelf --debug-dump=decodedline testfilefoobarbaz <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=decodedline testfilefoobarbaz <<\EOF
 
 DWARF section [30] '.debug_line' at offset 0x15f6:
 
diff --git a/tests/run-readelf-loc.sh b/tests/run-readelf-loc.sh
index 6612e7d..98870fc 100755
--- a/tests/run-readelf-loc.sh
+++ b/tests/run-readelf-loc.sh
@@ -59,7 +59,7 @@
 testfiles testfileloc
 
 # Process values as offsets from base addresses and resolve to symbols.
-testrun_compare ../src/readelf --debug-dump=loc --debug-dump=ranges \
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=loc --debug-dump=ranges \
   testfileloc<<\EOF
 
 DWARF section [33] '.debug_loc' at offset 0xd2a:
@@ -75,7 +75,7 @@ DWARF section [34] '.debug_ranges' at offset 0xd94:
 EOF
 
 # Don't resolve addresses to symbols.
-testrun_compare ../src/readelf -N --debug-dump=loc --debug-dump=ranges \
+testrun_compare ${abs_top_builddir}/src/readelf -N --debug-dump=loc --debug-dump=ranges \
   testfileloc<<\EOF
 
 DWARF section [33] '.debug_loc' at offset 0xd2a:
@@ -91,7 +91,7 @@ DWARF section [34] '.debug_ranges' at offset 0xd94:
 EOF
 
 # Produce "raw" unprocessed content.
-testrun_compare ../src/readelf -U --debug-dump=loc --debug-dump=ranges \
+testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=loc --debug-dump=ranges \
   testfileloc<<\EOF
 
 DWARF section [33] '.debug_loc' at offset 0xd2a:
diff --git a/tests/run-readelf-macro.sh b/tests/run-readelf-macro.sh
index c65992b..8693203 100755
--- a/tests/run-readelf-macro.sh
+++ b/tests/run-readelf-macro.sh
@@ -59,7 +59,7 @@
 
 testfiles testfilemacro
 
-testrun_compare ../src/readelf --debug-dump=macro testfilemacro <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=macro testfilemacro <<\EOF
 
 DWARF section [32] '.debug_macro' at offset 0x2480:
 
diff --git a/tests/run-readelf-mixed-corenote.sh b/tests/run-readelf-mixed-corenote.sh
index 3c4ec51..915bdeb 100755
--- a/tests/run-readelf-mixed-corenote.sh
+++ b/tests/run-readelf-mixed-corenote.sh
@@ -19,7 +19,7 @@
 
 testfiles testfile63
 
-testrun_compare ../src/readelf -n testfile63 <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile63 <<\EOF
 
 Note segment of 892 bytes at offset 0x274:
   Owner          Data size  Type
@@ -85,7 +85,7 @@ Note segment of 892 bytes at offset 0x274:
 EOF
 
 testfiles testfile67
-testrun_compare ../src/readelf -n testfile67 <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile67 <<\EOF
 
 Note segment of 1044 bytes at offset 0xe8:
   Owner          Data size  Type
@@ -150,7 +150,7 @@ Note segment of 1044 bytes at offset 0xe8:
 EOF
 
 testfiles testfile68
-testrun_compare ../src/readelf -n testfile68 <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile68 <<\EOF
 
 Note segment of 852 bytes at offset 0x94:
   Owner          Data size  Type
diff --git a/tests/run-readelf-s.sh b/tests/run-readelf-s.sh
index bad31cf..4373b5f 100755
--- a/tests/run-readelf-s.sh
+++ b/tests/run-readelf-s.sh
@@ -251,33 +251,33 @@ Symbol table [27] '.symtab' contains 35 entries:
 EOF
 
 cat testfile.dynsym.in testfile.symtab.in \
-  | testrun_compare ../src/readelf -s testfilebaztab
+  | testrun_compare ${abs_top_builddir}/src/readelf -s testfilebaztab
 
 cat testfile.dynsym.in \
-  | testrun_compare ../src/readelf -s testfilebazdbg
+  | testrun_compare ${abs_top_builddir}/src/readelf -s testfilebazdbg
 
 cat testfile.symtab.in \
-  | testrun_compare ../src/readelf -s testfilebazdbg.debug
+  | testrun_compare ${abs_top_builddir}/src/readelf -s testfilebazdbg.debug
 
 cat testfile.dynsym.in \
-  | testrun_compare ../src/readelf -s testfilebazdyn
+  | testrun_compare ${abs_top_builddir}/src/readelf -s testfilebazdyn
 
 cat testfile.dynsym.in \
-  | testrun_compare ../src/readelf -s testfilebazmdb
+  | testrun_compare ${abs_top_builddir}/src/readelf -s testfilebazmdb
 
 cat testfile.minsym.in \
-  | testrun_compare ../src/readelf --elf-section -s testfilebazmdb
+  | testrun_compare ${abs_top_builddir}/src/readelf --elf-section -s testfilebazmdb
 
 cat testfile.dynsym.in \
-  | testrun_compare ../src/readelf -s testfilebazmin
+  | testrun_compare ${abs_top_builddir}/src/readelf -s testfilebazmin
 
 cat testfile.minsym.in \
-  | testrun_compare ../src/readelf --elf-section -s testfilebazmin
+  | testrun_compare ${abs_top_builddir}/src/readelf --elf-section -s testfilebazmin
 
-testrun_compare ../src/readelf -s testfilebasmin <<EOF
+testrun_compare ${abs_top_builddir}/src/readelf -s testfilebasmin <<EOF
 EOF
 
-testrun_compare ../src/readelf --elf-section -s testfilebasmin <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf --elf-section -s testfilebasmin <<\EOF
 
 Symbol table [ 6] '.symtab' contains 9 entries:
  6 local symbols  String table: [ 7] '.strtab'
diff --git a/tests/run-readelf-self.sh b/tests/run-readelf-self.sh
index 4602712..7ffb357 100755
--- a/tests/run-readelf-self.sh
+++ b/tests/run-readelf-self.sh
@@ -18,4 +18,4 @@
 . $srcdir/test-subr.sh
 
 # Just makes sure readelf doesn't crash
-testrun_on_self_quiet ../src/readelf -a -w
+testrun_on_self_quiet ${abs_top_builddir}/src/readelf -a -w
diff --git a/tests/run-readelf-test1.sh b/tests/run-readelf-test1.sh
index b64103e..4725049 100755
--- a/tests/run-readelf-test1.sh
+++ b/tests/run-readelf-test1.sh
@@ -26,7 +26,7 @@ testfiles testfile3
 
 tempfiles testfile.temp
 
-testrun ../src/readelf -r testfile3 > testfile.temp
+testrun ${abs_top_builddir}/src/readelf -r testfile3 > testfile.temp
 
 diff -u - testfile.temp <<EOF
 
diff --git a/tests/run-readelf-test2.sh b/tests/run-readelf-test2.sh
index 676fcde..9030624 100755
--- a/tests/run-readelf-test2.sh
+++ b/tests/run-readelf-test2.sh
@@ -19,7 +19,7 @@
 
 testfiles testfile28
 
-testrun_compare ../src/readelf -x .strtab testfile28 <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf -x .strtab testfile28 <<\EOF
 
 Hex dump of section [6] '.strtab', 1 bytes at offset 0x290:
   0x00000000 00                                  .
diff --git a/tests/run-readelf-test3.sh b/tests/run-readelf-test3.sh
index 15f0ba5..cc0a191 100755
--- a/tests/run-readelf-test3.sh
+++ b/tests/run-readelf-test3.sh
@@ -19,7 +19,7 @@
 
 testfiles testfile40.debug
 
-testrun_compare ../src/readelf -n testfile40.debug <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile40.debug <<\EOF
 
 Note section [ 6] '.note' of 60 bytes at offset 0x120:
   Owner          Data size  Type
diff --git a/tests/run-readelf-test4.sh b/tests/run-readelf-test4.sh
index 16cf802..ca0526a 100755
--- a/tests/run-readelf-test4.sh
+++ b/tests/run-readelf-test4.sh
@@ -19,7 +19,7 @@
 
 testfiles testfile19.index
 
-testrun_compare ../src/readelf -c testfile19.index <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf -c testfile19.index <<\EOF
 
 Index of archive 'testfile19.index' has 4 entries:
 Archive member 'u1.o' contains:
diff --git a/tests/run-readelf-twofiles.sh b/tests/run-readelf-twofiles.sh
index d12f57f..46eec7b 100755
--- a/tests/run-readelf-twofiles.sh
+++ b/tests/run-readelf-twofiles.sh
@@ -19,6 +19,6 @@
 
 testfiles testfile14
 
-testrun >/dev/null ../src/readelf -w testfile14 testfile14
+testrun >/dev/null ${abs_top_builddir}/src/readelf -w testfile14 testfile14
 
 exit 0
diff --git a/tests/run-readelf-vmcoreinfo.sh b/tests/run-readelf-vmcoreinfo.sh
index da361c8..b1732fc 100755
--- a/tests/run-readelf-vmcoreinfo.sh
+++ b/tests/run-readelf-vmcoreinfo.sh
@@ -19,7 +19,7 @@
 
 testfiles testfile62
 
-testrun_compare ../src/readelf -n testfile62 <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile62 <<\EOF
 
 Note segment of 2104 bytes at offset 0x158:
   Owner          Data size  Type
diff --git a/tests/run-rerequest_tag.sh b/tests/run-rerequest_tag.sh
index 3a4cb1c..f437284 100755
--- a/tests/run-rerequest_tag.sh
+++ b/tests/run-rerequest_tag.sh
@@ -19,7 +19,7 @@
 
 testfiles testfile56 testfile57
 
-testrun ./rerequest_tag testfile56
-testrun ./rerequest_tag testfile57
+testrun ${abs_builddir}/rerequest_tag testfile56
+testrun ${abs_builddir}/rerequest_tag testfile57
 
 exit 0
diff --git a/tests/run-show-abbrev.sh b/tests/run-show-abbrev.sh
index 351730f..40d0e36 100755
--- a/tests/run-show-abbrev.sh
+++ b/tests/run-show-abbrev.sh
@@ -20,7 +20,7 @@
 
 testfiles testfile testfile2
 
-testrun_compare ./show-abbrev testfile testfile2 <<\EOF
+testrun_compare ${abs_builddir}/show-abbrev testfile testfile2 <<\EOF
 abbrev[0]: code = 1, tag = 17, children = 1
 abbrev[0]: attr[0]: code = 16, form = 6, offset = 0
 abbrev[0]: attr[1]: code = 18, form = 1, offset = 2
diff --git a/tests/run-show-die-info.sh b/tests/run-show-die-info.sh
index cbe60f9..f92ee48 100755
--- a/tests/run-show-die-info.sh
+++ b/tests/run-show-die-info.sh
@@ -20,7 +20,7 @@
 
 testfiles testfile5 testfile2
 
-testrun_compare ./show-die-info testfile5 testfile2 <<\EOF
+testrun_compare ${abs_builddir}/show-die-info testfile5 testfile2 <<\EOF
 file: testfile5
 New CU: off = 0, hsize = 11, ab = 0, as = 4, os = 4
      DW_TAG_compile_unit
diff --git a/tests/run-strings-test.sh b/tests/run-strings-test.sh
index 6bfc87e..33f2d64 100755
--- a/tests/run-strings-test.sh
+++ b/tests/run-strings-test.sh
@@ -21,7 +21,7 @@
 files="testfile `seq 2 9 | while read n; do echo testfile$n; done`"
 testfiles $files
 
-testrun_compare ../src/strings -tx -f $files <<\EOF
+testrun_compare ${abs_top_builddir}/src/strings -tx -f $files <<\EOF
 testfile:      f4 /lib/ld-linux.so.2
 testfile:     1c9 __gmon_start__
 testfile:     1d8 libc.so.6
diff --git a/tests/run-strip-groups.sh b/tests/run-strip-groups.sh
index 86d1d44..1c836a4 100755
--- a/tests/run-strip-groups.sh
+++ b/tests/run-strip-groups.sh
@@ -49,7 +49,7 @@ dbgfile=$infile.debug
 testfiles $infile
 tempfiles $outfile $dbgfile
 
-testrun ../src/strip -o $outfile -f $dbgfile $infile
-testrun ../src/elflint -q $infile
-testrun ../src/elflint -q $outfile
-testrun ../src/elflint -q -d $dbgfile
+testrun ${abs_top_builddir}/src/strip -o $outfile -f $dbgfile $infile
+testrun ${abs_top_builddir}/src/elflint -q $infile
+testrun ${abs_top_builddir}/src/elflint -q $outfile
+testrun ${abs_top_builddir}/src/elflint -q -d $dbgfile
diff --git a/tests/run-strip-reloc.sh b/tests/run-strip-reloc.sh
index 603fb7c..ec4be3f 100755
--- a/tests/run-strip-reloc.sh
+++ b/tests/run-strip-reloc.sh
@@ -28,18 +28,18 @@ runtest() {
   outfile2=out.stripped2
   debugfile2=out.debug2
 
-  testrun ../src/strip -o $outfile1 -f $debugfile1 $infile ||
+  testrun ${abs_top_builddir}/src/strip -o $outfile1 -f $debugfile1 $infile ||
   { echo "*** failure strip $infile"; status=1; }
 
-  testrun ../src/strip --reloc-debug-sections -o $outfile2 \
+  testrun ${abs_top_builddir}/src/strip --reloc-debug-sections -o $outfile2 \
 	-f $debugfile2 $infile ||
   { echo "*** failure strip --reloc-debug-sections $infile"; status=1; }
 
   # shouldn't make any difference for stripped files.
-  testrun ../src/readelf -a $outfile1 > readelf.out ||
+  testrun ${abs_top_builddir}/src/readelf -a $outfile1 > readelf.out ||
   { echo "*** failure readelf -a outfile1 $infile"; status=1; }
 
-  testrun_compare ../src/readelf -a $outfile2 < readelf.out ||
+  testrun_compare ${abs_top_builddir}/src/readelf -a $outfile2 < readelf.out ||
   { echo "*** failure compare stripped files $infile"; status=1; }
 
   # debug files however should be smaller, when ET_REL.
@@ -51,11 +51,11 @@ runtest() {
 
   # Strip of DWARF section lines, offset will not match.
   # Everything else should match.
-  testrun ../src/readelf -w $debugfile1 \
+  testrun ${abs_top_builddir}/src/readelf -w $debugfile1 \
 	| grep -v ^DWARF\ section > readelf.out1 ||
   { echo "*** failure readelf -w debugfile1 $infile"; status=1; }
 
-  testrun ../src/readelf -w $debugfile2 \
+  testrun ${abs_top_builddir}/src/readelf -w $debugfile2 \
 	| grep -v ^DWARF\ section > readelf.out2 ||
   { echo "*** failure readelf -w debugfile2 $infile"; status=1; }
 
@@ -101,7 +101,7 @@ runtest hello_ppc64.ko 1
 runtest hello_s390.ko 1
 
 # self test, shouldn't impact non-ET_REL files at all.
-runtest ../src/strip 0
-runtest ../src/strip.o 1
+runtest ${abs_top_builddir}/src/strip 0
+runtest ${abs_top_builddir}/src/strip.o 1
 
 exit $status
diff --git a/tests/run-strip-test.sh b/tests/run-strip-test.sh
index c6c7c09..c558e90 100755
--- a/tests/run-strip-test.sh
+++ b/tests/run-strip-test.sh
@@ -27,30 +27,30 @@ test x$stripped = xtestfile.temp || testfiles $stripped $debugfile
 
 tempfiles testfile.temp testfile.debug.temp testfile.unstrip
 
-testrun ../src/strip -o testfile.temp $debugout $original
+testrun ${abs_top_builddir}/src/strip -o testfile.temp $debugout $original
 
 status=0
 
 cmp $stripped testfile.temp || status=$?
 
 # Check elflint and the expected result.
-testrun ../src/elflint -q testfile.temp || status=$?
+testrun ${abs_top_builddir}/src/elflint -q testfile.temp || status=$?
 
 test -z "$debugfile" || {
 cmp $debugfile testfile.debug.temp || status=$?
 
 # Check elflint and the expected result.
-testrun ../src/elflint -q -d testfile.debug.temp || status=$?
+testrun ${abs_top_builddir}/src/elflint -q -d testfile.debug.temp || status=$?
 
 # Now test unstrip recombining those files.
-testrun ../src/unstrip -o testfile.unstrip testfile.temp testfile.debug.temp
+testrun ${abs_top_builddir}/src/unstrip -o testfile.unstrip testfile.temp testfile.debug.temp
 
 # Check that it came back whole.
-testrun ../src/elfcmp --hash-inexact $original testfile.unstrip
+testrun ${abs_top_builddir}/src/elfcmp --hash-inexact $original testfile.unstrip
 }
 
 tempfiles testfile.sections
-testrun ../src/readelf -S testfile.temp > testfile.sections || status=$?
+testrun ${abs_top_builddir}/src/readelf -S testfile.temp > testfile.sections || status=$?
 fgrep ' .debug_' testfile.sections && status=1
 
 exit $status
diff --git a/tests/run-test-archive64.sh b/tests/run-test-archive64.sh
index 26552ac..43df16e 100755
--- a/tests/run-test-archive64.sh
+++ b/tests/run-test-archive64.sh
@@ -26,7 +26,7 @@
 #  ar cru testarchive64.a aaa.o bbb.o ccc.o
 testfiles testarchive64.a
 
-testrun_compare ../src/readelf -c testarchive64.a <<\EOF
+testrun_compare ${abs_top_builddir}/src/readelf -c testarchive64.a <<\EOF
 
 Index of archive 'testarchive64.a' has 7 entries:
 Archive member 'aaa.o' contains:
diff --git a/tests/run-test-flag-nobits.sh b/tests/run-test-flag-nobits.sh
index 1566756..9bedf17 100755
--- a/tests/run-test-flag-nobits.sh
+++ b/tests/run-test-flag-nobits.sh
@@ -19,4 +19,4 @@
 
 testfiles testfile
 
-testrun ./test-flag-nobits testfile
+testrun ${abs_builddir}/test-flag-nobits testfile
diff --git a/tests/run-typeiter.sh b/tests/run-typeiter.sh
index 3a453ab..b85839c 100755
--- a/tests/run-typeiter.sh
+++ b/tests/run-typeiter.sh
@@ -43,7 +43,7 @@
 
 testfiles testfile59
 
-testrun_compare ./typeiter testfile59 <<\EOF
+testrun_compare ${abs_builddir}/typeiter testfile59 <<\EOF
 ok
 EOF
 
diff --git a/tests/run-unstrip-n.sh b/tests/run-unstrip-n.sh
index 1353b1d..9c2b43b 100755
--- a/tests/run-unstrip-n.sh
+++ b/tests/run-unstrip-n.sh
@@ -33,7 +33,7 @@
 
 testfiles testcore-rtlib testcore-rtlib-ppc
 
-testrun_compare ../src/unstrip -n --core=testcore-rtlib <<\EOF
+testrun_compare ${abs_top_builddir}/src/unstrip -n --core=testcore-rtlib <<\EOF
 0x8048000+0x2000 f1c600bc36cb91bf01f9a63a634ecb79aa4c3199@0x8048178 . - [exe]
 0xf77d6000+0x1000 676560b1b765cde9c2e53f134f4ee354ea894747@0xf77d6210 . - linux-gate.so.1
 0xf77b3000+0x9000 c6c5b5e35ab9589d4762ac85b4bd56b1b2720e37@0xf77b3164 /lib/librt.so.1 - librt.so.1
@@ -42,7 +42,7 @@ testrun_compare ../src/unstrip -n --core=testcore-rtlib <<\EOF
 0xf77d7000+0x21000 6d2cb32650054f1c176d01d48713a4a5e5e84c1a@0xf77d7124 /lib/ld-linux.so.2 - ld-linux.so.2
 EOF
 
-testrun_compare ../src/unstrip -n --core=testcore-rtlib-ppc <<\EOF
+testrun_compare ${abs_top_builddir}/src/unstrip -n --core=testcore-rtlib-ppc <<\EOF
 0x10000000+0x20000 979b7a26747cc09bd84a42b311b5288c704baea5@0x10000174 . - [exe]
 0x100000+0x10000 708b900b05176964512a6b0fe90c2a0c9d73d726@0x100334 . - linux-vdso32.so.1
 0xfd50000+0x30000 3f7d21508470322d2f47acddc20ab10516edba99@0xfd50164 /lib/librt.so.1 - librt.so.1
diff --git a/tests/run-unstrip-test.sh b/tests/run-unstrip-test.sh
index 3654943..dc7d3a4 100755
--- a/tests/run-unstrip-test.sh
+++ b/tests/run-unstrip-test.sh
@@ -29,15 +29,15 @@ tempfiles testfile.unstrip testfile.inplace
 # stripped sections that shrank in the stripped file.  strip
 # no longer does that, but unstrip must still handle it.
 
-testrun ../src/unstrip -o testfile.unstrip $stripped $debugfile
+testrun ${abs_top_builddir}/src/unstrip -o testfile.unstrip $stripped $debugfile
 
-testrun ../src/elfcmp --hash-inexact $original testfile.unstrip
+testrun ${abs_top_builddir}/src/elfcmp --hash-inexact $original testfile.unstrip
 
 # Also test modifying the file in place.
 
 rm -f testfile.inplace
 cp $debugfile testfile.inplace
 chmod 644 testfile.inplace
-testrun ../src/unstrip $stripped testfile.inplace
+testrun ${abs_top_builddir}/src/unstrip $stripped testfile.inplace
 
-testrun ../src/elfcmp --hash-inexact $original testfile.inplace
+testrun ${abs_top_builddir}/src/elfcmp --hash-inexact $original testfile.inplace
diff --git a/tests/test-subr.sh b/tests/test-subr.sh
index 19a9836..7bf1f71 100644
--- a/tests/test-subr.sh
+++ b/tests/test-subr.sh
@@ -22,11 +22,16 @@
 
 set -e
 
+# Each test runs in its own directory to make sure they can run in parallel.
+test_dir="test-$$"
+mkdir -p "$test_dir"
+pushd "$test_dir" > /dev/null
+
 #LC_ALL=C
 #export LC_ALL
 
 remove_files=
-trap 'rm -f $remove_files' 0
+trap 'rm -f $remove_files; popd > /dev/null; rmdir $test_dir' 0
 
 tempfiles()
 {
@@ -36,7 +41,7 @@ tempfiles()
 testfiles()
 {
   for file; do
-    bunzip2 -c $srcdir/${file}.bz2 > ${file} 2>/dev/null || exit 77
+    bunzip2 -c ${abs_srcdir}/${file}.bz2 > ${file} 2>/dev/null || exit 77
     remove_files="$remove_files $file"
   done
 }
@@ -80,13 +85,13 @@ installed_testrun()
   program="$1"
   shift
   case "$program" in
-  ./*)
+  ${abs_builddir}/*)
     if [ "x$elfutils_tests_rpath" != xno ]; then
       echo >&2 installcheck not possible with --enable-tests-rpath
       exit 77
     fi
     ;;
-  ../*)
+  ${abs_top_builddir}/src/*)
     program=${bindir}/`program_transform ${program##*/}`
     ;;
   esac
@@ -104,10 +109,12 @@ program_transform()
   echo "$*" | sed "${program_transform_name}"
 }
 
-self_test_files=`echo ../src/addr2line ../src/elfcmp ../src/elflint \
-../src/findtextrel ../src/ld ../src/nm ../src/objdump ../src/readelf \
-../src/size ../src/strip ../libelf/libelf.so ../libdw/libdw.so \
-../libasm/libasm.so ../backends/libebl_*.so`
+self_test_files=`echo ${abs_top_builddir}/src/addr2line \
+${abs_top_builddir}/src/elfcmp ${abs_top_builddir}/src/elflint \
+${abs_top_builddir}/src/nm ${abs_top_builddir}/src/objdump \
+${abs_top_builddir}/src/readelf ${abs_top_builddir}/src/size \
+${abs_top_builddir}/src/strip ${abs_top_builddir}/libelf/libelf.so \
+${abs_top_builddir}/libdw/libdw.so ${abs_top_builddir}/backends/libebl_*.so`
 
 # Provide a command to run on all self-test files with testrun.
 testrun_on_self()
