summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoland McGrath <[email protected]>2005-12-13 23:24:37 +0000
committerRoland McGrath <[email protected]>2005-12-13 23:24:37 +0000
commit94d26ad7385888b46e75dc1949ff7e424288c00d (patch)
treedb1040d6a381ca88a01ea13bcf3e806365136b13 /tests
parentdec3a24331194d06145b28011336d121c3440ac7 (diff)
2005-12-13 Roland McGrath <[email protected]>
* allregs.c (main): Fail if we find no registers. * run-native-test.sh: New file. * Makefile.am (TESTS, EXTRA_DIST): Add it.
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog7
-rw-r--r--tests/Makefile.am5
-rw-r--r--tests/allregs.c10
-rwxr-xr-xtests/run-native-test.sh58
4 files changed, 73 insertions, 7 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index d2e38759..4cc42b85 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,10 @@
+2005-12-13 Roland McGrath <[email protected]>
+
+ * 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 <[email protected]
* run-readelf-test1.sh: New file.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4da3bed4..dbd68470 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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 \
diff --git a/tests/allregs.c b/tests/allregs.c
index c00b86a3..014c80cb 100644
--- a/tests/allregs.c
+++ b/tests/allregs.c
@@ -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
index 00000000..c9126c61
--- /dev/null
+++ b/tests/run-native-test.sh
@@ -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