]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
tests: Add run-readelf-unknown-self.sh test to check for unknown DWARF codes.
authorMark Wielaard <mjw@redhat.com>
Wed, 1 Aug 2012 13:48:18 +0000 (15:48 +0200)
committerMark Wielaard <mjw@redhat.com>
Thu, 16 Aug 2012 20:26:23 +0000 (22:26 +0200)
Signed-off-by: Mark Wielaard <mjw@redhat.com>
tests/ChangeLog
tests/Makefile.am
tests/run-readelf-unknown-self.sh [new file with mode: 0755]
tests/test-subr.sh

index 24ba17e6b169ff43e9d0bd4b90a7adaba034f606..8ca08ea6240197ae696c82a87108bcd20475df6e 100644 (file)
@@ -1,3 +1,9 @@
+2012-07-19  Mark Wielaard  <mjw@redhat.com>
+
+       * run-readelf-unknown-self.sh: New test.
+       * Makefile.am (TESTS): Add run-readelf-unknown-self.sh.
+       (EXTRA_DIST): Likewise.
+
 2012-07-27  Mark Wielaard  <mjw@redhat.com>
 
        * allregs.c (dwarf_encoding_string): Removed.
index df66db6ee9f0d2c9ae94895b96f5f9af1a516561..05705698a0301c4ecd7cbff71ae2cdc942655862 100644 (file)
@@ -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 (executable)
index 0000000..edb1741
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+. $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
index ff29136fb97c100074e7540b0414334656b89bc5..e05d22a525c97f7c03d8f495e2562b6db3cdeee5 100644 (file)
@@ -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
+}