From: Mark Wielaard Date: Wed, 1 Aug 2012 13:48:18 +0000 (+0200) Subject: tests: Add run-readelf-unknown-self.sh test to check for unknown DWARF codes. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f75e849377bc5a8402fb794622f22d9fd4f661be;p=thirdparty%2Felfutils.git tests: Add run-readelf-unknown-self.sh test to check for unknown DWARF codes. Signed-off-by: Mark Wielaard --- diff --git a/tests/ChangeLog b/tests/ChangeLog index 24ba17e6b..8ca08ea62 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2012-07-19 Mark Wielaard + + * run-readelf-unknown-self.sh: New test. + * Makefile.am (TESTS): Add run-readelf-unknown-self.sh. + (EXTRA_DIST): Likewise. + 2012-07-27 Mark Wielaard * allregs.c (dwarf_encoding_string): Removed. diff --git a/tests/Makefile.am b/tests/Makefile.am index df66db6ee..05705698a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -73,7 +73,8 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ run-nm-self.sh run-readelf-self.sh \ run-readelf-test1.sh run-readelf-test2.sh run-readelf-test3.sh \ run-readelf-test4.sh run-readelf-twofiles.sh \ - run-readelf-macro.sh run-readelf-dwz-multi.sh \ + run-readelf-unknown-self.sh run-readelf-macro.sh \ + run-readelf-dwz-multi.sh \ run-native-test.sh run-bug1-test.sh \ dwfl-bug-addr-overflow run-addrname-test.sh \ dwfl-bug-fd-leak dwfl-bug-report \ @@ -132,6 +133,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ coverage.sh test-subr.sh test-wrapper.sh \ run-readelf-test1.sh run-readelf-test2.sh run-readelf-test3.sh \ run-readelf-test4.sh run-readelf-twofiles.sh \ + run-readelf-unknown-self.sh \ run-bug1-test.sh testfile28.bz2 testfile28.rdwr.bz2 \ testfile29.bz2 testfile29.rdwr.bz2 \ testfile30.bz2 testfile31.bz2 testfile32.bz2 testfile33.bz2 \ diff --git a/tests/run-readelf-unknown-self.sh b/tests/run-readelf-unknown-self.sh new file mode 100755 index 000000000..edb174150 --- /dev/null +++ b/tests/run-readelf-unknown-self.sh @@ -0,0 +1,21 @@ +#! /bin/sh +# Copyright (C) 2012 Red Hat, Inc. +# This file is part of elfutils. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# elfutils is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. $srcdir/test-subr.sh + +# Make sure there are no unknown DWARF codes. +testrun_on_self_nomatch "\?\?\?\ \([x0-9]+\)|lo_user\+0x[0-9a-f]+" ../src/readelf -N -w diff --git a/tests/test-subr.sh b/tests/test-subr.sh index ff29136fb..e05d22a52 100644 --- a/tests/test-subr.sh +++ b/tests/test-subr.sh @@ -136,3 +136,31 @@ testrun_on_self_quiet() # Only exit if something failed if test $exit_status != 0; then exit $exit_status; fi } + +# Make sure the testrun doesn't contain some regular expression output. +# First argument is an egrep regular expression, the rest is the command +# to run on all self test files. +testrun_on_self_nomatch() +{ + pattern="$1" + shift + + exit_status=0 + tempfiles self_matches.in self_matches.out + + for file in $self_test_files; do + testrun "$@" $file > self_matches.in + # egrep should fail to match anything, but we also want to show + # what it matched if it doesn't fail, so save output. + grep_ok=0 + egrep -o "$pattern" < self_matches.in > self_matches.out || grep_ok=1 + if test $grep_ok == 0; then + echo "*** failure in $* $file" + sort -u self_matches.out + exit_status=1; + fi + done + + # Only exit if something failed + test $exit_status == 0 || exit $exit_status +}