]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
2005-12-13 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@redhat.com>
Tue, 13 Dec 2005 23:24:37 +0000 (23:24 +0000)
committerRoland McGrath <roland@redhat.com>
Tue, 13 Dec 2005 23:24:37 +0000 (23:24 +0000)
* allregs.c (main): Fail if we find no registers.

* run-native-test.sh: New file.
* Makefile.am (TESTS, EXTRA_DIST): Add it.

tests/ChangeLog
tests/Makefile.am
tests/allregs.c
tests/run-native-test.sh [new file with mode: 0755]

index d2e38759cad2b118722cbb99375efec6110930de..4cc42b85e39cd43e95bc0e0373871d5e0930d335 100644 (file)
@@ -1,3 +1,10 @@
+2005-12-13  Roland McGrath  <roland@redhat.com>
+
+       * allregs.c (main): Fail if we find no registers.
+
+       * run-native-test.sh: New file.
+       * Makefile.am (TESTS, EXTRA_DIST): Add it.
+
 2005-12-10  Ulrich Drepper  <drepper@redhat.com
 
        * run-readelf-test1.sh: New file.
index 4da3bed4161d3f952ca8f36d974c4699b22e4a75..dbd684708e8194515d69d83689c712a6513b380b 100644 (file)
@@ -58,7 +58,8 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
        run-elflint-test.sh 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-find-prologues.sh run-allregs.sh run-readelf-test1.sh
+       run-find-prologues.sh run-allregs.sh run-readelf-test1.sh \
+       run-native-test.sh
 # run-show-ciefde.sh
 
 if !STANDALONE
@@ -86,7 +87,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
             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-find-prologues.sh run-allregs.sh \
+            run-find-prologues.sh run-allregs.sh run-native-test.sh \
             testfile15.bz2 testfile15.debug.bz2 \
             testfile16.bz2 testfile16.debug.bz2 \
             testfile17.bz2 testfile17.debug.bz2 \
index c00b86a3429549b89c5a0fa2ccf661ef4bf05e5e..014c80cbeac1a93a0c09374efccc0b355d08dfee 100644 (file)
@@ -107,7 +107,7 @@ match_register (void *arg,
   if (regno == *(int *) arg)
     printf ("%5d => %s register %s%s\n", regno, setname, prefix, regname);
 
-  return DWARF_CB_OK;
+  return DWARF_CB_ABORT;
 }
 
 
@@ -131,9 +131,9 @@ main (int argc, char **argv)
     {
       struct state state = { NULL, 0 };
       int result = dwfl_module_register_names (mod, &one_register, &state);
-      if (result != 0)
+      if (result != 0 || state.nregs == 0)
        error (EXIT_FAILURE, 0, "dwfl_module_register_names: %s",
-              dwfl_errmsg (-1));
+              result ? dwfl_errmsg (-1) : "no backend registers known");
 
       qsort (state.info, state.nregs, sizeof state.info[0], &compare);
 
@@ -156,9 +156,9 @@ main (int argc, char **argv)
        const char *arg = argv[remaining++];
        int regno = atoi (arg);
        int result = dwfl_module_register_names (mod, &match_register, &regno);
-       if (result != 0)
+       if (result != DWARF_CB_ABORT)
          error (EXIT_FAILURE, 0, "dwfl_module_register_names: %s",
-                dwfl_errmsg (-1));
+                result ? dwfl_errmsg (-1) : "no backend registers known");
       }
     while (remaining < argc);
 
diff --git a/tests/run-native-test.sh b/tests/run-native-test.sh
new file mode 100755 (executable)
index 0000000..c9126c6
--- /dev/null
@@ -0,0 +1,58 @@
+#! /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.
+
+. $srcdir/test-subr.sh
+
+# This tests all the miscellaneous components of backend support
+# against whatever this build is running on.  A platform will fail
+# this test if it is missing parts of the backend implementation.
+#
+# As new backend code is added to satisfy the test, be sure to update
+# the fixed test cases (run-allregs.sh et al) to test that backend
+# in all builds.
+
+tempfiles native.c native
+echo 'main () { while (1) pause (); }' > native.c
+
+native=0
+native_cleanup()
+{
+  test $native -eq 0 || kill -9 $native || :
+  rm -f $remove_files
+}
+trap native_cleanup 0 1 2 15
+
+for cc in "$HOSTCC" "$HOST_CC" cc gcc "$CC"; do
+  test "x$cc" != x || continue
+  $cc -o native -g native.c > /dev/null 2>&1 &&
+  ./native & native=$! &&
+  sleep 1 && kill -0 $native 2> /dev/null &&
+  break ||
+  native=0
+done
+
+native_test()
+{
+  # Try the build against itself, i.e. $config_host.
+  testrun "$@" -e $1 > /dev/null
+
+  # Try the build against a presumed native process, running this sh.
+  # For tests requiring debug information, this may not test anything.
+  testrun "$@" -p $$ > /dev/null
+
+  # Try the build against the trivial native program we just built with -g.
+  test $native -eq 0 || testrun "$@" -p $native > /dev/null
+}
+
+native_test ./allregs
+native_test ./funcretval