]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
2005-11-15 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@redhat.com>
Wed, 16 Nov 2005 01:33:38 +0000 (01:33 +0000)
committerRoland McGrath <roland@redhat.com>
Wed, 16 Nov 2005 01:33:38 +0000 (01:33 +0000)
* configure.ac: Add --enable-tests-rpath option.

tests/
2005-11-15  Roland McGrath  <roland@redhat.com>

* Makefile.am (BUILD_RPATH): New variable.
[TESTS_RPATH] (AM_LDFLAGS): Pass -rpath option using that value.
(tests_rpath): New variable.
(installcheck-local): Pass it to test-wrapper.sh.
* test-wrapper.sh: In "installed" format, take yes/no value
for elfutils_tests_rpath, which export.  When running a test
binary for installcheck, exit 77.
* test-subr.sh (installed_testrun): When running a test binary
for installcheck, exit 77 if $elfutils_tests_rpath = yes.

26 files changed:
ChangeLog
configure.ac
tests/ChangeLog
tests/Makefile.am
tests/run-addrscopes.sh
tests/run-allfcts.sh
tests/run-ecp-test.sh
tests/run-ecp-test2.sh
tests/run-elflint-self.sh
tests/run-elflint-test.sh
tests/run-find-prologues.sh
tests/run-funcscopes.sh
tests/run-get-aranges.sh
tests/run-get-files.sh
tests/run-get-lines.sh
tests/run-get-pubnames.sh
tests/run-line2addr.sh
tests/run-ranlib-test.sh
tests/run-ranlib-test2.sh
tests/run-show-abbrev.sh
tests/run-show-ciefde.sh
tests/run-show-die-info.sh
tests/run-strings-test.sh
tests/run-strip-test.sh
tests/test-subr.sh [new file with mode: 0644]
tests/test-wrapper.sh [new file with mode: 0755]

index d03a77139659c7ae74c00b60ca184094a24b8a45..ff169d67db743f5ed0b24d046dac970400c4a579 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-11-15  Roland McGrath  <roland@redhat.com>
+
+       * configure.ac: Add --enable-tests-rpath option.
+
 2005-09-16  Roland McGrath  <roland@redhat.com>
 
        * configure.ac (ALLOW_UNALIGNED) [__ia64__ || __alpha__]:
index c2140e266fd4049a44d3c1544de013a74a6eb6f5..3d30a031ca37fabf7625d222187b5312cb3b6fa2 100644 (file)
@@ -152,6 +152,11 @@ AM_CONDITIONAL(GCOV, test "$use_gcov" = yes)
 AM_CONDITIONAL(BUILD_STATIC, [dnl
 test "$use_mudflap" = yes -o "$use_gprof" = yes -o "$use_gcov" = yes])
 
