diff options
author | Roland McGrath <roland@redhat.com> | 2005-11-16 01:33:38 +0000 |
---|---|---|
committer | Roland McGrath <roland@redhat.com> | 2005-11-16 01:33:38 +0000 |
commit | 1b8b446a794ac4babfd687ca48de32e5f4aaa539 (patch) | |
tree | b619a87dfff2b1fb667778f2699daa29a77f74c3 | |
parent | fd856b5865368a894c178be0d2ad7285db5b3150 (diff) | |
download | elfutils-1b8b446a794ac4babfd687ca48de32e5f4aaa539.tar.gz |
2005-11-15 Roland McGrath <roland@redhat.com>
* 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.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | tests/ChangeLog | 41 | ||||
-rw-r--r-- | tests/Makefile.am | 22 | ||||
-rwxr-xr-x | tests/run-addrscopes.sh | 23 | ||||
-rwxr-xr-x | tests/run-allfcts.sh | 17 | ||||
-rwxr-xr-x | tests/run-ecp-test.sh | 10 | ||||
-rwxr-xr-x | tests/run-ecp-test2.sh | 10 | ||||
-rwxr-xr-x | tests/run-elflint-self.sh | 6 | ||||
-rwxr-xr-x | tests/run-elflint-test.sh | 12 | ||||
-rwxr-xr-x | tests/run-find-prologues.sh | 43 | ||||
-rwxr-xr-x | tests/run-funcscopes.sh | 12 | ||||
-rwxr-xr-x | tests/run-get-aranges.sh | 14 | ||||
-rwxr-xr-x | tests/run-get-files.sh | 14 | ||||
-rwxr-xr-x | tests/run-get-lines.sh | 14 | ||||
-rwxr-xr-x | tests/run-get-pubnames.sh | 14 | ||||
-rwxr-xr-x | tests/run-line2addr.sh | 41 | ||||
-rwxr-xr-x | tests/run-ranlib-test.sh | 9 | ||||
-rwxr-xr-x | tests/run-ranlib-test2.sh | 13 | ||||
-rwxr-xr-x | tests/run-show-abbrev.sh | 14 | ||||
-rwxr-xr-x | tests/run-show-ciefde.sh | 14 | ||||
-rwxr-xr-x | tests/run-show-die-info.sh | 14 | ||||
-rwxr-xr-x | tests/run-strings-test.sh | 18 | ||||
-rwxr-xr-x | tests/run-strip-test.sh | 25 | ||||
-rw-r--r-- | tests/test-subr.sh | 91 | ||||
-rwxr-xr-x | tests/test-wrapper.sh | 52 |
26 files changed, 319 insertions, 233 deletions
@@ -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__]: diff --git a/configure.ac b/configure.ac index c2140e26..3d30a031 100644 --- a/configure.ac +++ b/configure.ac @@ -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], diff --git a/tests/ChangeLog b/tests/ChangeLog index 2c5fc164..6243ff42 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -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. diff --git a/tests/Makefile.am b/tests/Makefile.am index 01d7b6ad..0a80f634 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 diff --git a/tests/run-addrscopes.sh b/tests/run-addrscopes.sh index d1e89cc8..e1ac7b8e 100755 --- a/tests/run-addrscopes.sh +++ b/tests/run-addrscopes.sh @@ -10,15 +10,11 @@ # 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 diff --git a/tests/run-allfcts.sh b/tests/run-allfcts.sh index 3fde34b9..5ca342e4 100755 --- a/tests/run-allfcts.sh +++ b/tests/run-allfcts.sh @@ -11,20 +11,11 @@ # 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 diff --git a/tests/run-ecp-test.sh b/tests/run-ecp-test.sh index c21bb6ca..aee8b9c5 100755 --- a/tests/run-ecp-test.sh +++ b/tests/run-ecp-test.sh @@ -11,15 +11,13 @@ # 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 diff --git a/tests/run-ecp-test2.sh b/tests/run-ecp-test2.sh index 8f3775be..2f8ce07f 100755 --- a/tests/run-ecp-test2.sh +++ b/tests/run-ecp-test2.sh @@ -11,13 +11,11 @@ # 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 diff --git a/tests/run-elflint-self.sh b/tests/run-elflint-self.sh index df7678ab..123cfe04 100755 --- a/tests/run-elflint-self.sh +++ b/tests/run-elflint-self.sh @@ -11,15 +11,13 @@ # 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 } diff --git a/tests/run-elflint-test.sh b/tests/run-elflint-test.sh index 74727b66..8d8e353c 100755 --- a/tests/run-elflint-test.sh +++ b/tests/run-elflint-test.sh @@ -11,18 +11,12 @@ # 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 diff --git a/tests/run-find-prologues.sh b/tests/run-find-prologues.sh index 3e43fc53..56d2819a 100755 --- a/tests/run-find-prologues.sh +++ b/tests/run-find-prologues.sh @@ -10,24 +10,18 @@ # 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 diff --git a/tests/run-funcscopes.sh b/tests/run-funcscopes.sh index e0dcfae1..4d365723 100755 --- a/tests/run-funcscopes.sh +++ b/tests/run-funcscopes.sh @@ -10,21 +10,15 @@ # 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 diff --git a/tests/run-get-aranges.sh b/tests/run-get-aranges.sh index a816c218..8bcb2c90 100755 --- a/tests/run-get-aranges.sh +++ b/tests/run-get-aranges.sh @@ -11,17 +11,11 @@ # 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 diff --git a/tests/run-get-files.sh b/tests/run-get-files.sh index e80cf68d..afeac22d 100755 --- a/tests/run-get-files.sh +++ b/tests/run-get-files.sh @@ -11,17 +11,11 @@ # 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 diff --git a/tests/run-get-lines.sh b/tests/run-get-lines.sh index 2f7f8580..d7dc0c81 100755 --- a/tests/run-get-lines.sh +++ b/tests/run-get-lines.sh @@ -11,17 +11,11 @@ # 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 diff --git a/tests/run-get-pubnames.sh b/tests/run-get-pubnames.sh index 4c9d5c2a..35cbfae5 100755 --- a/tests/run-get-pubnames.sh +++ b/tests/run-get-pubnames.sh @@ -11,17 +11,11 @@ # 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 diff --git a/tests/run-line2addr.sh b/tests/run-line2addr.sh index 91047c27..0e57b891 100755 --- a/tests/run-line2addr.sh +++ b/tests/run-line2addr.sh @@ -11,45 +11,34 @@ # 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 diff --git a/tests/run-ranlib-test.sh b/tests/run-ranlib-test.sh index 868e728e..0397f056 100755 --- a/tests/run-ranlib-test.sh +++ b/tests/run-ranlib-test.sh @@ -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 diff --git a/tests/run-ranlib-test2.sh b/tests/run-ranlib-test2.sh index 6eb62f2e..3693eb5e 100755 --- a/tests/run-ranlib-test2.sh +++ b/tests/run-ranlib-test2.sh @@ -11,19 +11,14 @@ # 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 diff --git a/tests/run-show-abbrev.sh b/tests/run-show-abbrev.sh index 0d0ff60c..97743b69 100755 --- a/tests/run-show-abbrev.sh +++ b/tests/run-show-abbrev.sh @@ -11,17 +11,11 @@ # 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 diff --git a/tests/run-show-ciefde.sh b/tests/run-show-ciefde.sh index ac97bbb3..fe0a5a91 100755 --- a/tests/run-show-ciefde.sh +++ b/tests/run-show-ciefde.sh @@ -11,17 +11,11 @@ # 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 diff --git a/tests/run-show-die-info.sh b/tests/run-show-die-info.sh index 3cdfae50..c730c1ec 100755 --- a/tests/run-show-die-info.sh +++ b/tests/run-show-die-info.sh @@ -11,17 +11,11 @@ # 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 diff --git a/tests/run-strings-test.sh b/tests/run-strings-test.sh index 66918008..06e52e06 100755 --- a/tests/run-strings-test.sh +++ b/tests/run-strings-test.sh @@ -11,20 +11,12 @@ # 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 diff --git a/tests/run-strip-test.sh b/tests/run-strip-test.sh index 169e8929..7a5a52a5 100755 --- a/tests/run-strip-test.sh +++ b/tests/run-strip-test.sh @@ -11,41 +11,28 @@ # 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 index 00000000..6ad31edb --- /dev/null +++ b/tests/test-subr.sh @@ -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 index 00000000..2abcc74e --- /dev/null +++ b/tests/test-wrapper.sh @@ -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 "$@" |