diff options
| author | Ulf Hermann <[email protected]> | 2018-07-19 19:12:31 +0200 |
|---|---|---|
| committer | Ulf Hermann <[email protected]> | 2018-07-20 15:18:14 +0000 |
| commit | 75bd5fdb30346f5567b982b128689e41d5ac7f15 (patch) | |
| tree | 408f4479028fb9eeeaf2a32258de544a25e0eb5c /tests | |
| parent | 4ef620c1b74d7442c43ddb03da563639d923f0d2 (diff) | |
Refine self-test detection
There are some convenient new methods for selftests that we can hook into
to avoid repeating the same check in every test.
Change-Id: Ie12e1f90f86f3bd3f0590fef4fe0157f4bc0f59c
Reviewed-by: Christian Kandeler <[email protected]>
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/run-dwfllines.sh | 5 | ||||
| -rwxr-xr-x | tests/run-elflint-self.sh | 5 | ||||
| -rwxr-xr-x | tests/run-low_high_pc.sh | 5 | ||||
| -rwxr-xr-x | tests/run-readelf-self.sh | 5 | ||||
| -rwxr-xr-x | tests/run-strip-g.sh | 59 | ||||
| -rw-r--r-- | tests/test-subr.sh | 25 |
6 files changed, 56 insertions, 48 deletions
diff --git a/tests/run-dwfllines.sh b/tests/run-dwfllines.sh index c228d7db..b384de09 100755 --- a/tests/run-dwfllines.sh +++ b/tests/run-dwfllines.sh @@ -83,11 +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 -if ! grep -q -F '#define LIBEXT ".so"' ${abs_top_builddir}/config.h; then - echo "self tests only work with native ELF binaries." - exit 77 -fi - testrun_on_self_quiet ${abs_builddir}/dwfllines -e exit 0 diff --git a/tests/run-elflint-self.sh b/tests/run-elflint-self.sh index fe6b0a46..58fa7d0f 100755 --- a/tests/run-elflint-self.sh +++ b/tests/run-elflint-self.sh @@ -18,10 +18,5 @@ . $srcdir/test-subr.sh -if ! grep -q -F '#define LIBEXT ".so"' ${abs_top_builddir}/config.h; then - echo "only works with native ELF binaries." - exit 77 -fi - testrun_on_self ${abs_top_builddir}/src/elflint --quiet --gnu-ld testrun_on_self_compressed ${abs_top_builddir}/src/elflint --quiet --gnu-ld diff --git a/tests/run-low_high_pc.sh b/tests/run-low_high_pc.sh index 245a80bd..f3eebf40 100755 --- a/tests/run-low_high_pc.sh +++ b/tests/run-low_high_pc.sh @@ -29,11 +29,10 @@ testrun ${abs_builddir}/low_high_pc -e ./testfile_low_high_pc if ! grep -q -F '#define LIBEXT ".so"' ${abs_top_builddir}/config.h; then echo "self tests only work with native ELF binaries." - exit 77 +else + testrun ${abs_builddir}/low_high_pc -e ${abs_builddir}/low_high_pc fi -testrun ${abs_builddir}/low_high_pc -e ${abs_builddir}/low_high_pc - # see tests/testfile-dwarf-45.source testfiles testfile-splitdwarf-4 testfile-splitdwarf-5 testfiles testfile-hello4.dwo testfile-hello5.dwo diff --git a/tests/run-readelf-self.sh b/tests/run-readelf-self.sh index f645a148..7ffb3577 100755 --- a/tests/run-readelf-self.sh +++ b/tests/run-readelf-self.sh @@ -17,10 +17,5 @@ . $srcdir/test-subr.sh -if ! grep -q -F '#define LIBEXT ".so"' ${abs_top_builddir}/config.h; then - echo "only works with native ELF binaries." - exit 77 -fi - # Just makes sure readelf doesn't crash testrun_on_self_quiet ${abs_top_builddir}/src/readelf -a -w diff --git a/tests/run-strip-g.sh b/tests/run-strip-g.sh index fa2af157..0834c7c3 100755 --- a/tests/run-strip-g.sh +++ b/tests/run-strip-g.sh @@ -17,11 +17,6 @@ . $srcdir/test-subr.sh -if ! grep -q -F '#define LIBEXT ".so"' ${abs_top_builddir}/config.h; then - echo "only works with native ELF binaries." - exit 77 -fi - # When stripping just the debug sections/symbols we keep the symtab # in the main ELF file. There should be no symbols pointing into the # debug sections and so there should not be a copy in the debug file @@ -29,29 +24,33 @@ fi tempfiles a.out strip.out debug.out readelf.out -echo Create debug a.out. -echo "int main() { return 1; }" | gcc -g -xc - - -echo strip -g to file with debug file -testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out || - { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; } - -status=0 -testrun ${abs_top_builddir}/src/readelf -S strip.out > readelf.out -grep SYMTAB readelf.out || status=$? -echo $status -if test $status -ne 0; then - echo no symtab found in strip.out - exit 1 -fi - -status=0 -testrun ${abs_top_builddir}/src/readelf -S debug.out > readelf.out -grep SYMTAB readelf.out || status=$? -echo $status -if test $status -ne 1; then - echo symtab found in debug.out - exit 1 +if ! grep -q -F '#define LIBEXT ".so"' ${abs_top_builddir}/config.h; then + echo "only works with native ELF binaries." +else + echo Create debug a.out. + echo "int main() { return 1; }" | gcc -g -xc - + + echo strip -g to file with debug file + testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out || + { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; } + + status=0 + testrun ${abs_top_builddir}/src/readelf -S strip.out > readelf.out + grep SYMTAB readelf.out || status=$? + echo $status + if test $status -ne 0; then + echo no symtab found in strip.out + exit 1 + fi + + status=0 + testrun ${abs_top_builddir}/src/readelf -S debug.out > readelf.out + grep SYMTAB readelf.out || status=$? + echo $status + if test $status -ne 1; then + echo symtab found in debug.out + exit 1 + fi fi # arm (with data marker in .debug_frame). See tests/run-addrcfi.sh @@ -59,7 +58,7 @@ testfiles testfilearm echo arm strip -g to file with debug file testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out testfilearm || - { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; } + { echo "*** failed to strip -g -o strip.out -f debug.out testfilearm"; exit -1; } status=0 testrun ${abs_top_builddir}/src/readelf -S strip.out > readelf.out @@ -84,7 +83,7 @@ testfiles testfileaarch64 echo aarch64 strip -g to file with debug file testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out testfileaarch64 || - { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; } + { echo "*** failed to strip -g -o strip.out -f debug.out testfileaarch64"; exit -1; } status=0 testrun ${abs_top_builddir}/src/readelf -S strip.out > readelf.out diff --git a/tests/test-subr.sh b/tests/test-subr.sh index 0d11aa64..c8b279d8 100644 --- a/tests/test-subr.sh +++ b/tests/test-subr.sh @@ -136,6 +136,11 @@ testrun_on_self() { exit_status=0 + if ! grep -q -F '#define LIBEXT ".so"' ${abs_top_builddir}/config.h; then + echo "self tests only work with native ELF binaries." + return + fi + for file in $self_test_files; do testrun $* $file \ || { echo "*** failure in $* $file"; exit_status=1; } @@ -149,6 +154,11 @@ testrun_on_self_exe() { exit_status=0 + if ! grep -q -F '#define LIBEXT ".so"' ${abs_top_builddir}/config.h; then + echo "self tests only work with native ELF binaries." + return + fi + for file in $self_test_files_exe; do testrun $* $file \ || { echo "*** failure in $* $file"; exit_status=1; } @@ -162,6 +172,11 @@ testrun_on_self_lib() { exit_status=0 + if ! grep -q -F '#define LIBEXT ".so"' ${abs_top_builddir}/config.h; then + echo "self tests only work with native ELF binaries." + return + fi + for file in $self_test_files_lib; do testrun $* $file \ || { echo "*** failure in $* $file"; exit_status=1; } @@ -176,6 +191,11 @@ testrun_on_self_compressed() { exit_status=0 + if ! grep -q -F '#define LIBEXT ".so"' ${abs_top_builddir}/config.h; then + echo "self tests only work with native ELF binaries." + return + fi + for file in $self_test_files; do tempfiles ${file}z testrun ${abs_top_builddir}/src/elfcompress -f -q -o ${file}z ${file} @@ -194,6 +214,11 @@ testrun_on_self_quiet() { exit_status=0 + if ! grep -q -F '#define LIBEXT ".so"' ${abs_top_builddir}/config.h; then + echo "self tests only work with native ELF binaries." + return + fi + for file in $self_test_files; do testrun $* $file > /dev/null \ || { echo "*** failure in $* $file"; exit_status=1; } |