+AC_ARG_ENABLE([tests-rpath],
+AC_HELP_STRING([--enable-tests-rpath], [build $ORIGIN-using rpath into tests]),
+              [tests_use_rpath=yes], [tests_use_rpath=no])
+AM_CONDITIONAL(TESTS_RPATH, test "$tests_use_rpath" = yes)
+
 LIBEBL_SUBDIR="$PACKAGE"
 AC_ARG_ENABLE([libebl-subdir],
 AS_HELP_STRING([--enable-libebl-subdir=DIR],
index 2c5fc164d78b0d6347f50bb11fa6a608777dee23..6243ff42633fe1f57da56c7b307f6c85385d2ef7 100644 (file)
@@ -1,3 +1,44 @@
+2005-11-15  Roland McGrath  <roland@redhat.com>
+
+       * Makefile.am (BUILD_RPATH): New variable.
+       [TESTS_RPATH] (AM_LDFLAGS): Pass -rpath option using that value.
+       (tests_rpath): New variable.
+       (installcheck-local): Pass it to test-wrapper.sh.
+       * test-wrapper.sh: In "installed" format, take yes/no value
+       for elfutils_tests_rpath, which export.  When running a test
+       binary for installcheck, exit 77.
+       * test-subr.sh (installed_testrun): When running a test binary
+       for installcheck, exit 77 if $elfutils_tests_rpath = yes.
+
+2005-11-14  Roland McGrath  <roland@redhat.com>
+
+       * test-subr.sh: New file.
+       * test-wrapper.sh: New file.
+       * Makefile.am (EXTRA_DIST): Add them.
+       (AM_LDFLAGS): Variable removed.
+       (TESTS_ENVIRONMENT): New variable.
+       (installcheck-local): New target.
+       * run-addrscopes.sh: Use test-subr.sh.
+       * run-allfcts.sh: Likewise.
+       * run-ecp-test.sh: Likewise.
+       * run-ecp-test2.sh: Likewise.
+       * run-elflint-self.sh: Likewise.
+       * run-elflint-test.sh: Likewise.
+       * run-find-prologues.sh: Likewise.
+       * run-funcscopes.sh: Likewise.
+       * run-get-aranges.sh: Likewise.
+       * run-get-files.sh: Likewise.
+       * run-get-lines.sh: Likewise.
+       * run-get-pubnames.sh: Likewise.
+       * run-line2addr.sh: Likewise.
+       * run-ranlib-test.sh: Likewise.
+       * run-ranlib-test2.sh: Likewise.
+       * run-show-abbrev.sh: Likewise.
+       * run-show-ciefde.sh: Likewise.
+       * run-show-die-info.sh: Likewise.
+       * run-strings-test.sh: Likewise.
+       * run-strip-test.sh: Likewise.
+
 2005-11-09  Ulrich Drepper  <drepper@redhat.com>
 
        * line2addr.c (handle_module): Add missing parameter to printf.
index 01d7b6ad7454f422b57b3ba740a44b17379e1c78..0a80f63438d61254d8c4d7d6a0a1bcb554260cca 100644 (file)
@@ -16,17 +16,24 @@ DEFS = -DHAVE_CONFIG_H -D_GNU_SOURCE
 if MUDFLAP
 AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 -fmudflap\
            $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2)
-AM_LDFLAGS = -Wl,-rpath,\$$ORIGIN/../libebl
+BUILD_RPATH = \$$ORIGIN/../libebl
 else
 AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 \
            $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2)
-AM_LDFLAGS = -Wl,-rpath,\$$ORIGIN/../libasm:\$$ORIGIN/../libdw:\$$ORIGIN/../libebl:\$$ORIGIN/../libelf
+BUILT_RPATH = \$$ORIGIN/../libasm:\$$ORIGIN/../libdw:\$$ORIGIN/../libebl:\$$ORIGIN/../libelf
 endif
 INCLUDES = -I$(top_srcdir)/libasm -I$(top_srcdir)/libdw \
           -I$(top_srcdir)/libdwfl \
           -I$(top_srcdir)/libebl -I$(top_srcdir)/libelf \
           -I$(top_srcdir)/lib -I..
 
+if TESTS_RPATH
+AM_LDFLAGS = -Wl,-rpath,$(BUILT_RPATH)
+tests_rpath = yes
+else
+tests_rpath = no
+endif
+
 noinst_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
                  showptable update1 update2 update3 update4 test-nlist \
                  show-die-info get-files get-lines get-pubnames \
@@ -73,7 +80,16 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
             testfile20.bz2 testfile20.index.bz2 \
             testfile21.bz2 testfile21.index.bz2 \
             testfile22.bz2 testfile23.bz2 testfile24.bz2 testfile25.bz2 \
-            coverage.sh
+            coverage.sh test-subr.sh test-wrapper.sh
+
+TESTS_ENVIRONMENT = $(srcdir)/test-wrapper.sh \
+                   ../libdw:../libebl:../libelf:../libasm
+
+installcheck-local:
+       $(MAKE) $(AM_MAKEFLAGS) TESTS_ENVIRONMENT='$(srcdir)/test-wrapper.sh \
+                                       installed $(tests_rpath) \
+                                       $(program_transform_name)' \
+               check-TESTS
 
 if MUDFLAP
 static_build=yes
index d1e89cc85182b2fe354a9f254f1bde9b55deafc1..e1ac7b8eee93771b28f297aa7b660c52b9433d36 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile22.bz2 > testfile22 2>/dev/null || exit 77
+testfiles testfile22
 
