tests: Add run-nm-self.sh and run-readelf-self.sh tests.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 0f8d10f..8c2547c 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,5 +1,13 @@
 2012-08-01  Mark Wielaard  <mjw@redhat.com>
 
+	* run-nm-self.sh: New test.
+	* run-readelf-self.sh: Likewise.
+	* test-subr.sh (testrun_on_self_quiet): New function.
+	* Makefile.am (TESTS): Add run-nm-self.sh and run-readelf-self.sh.
+	(EXTRA_DIST): Likewise.
+
+2012-08-01  Mark Wielaard  <mjw@redhat.com>
+
 	* test-subr.sh (self_test_files): New list of files.
 	(testrun_on_self): New function.
 	* run-elflint-self.sh: Use testrun_on_self.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a8b0f16..0615869 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -70,6 +70,7 @@
 	run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \
 	run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \
 	run-find-prologues.sh run-allregs.sh \
+	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 \
@@ -113,6 +114,7 @@
 	     run-elflint-self.sh run-ranlib-test.sh run-ranlib-test2.sh \
 	     run-ranlib-test3.sh run-ranlib-test4.sh \
 	     run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \
+	     run-nm-self.sh run-readelf-self.sh \
 	     run-find-prologues.sh run-allregs.sh run-native-test.sh \
 	     run-addrname-test.sh run-dwfl-bug-offline-rel.sh \
 	     run-dwfl-addr-sect.sh run-early-offscn.sh \
diff --git a/tests/run-nm-self.sh b/tests/run-nm-self.sh
new file mode 100755
index 0000000..0fe0ec6
--- /dev/null
+++ b/tests/run-nm-self.sh
@@ -0,0 +1,26 @@
+#! /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
+
+for what_arg in --debug-syms --defined-only --dynamic --extern-only; do
+  for format_arg in --format=bsd --format=sysv --format=posix; do
+    for out_arg in --numeric-sort --no-sort --reverse-sort; do
+      testrun_on_self_quiet ../src/nm $what_arg $format_arg $out_arg
+    done
+  done
+done
diff --git a/tests/run-readelf-self.sh b/tests/run-readelf-self.sh
new file mode 100755
index 0000000..4602712
--- /dev/null
+++ b/tests/run-readelf-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 <http://www.gnu.org/licenses/>.
+
+. $srcdir/test-subr.sh
+
+# Just makes sure readelf doesn't crash
+testrun_on_self_quiet ../src/readelf -a -w
diff --git a/tests/test-subr.sh b/tests/test-subr.sh
index 5621cf1..ff29136 100644
--- a/tests/test-subr.sh
+++ b/tests/test-subr.sh
@@ -115,8 +115,22 @@
   exit_status=0
 
   for file in $self_test_files; do
-      testrun "$@" $file \
-	  || { echo "*** failure in $@ $file"; exit_status=1; }
+      testrun $* $file \
+	  || { echo "*** failure in $* $file"; exit_status=1; }
+  done
+
+  # Only exit if something failed
+  if test $exit_status != 0; then exit $exit_status; fi
+}
+
+# Same as above, but redirects stdout to /dev/null
+testrun_on_self_quiet()
+{
+  exit_status=0
+
+  for file in $self_test_files; do
+      testrun $* $file > /dev/null \
+	  || { echo "*** failure in $* $file"; exit_status=1; }
   done
 
   # Only exit if something failed