-LD_LIBRARY_PATH=../libdw:../libebl:../libelf${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH \
-  ./addrscopes -e testfile22 0x8048353 >& addrscopes-test.out || :
-
-diff -Bbu addrscopes-test.out - <<\EOF
+testrun_compare ./addrscopes -e testfile22 0x8048353 <<\EOF
 0x8048353:
     tests/foo.c (0x11): 0x8048348 (tests/foo.c:5) .. 0x804837e (tests/foo.c:16)
         global                        [    be]
@@ -26,15 +22,10 @@ diff -Bbu addrscopes-test.out - <<\EOF
             local                         [    8f]
 EOF
 
-rm -f testfile22 addrscopes-test.out
-
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile24.bz2 > testfile24 2>/dev/null || exit 77
+test_cleanup
 
-LD_LIBRARY_PATH=../libdw:../libebl:../libelf${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH \
-  ./addrscopes -e testfile24 0x804834e >& addrscopes-test.out || :
-
-diff -Bbu addrscopes-test.out - <<\EOF
+testfiles testfile24
+testrun_compare ./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)
@@ -44,6 +35,4 @@ diff -Bbu addrscopes-test.out - <<\EOF
             y (abstract)
 EOF
 
-rm -f testfile24 addrscopes-test.out
-
 exit 0
index 3fde34b9fafbf00fafb21fde1315a1e84ae1e2c4..5ca342e4edc034792a88285160658ee971ef24ba 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile.bz2 > testfile 2>/dev/null || exit 77
+testfiles testfile testfile2 testfile8
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile2.bz2 > testfile2 2>/dev/null || exit 77
-
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile8.bz2 > testfile8 2>/dev/null || exit 77
-
-./allfcts testfile testfile2 testfile8 > allfcts.out
-
-diff -u allfcts.out - <<"EOF"
+testrun_compare ./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
@@ -41,6 +32,4 @@ diff -u allfcts.out - <<"EOF"
 /home/drepper/gnu/elfutils/build/src/../../src/strip.c:313:handle_elf
 EOF
 
-rm -f testfile testfile2 testfile8 allfcts.out
-
 exit 0
index c21bb6ca3098ee47ac23c7e4740a7efd3d764431..aee8b9c547a41ca28b27322e317cb19e0664601d 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile10.bz2 > testfile10 2>/dev/null || exit 77
+testfiles testfile10
+tempfiles testfile10.tmp
 
-./ecp testfile10 testfile10.tmp
+testrun ./ecp testfile10 testfile10.tmp
 
 cmp testfile10 testfile10.tmp
 
-rm -f testfile10 testfile10.tmp
-
 exit 0
index 8f3775be9143770c69600e4cc171d97abe22e8eb..2f8ce07f74cac4308816a2481b8420d19b7cfbd7 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile2.bz2 > testfile2 2>/dev/null || exit 77
+testfiles testfile2
+tempfiles testfile2.tmp
 
-./ecp testfile2 testfile2.tmp
-
-rm -f testfile2 testfile2.tmp
+testrun ./ecp testfile2 testfile2.tmp
 
 exit 0
index df7678abe1183efe2023bab5da4ef37ea514222e..123cfe04e9984ae829c5e9f17c10eddb67ff6450 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
-
-export LD_LIBRARY_PATH=../libebl:../libelf${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH
+. $srcdir/test-subr.sh
 
 runtest() {
 # Uncomment for debuging
 #  echo $1
   if [ -f $1 ]; then
-    ../src/elflint --quiet --gnu-ld $1
+    testrun ../src/elflint --quiet --gnu-ld $1
   fi
 }
 
index 74727b66ef220645875bad24eee53cba522663ca..8d8e353c41fb8bdae3ac3aa2972c4dc66063dffb 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile18.bz2 > testfile18 2>/dev/null || exit 77
+testfiles testfile18
 
-LD_LIBRARY_PATH=../libebl:../libelf${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH \
-  ../src/elflint --gnu-ld testfile18 >& elflint-test.out || :
-
-diff -u elflint-test.out - <<"EOF"
+testrun_compare ../src/elflint --gnu-ld testfile18 <<\EOF
 section [ 8] '.rela.dyn': relocation 1: copy relocation against symbol of type FUNC
 EOF
 
-rm -f testfile18 elflint-test.out
-
 exit 0
index 3e43fc5315c4b19070debed19a7406b2460ad220..56d2819abd0ff13e7b9f327f8e5ff95946a82f96 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
-files="testfile testfile11 testfile22 testfile24 \
-testfile25 testfile3 testfile4 testfile5 testfile6"
+testfiles testfile testfile11 testfile22 testfile24 \
+         testfile25 testfile3 testfile4 testfile5 testfile6
 
-for file in $files; do
-  # Don't fail if we cannot decompress the file.
-  bunzip2 -c $srcdir/$file.bz2 > $file 2>/dev/null || exit 77
-done
-
-for file in $files; do
-  ./find-prologues -e $file || :
-done > find-prologues-test.out 2>&1
-
-diff -Bbu find-prologues-test.out - <<\EOF
+testrun_compare ./find-prologues -e testfile <<\EOF
 main             0x000000000804842c 0x0000000008048432
 bar              0x000000000804845c 0x000000000804845f
 foo              0x0000000008048468 0x000000000804846b
+EOF
+
+testrun_compare ./find-prologues -e testfile11 <<\EOF
 main             0x00000000080489b8 0x00000000080489cd
 gnu_obj_2        0x0000000008048c9e 0x0000000008048ca4
 gnu_obj_3        0x0000000008048cd8 0x0000000008048cde
@@ -36,22 +30,43 @@ gnu_obj_2        0x0000000008048cf4 0x0000000008048cfa
 gnu_obj_1        0x0000000008048d62 0x0000000008048d65
 gnu_obj_1        0x0000000008048d8a 0x0000000008048d8d
 ~invalid_argument 0x0000000008048db2 0x0000000008048db8
+EOF
+
+testrun_compare ./find-prologues -e testfile22 <<\EOF
 function         0x0000000008048348 0x000000000804834e
 main             0x000000000804835b 0x0000000008048377
+EOF
+
+testrun_compare ./find-prologues -e testfile24 <<\EOF
 incr             0x0000000008048348 0x000000000804834e
 main             0x0000000008048354 0x0000000008048360
+EOF
+
+testrun_compare ./find-prologues -e testfile25 <<\EOF
 incr             0x0000000008048348 0x000000000804834c
+EOF
+
+testrun_compare ./find-prologues -e testfile3 <<\EOF
 main             0x000000000804842c 0x0000000008048433
 bar              0x0000000008048458 0x000000000804845b
 foo              0x0000000008048464 0x0000000008048467
+EOF
+
+testrun_compare ./find-prologues -e testfile4 <<\EOF
 get              0x00000000080493fc 0x0000000008049402
 main             0x0000000008049498 0x000000000804949e
 a                0x000000000804d85c 0x000000000804d85c
 __tfPCc          0x000000000804d86c 0x000000000804d872
 __tfCc           0x000000000804d8a4 0x000000000804d8a4
+EOF
+
+testrun_compare ./find-prologues -e testfile5 <<\EOF
 bar              0x000000000804842c 0x000000000804842f
 foo              0x0000000008048438 0x000000000804843b
 main             0x0000000008048444 0x000000000804844a
+EOF
+
+testrun_compare ./find-prologues -e testfile6 <<\EOF
 main             0x00000000080489b8 0x00000000080489cd
 gnu_obj_2        0x0000000008048c9e 0x0000000008048ca4
 gnu_obj_3        0x0000000008048cd8 0x0000000008048cde
@@ -62,4 +77,4 @@ gnu_obj_1        0x0000000008048d8a 0x0000000008048d8d
 ~invalid_argument 0x0000000008048db2 0x0000000008048db8
 EOF
 
-rm -f find-prologues-test.out $files
+exit 0
index e0dcfae1684afd80129d457ee0f2592ae595caae..4d3657234883026d15b8bfaab5b2ffb8db1dbc5d 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile25.bz2 > testfile25 2>/dev/null || exit 77
+testfiles testfile25
 
-LD_LIBRARY_PATH=../libdw:../libebl:../libelf${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH \
-  ./funcscopes -e testfile25 incr >& funcscopes-test.out || :
-
-diff -Bbu funcscopes-test.out - <<\EOF
+testrun_compare ./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)
             x                             [    66]
 EOF
 
-rm -f testfile25 funcscopes-test.out
-
 exit 0
index a816c218488b3c0e9287b6b9a2b9036b7bbf27d9..8bcb2c9033c740c94b6b1f654277a32abd63e844 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile.bz2 > testfile 2>/dev/null || exit 77
+testfiles testfile testfile2
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile2.bz2 > testfile2 2>/dev/null || exit 77
-
-./get-aranges testfile testfile2 > get-aranges.out
-
-cmp get-aranges.out - <<"EOF"
+testrun_compare ./get-aranges testfile testfile2 <<\EOF
 0x804842b: not in range
 CU name: "m.c"
 CU name: "m.c"
@@ -66,6 +60,4 @@ CU name: "f.c"
 CU name: "m.c"
 EOF
 
-rm -f testfile testfile2 get-aranges.out
-
 exit 0
index e80cf68d78f99449275433a5f08492a53c31f75c..afeac22d8ea9cb9f590fb9f82824024213243b7e 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile.bz2 > testfile 2>/dev/null || exit 77
+testfiles testfile testfile2
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile2.bz2 > testfile2 2>/dev/null || exit 77
-
-./get-files testfile testfile2 > get-files.out
-
-diff -u get-files.out - <<"EOF"
+testrun_compare ./get-files testfile testfile2 <<\EOF
 cuhl = 11, o = 0, asz = 4, osz = 4, ncu = 191
  file[0] = "???"
  file[1] = "/home/drepper/gnu/new-bu/build/ttt/m.c"
@@ -59,6 +53,4 @@ cuhl = 11, o = 267, asz = 4, osz = 4, ncu = 2680
  file[1] = "/shoggoth/drepper/m.c"
 EOF
 
-rm -f testfile testfil2 get-files.out
-
 exit 0
index 2f7f85809932ce7cacc17122c3e3a238f2738d33..d7dc0c812d977124e3a8365d0c461563806ed794 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile.bz2 > testfile 2>/dev/null || exit 77
+testfiles testfile testfile2
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile2.bz2 > testfile2 2>/dev/null || exit 77
-
-./get-lines testfile testfile2 > get-lines.out
-
-diff -u get-lines.out - <<"EOF"
+testrun_compare ./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
@@ -62,6 +56,4 @@ cuhl = 11, o = 267, asz = 4, osz = 4, ncu = 2680
 10000514: /shoggoth/drepper/m.c:8:0: is_stmt:yes, end_seq:yes, bb:no, prologue:no, epilogue:no
 EOF
 
-rm -f testfile testfile2 get-lines.out
-
 exit 0
index 4c9d5c2a7e0a6f4d6fe225d06913c06685360612..35cbfae55c72313b338e841c34879f23d4a38e2a 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile.bz2 > testfile 2>/dev/null || exit 77
+testfiles testfile testfile2
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile2.bz2 > testfile2 2>/dev/null || exit 77
-
-./get-pubnames testfile testfile2 > get-pubnames.out
-
-diff -u get-pubnames.out - <<"EOF"
+testrun_compare ./get-pubnames testfile testfile2 <<\EOF
  [ 0] "main", die: 104, cu: 11
 CU name: "m.c"
 object name: "main"
@@ -48,6 +42,4 @@ CU name: "m.c"
 object name: "a"
 EOF
 
-rm -f testfile testfile2 get-pubnames.out
-
 exit 0
index 91047c2739a65e890fe0d9ccbed200a7d2a7f535..0e57b891659aa5eb800b7de0ff448eb074bbadc2 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile.bz2 > testfile 2>/dev/null || exit 77
+testfiles testfile testfile2 testfile8 testfile14 testfile23
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile2.bz2 > testfile2 2>/dev/null || exit 77
-
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile8.bz2 > testfile8 2>/dev/null || exit 77
-
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile14.bz2 > testfile14 2>/dev/null || exit 77
-
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile23.bz2 > testfile23 2>/dev/null || exit 77
-
-(./line2addr -e testfile f.c:4 testfile f.c:8
- ./line2addr -e testfile2 m.c:6 b.c:1
- ./line2addr -e testfile8 strip.c:953 strip.c:365
- ./line2addr -e testfile14 v.c:6
- ./line2addr -e testfile23 foo.c:2 foo.c:6
-) > line2addr.out
-
-diff -u line2addr.out - <<"EOF"
+testrun_compare ./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
 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
 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
 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
 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
 
-rm -f testfile testfile2 testfile8 testfile14 testfile22 testfile23 \
-      line2addr.out
-
 exit 0
index 868e728eb5664b228f01d4a850b139563616b770..0397f056d5121883d5b3060a12e87d30bfa8464b 100755 (executable)
@@ -11,7 +11,9 @@
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
+
+tempfiles ranlib-test.a ranlib-test.a-copy
 
 cat > ranlib-test.a <<"EOF"
 !<arch>
@@ -23,12 +25,9 @@ EOF
 
 cp ranlib-test.a ranlib-test.a-copy
 
-LD_LIBRARY_PATH=../libelf${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH \
-  ../src/ranlib ranlib-test.a
+testrun ../src/ranlib ranlib-test.a
 
 # The ranlib call should not have changed anything.
 cmp ranlib-test.a ranlib-test.a-copy
 
-rm -f ranlib-test.a ranlib-test.a-copy
-
 exit 0
index 6eb62f2e390ccff5690b4b0c45c7b4a28ec5393f..3693eb5e5e0f7a873309ad17cb0a6742ef441efe 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
 original=${original:-testfile19}
 indexed=${indexed:-testfile19.index}
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/$original.bz2 > $original 2>/dev/null || exit 77
+testfiles $original $indexed
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/$indexed.bz2 > $indexed 2>/dev/null || exit 77
-
-LD_LIBRARY_PATH=../libelf${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH \
-  ../src/ranlib $original
+testrun ../src/ranlib $original
 
 if test -z "$noindex"; then
   # The data in the index is different.  The reference file has it blanked
@@ -34,6 +29,4 @@ fi
 
 cmp $original $indexed
 
-rm -f $original $indexed
-
 exit 0
index 0d0ff60cdb54fb5c90f80f7091a30db391a61cfd..97743b692802d44b610cfb1187791aa8ea8b3679 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile.bz2 > testfile 2>/dev/null || exit 77
+testfiles testfile testfile2
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile2.bz2 > testfile2 2>/dev/null || exit 77
-
-./show-abbrev testfile testfile2 > show-abbrev.out
-
-diff -u show-abbrev.out - <<"EOF"
+testrun_compare ./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
@@ -350,6 +344,4 @@ abbrev[96]: attr[4]: code = 63, form = 12, offset = 371
 abbrev[96]: attr[5]: code = 2, form = 10, offset = 373
 EOF
 
-rm -f testfile testfile2 show-abbrev.out
-
 exit 0
index ac97bbb327c2ed980177099dc4b03d05c98f2cad..fe0a5a91f67e0557592eb34f2e0abb38a44b1ff2 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile3.bz2 > testfile3 2>/dev/null || exit 77
+testfiles testfile3 testfile4
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile4.bz2 > testfile4 2>/dev/null || exit 77
-
-./show-ciefde testfile3 testfile4 > show-ciefde.out
-
-diff -u show-ciefde.out - <<"EOF"
+testrun_compare ./show-ciefde testfile3 testfile4 <<\EOF
 testfile3 has 1 CIEs and 1 FDEs
 CIE[0]: bytes_in_cie = 16, version = 1, augmenter = ""
 CIE[0]: code_alignment_factor = 1
@@ -314,6 +308,4 @@ no FDE at 8048455
 FDE[@80493fc]: cie_offset = 0, cie_index = 0, fde_offset = 28
 EOF
 
-rm -f testfile3 testfile4 show-ciefde.out
-
 exit 0
index 3cdfae50a77f6512b1b17f4228efaf43b58311aa..c730c1ecef8d4670d971f8399b25932ff98a8905 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile5.bz2 > testfile5 2>/dev/null || exit 77
+testfiles testfile5 testfile2
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile2.bz2 > testfile2 2>/dev/null || exit 77
-
-./show-die-info testfile5 testfile2 > show-die-info.out
-
-diff -u show-die-info.out - <<"EOF"
+testrun_compare ./show-die-info testfile5 testfile2 <<\EOF
 file: testfile5
 New CU: off = 0, hsize = 11, ab = 0, as = 4, os = 4
      DW_TAG_compile_unit
@@ -983,6 +977,4 @@ New CU: off = 2521, hsize = 11, ab = 267, as = 4, os = 4
            Attrs     : location name decl_file decl_line external type
 EOF
 
-rm -f testfile2 testfile5 show-die-info.out
-
 exit 0
index 6691800861e214bb4388baafa9665d716d3f508d..06e52e065bdd74adedc05a879f1d09d61828cc40 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile.bz2 > testfile 2>/dev/null || exit 77
+files="testfile `seq 2 9 | while read n; do echo testfile$n; done`"
+testfiles $files
 
-# Don't fail if we cannot decompress the file.
-for n in $(seq 2 9); do
-bunzip2 -c $srcdir/testfile$n.bz2 > testfile$n 2>/dev/null || exit 77
-done
-
-LD_LIBRARY_PATH=../libelf${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH \
-  ../src/strings -tx -f testfile testfile[23456789] > strings.out
-
-diff -u strings.out - <<"EOF"
+testrun_compare ../src/strings -tx -f $files <<\EOF
 testfile:      f4 /lib/ld-linux.so.2
 testfile:     1c9 __gmon_start__
 testfile:     1d8 libc.so.6
@@ -470,6 +462,4 @@ testfile9:    3e20 Discard symbols from object files.
 testfile9:    3e43 [FILE...]
 EOF
 
-rm -f testfile testfile[23456789] strings.out
-
 exit 0
index 169e8929ccde0285d894169fddaf8c5d72572607..7a5a52a51bf41d954eaf0c670dc7abe857c2b2a8 100755 (executable)
 # License version 1.0 from http://www.opensource.org/licenses/osl.php or
 # by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
 # 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
+. $srcdir/test-subr.sh
 
 original=${original:-testfile11}
 stripped=${stripped:-testfile7}
 debugout=${debugfile:+-f testfile.debug.temp -F $debugfile}
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/$original.bz2 > $original 2>/dev/null || exit 77
+testfiles $original $stripped $debugfile
 
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/$stripped.bz2 > $stripped 2>/dev/null || exit 77
+tempfiles testfile.temp testfile.debug.temp
 
-# Don't fail if we cannot decompress the file.
-test -z "$debugfile" ||
-bunzip2 -c $srcdir/$debugfile.bz2 > $debugfile 2>/dev/null || exit 77
-
-LD_LIBRARY_PATH=../libebl:../libelf${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH \
-  ../src/strip -o testfile.temp $debugout $original
+testrun ../src/strip -o testfile.temp $debugout $original
 
 cmp $stripped testfile.temp
 
 # Check elflint and the expected result.
-LD_LIBRARY_PATH=../libebl:../libelf${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH \
-  ../src/elflint -q testfile.temp
+testrun ../src/elflint -q testfile.temp
 
 test -z "$debugfile" || {
 cmp $debugfile testfile.debug.temp
 
 # Check elflint and the expected result.
-LD_LIBRARY_PATH=../libebl:../libelf${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH \
-  ../src/elflint -q -d testfile.debug.temp
-
-rm -f "$debugfile"
+testrun ../src/elflint -q -d testfile.debug.temp
 }
 
-rm -f $original $stripped testfile.temp testfile.debug.temp
-
 exit 0
diff --git a/tests/test-subr.sh b/tests/test-subr.sh
new file mode 100644 (file)
index 0000000..6ad31ed
--- /dev/null
@@ -0,0 +1,91 @@
+#! /bin/sh
+# Copyright (C) 2005 Red Hat, Inc.
+#
+# This program is Open Source software; you can redistribute it and/or
+# modify it under the terms of the Open Software License version 1.0 as
+# published by the Open Source Initiative.
+#
+# You should have received a copy of the Open Software License along
+# with this program; if not, you may obtain a copy of the Open Software
+# License version 1.0 from http://www.opensource.org/licenses/osl.php or
+# by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
+# 3001 King Ranch Road, Ukiah, CA 95482.
+
+# This file is sourced by ". $srcdir/test-subr.sh" at the start of
+# each test script.  It defines some functions they use and sets up
+# canonical sh state for test runs.
+
+set -e
+
+remove_files=
+trap 'rm -f $remove_files' 0
+
+tempfiles()
+{
+  remove_files="$remove_files $*"
+}
+
+testfiles()
+{
+  for file; do
+    bunzip2 -c $srcdir/${file}.bz2 > ${file} 2>/dev/null || exit 77
+    remove_files="$remove_files $file"
+  done
+}
+
+testrun_out()
+{
+  outfile="$1"
+  shift
+  remove_files="$remove_files $outfile"
+  testrun "$@" > $outfile 2>&1 || :
+}
+
+testrun_compare()
+{
+  outfile="${1##*/}.out"
+  testrun_out $outfile "$@"
+  diff -Bbu $outfile -
+  # diff's exit status will kill the script.
+}
+
+test_cleanup()
+{
+  rm -f $remove_files
+  remove_files=
+}
+
+# See test-wrapper.sh, which sets the environment for this.
+testrun()
+{
+  ${elfutils_testrun}_testrun "$@"
+}
+
+built_testrun()
+{
+  LD_LIBRARY_PATH="${built_library_path}${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"\
+  "$@"
+}
+
+installed_testrun()
+{
+  program="$1"
+  shift
+  case "$program" in
+  ./*)
+    if [ "x$elfutils_tests_rpath" != xno ]; then
+      echo >&2 installcheck not possible with --enable-tests-rpath
+      exit 77
+    fi
+    ;;
+  ../*)
+    program=`program_transform ${program##*/}`
+    ;;
+  esac
+  $program ${1+"$@"}
+}
+
+program_transform()
+{
+  echo "$*" | sed "${program_transform_name}"
+}
diff --git a/tests/test-wrapper.sh b/tests/test-wrapper.sh
new file mode 100755 (executable)
index 0000000..2abcc74
--- /dev/null
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 2005 Red Hat, Inc.
+#
+# This program is Open Source software; you can redistribute it and/or
+# modify it under the terms of the Open Software License version 1.0 as
+# published by the Open Source Initiative.
+#
+# You should have received a copy of the Open Software License along
+# with this program; if not, you may obtain a copy of the Open Software
+# License version 1.0 from http://www.opensource.org/licenses/osl.php or
+# by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
+# 3001 King Ranch Road, Ukiah, CA 95482.
+
+# We don't compile in an rpath because we want "make installcheck" to
+# use the installed libraries.  So for local test runs we need to point
+# the library path at this build.
+
+# This wrapper script is called by the makefile, in one of two ways:
+#      $(srcdir)/test-wrapper.sh ../libelf:... run-test.sh ...
+# or:
+#      $(srcdir)/test-wrapper.sh installed s,^,eu-, run-test.sh ...
+
+if [ "$1" = installed ]; then
+  shift
+  elfutils_tests_rpath=$1
+  shift
+  program_transform_name="$1"
+  shift
+  elfutils_testrun=installed
+else
+  built_library_path="$1"
+  shift
+  elfutils_testrun=built
+fi
+
+case "$1" in
+*.sh)
+  export built_library_path program_transform_name elfutils_testrun
+  export elfutils_tests_rpath
+  ;;
+*)
+  if [ $elfutils_testrun = built ]; then
+    LD_LIBRARY_PATH="$built_library_path${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
+    export LD_LIBRARY_PATH
+  elif [ $elfutils_tests_rpath = yes ]; then
+    echo >&2 installcheck not possible with --enable-tests-rpath
+    exit 77
+  fi
+  ;;
+esac
+
+exec "$@"