summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2008-12-03 03:41:58 +0000
committerRoland McGrath <roland@redhat.com>2008-12-03 03:41:58 +0000
commita845f68bf43f90e0670ed6b33154f2aff98ad46b (patch)
tree3bc6809479ef0de95b106f0f8616ca8cb0c02cc2 /tests
parenta4c9d281616090c46ffc4fc3234d64e915008e1a (diff)
downloadelfutils-a845f68bf43f90e0670ed6b33154f2aff98ad46b.tar.gz
src/
2008-12-02 Roland McGrath <roland@redhat.com> * readelf.c (count_dwflmod, process_file): Don't presume encoding of nonzero OFFSET argument to dwfl_getmodules.
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog12
-rw-r--r--tests/Makefile.am4
-rw-r--r--tests/dwfl-bug-getmodules.c74
-rwxr-xr-xtests/run-dwfl-addr-sect.sh3
-rwxr-xr-xtests/run-strings-test.sh5
-rw-r--r--tests/test-subr.sh5
6 files changed, 95 insertions, 8 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 15e38181..b1471c1b 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,15 @@
+2008-11-26 Roland McGrath <roland@redhat.com>
+
+ * dwfl-bug-getmodules.c: New file.
+ * Makefile.am (noinst_PROGRAMS): Add it.
+ (dwfl_bug_getmodules_LDADD): New variable.
+
+2008-09-10 Roland McGrath <roland@redhat.com>
+
+ * test-subr.sh (LC_ALL): Export it set to "C".
+ * run-dwfl-addr-sect.sh: Don't do it here.
+ * run-strings-test.sh: Likewise.
+
2008-08-21 Denys Vlasenko <dvlasenk@redhat.com>
* run-addrname-test.sh: Add a new case.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f57e4328..b533521c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -59,7 +59,8 @@ noinst_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
show-abbrev hash newscn ecp dwflmodtest \
find-prologues funcretval allregs rdwrmmap \
dwfl-bug-addr-overflow arls dwfl-bug-fd-leak \
- dwfl-addr-sect dwfl-bug-report early-offscn
+ dwfl-addr-sect dwfl-bug-report early-offscn \
+ dwfl-bug-getmodules
# get-ciefde
asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
asm-tst6 asm-tst7 asm-tst8 asm-tst9
@@ -229,6 +230,7 @@ dwfl_bug_addr_overflow_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
arls_LDADD = $(libelf) $(libmudflap)
dwfl_bug_fd_leak_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
dwfl_bug_report_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
+dwfl_bug_getmodules_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
dwfl_addr_sect_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
sha1_tst_LDADD = $(libeu) $(libmudflap)
diff --git a/tests/dwfl-bug-getmodules.c b/tests/dwfl-bug-getmodules.c
new file mode 100644
index 00000000..f7042c02
--- /dev/null
+++ b/tests/dwfl-bug-getmodules.c
@@ -0,0 +1,74 @@
+/* Test program for dwfl_getmodules bug.
+ Copyright (C) 2008 Red Hat, Inc.
+ This file is part of Red Hat elfutils.
+
+ Red Hat elfutils 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; version 2 of the License.
+
+ Red Hat 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 Red Hat elfutils; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+ Red Hat elfutils is an included package of the Open Invention Network.
+ An included package of the Open Invention Network is a package for which
+ Open Invention Network licensees cross-license their patents. No patent
+ license is granted, either expressly or impliedly, by designation as an
+ included package. Should you wish to participate in the Open Invention
+ Network licensing program, please visit www.openinventionnetwork.com
+ <http://www.openinventionnetwork.com>. */
+
+#include <config.h>
+#include ELFUTILS_HEADER(dwfl)
+
+#include <error.h>
+
+static const Dwfl_Callbacks callbacks =
+ {
+ .find_elf = dwfl_linux_proc_find_elf,
+ .find_debuginfo = dwfl_standard_find_debuginfo,
+ };
+
+static int
+iterate (Dwfl_Module *mod __attribute__ ((unused)),
+ void **userdata __attribute__ ((unused)),
+ const char *name __attribute__ ((unused)),
+ Dwarf_Addr base, void *arg)
+{
+ if (base != 0x2000)
+ return DWARF_CB_OK;
+
+ if (dwfl_addrmodule (arg, 0x2100) == NULL)
+ error (1, 0, "dwfl_addrmodule: %s", dwfl_errmsg (-1));
+
+ return DWARF_CB_ABORT;
+}
+
+int
+main (void)
+{
+ Dwfl *dwfl = dwfl_begin (&callbacks);
+
+ dwfl_report_module (dwfl, "m1", 0, 0x1000);
+ dwfl_report_module (dwfl, "m2", 0x2000, 0x3000);
+ dwfl_report_module (dwfl, "m3", 0x4000, 0x5000);
+
+ dwfl_report_end (dwfl, NULL, NULL);
+
+ ptrdiff_t offset = dwfl_getmodules (dwfl, &iterate, dwfl, 0);
+ if (offset <= 0)
+ error (1, 0, "dwfl_getmodules: %s", dwfl_errmsg (-1));
+
+ offset = dwfl_getmodules (dwfl, &iterate, NULL, offset);
+ if (offset != 0)
+ error (1, 0, "dwfl_getmodules (%d): %s", (int) offset, dwfl_errmsg (-1));
+
+ dwfl_end (dwfl);
+
+ return 0;
+}
diff --git a/tests/run-dwfl-addr-sect.sh b/tests/run-dwfl-addr-sect.sh
index 69280f58..98666f37 100755
--- a/tests/run-dwfl-addr-sect.sh
+++ b/tests/run-dwfl-addr-sect.sh
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2007 Red Hat, Inc.
+# Copyright (C) 2007, 2008 Red Hat, Inc.
# This file is part of Red Hat elfutils.
#
# Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -27,7 +27,6 @@
testfiles testfile43
-export LC_ALL=C
testrun_compare ./dwfl-addr-sect -e testfile43 0x64 0x8 0x98 <<\EOF
address 0x64 => module "" section 4 + 0
address 0x8 => module "" section 1 + 0x8
diff --git a/tests/run-strings-test.sh b/tests/run-strings-test.sh
index cfd9d236..a5dac634 100755
--- a/tests/run-strings-test.sh
+++ b/tests/run-strings-test.sh
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2005, 2006 Red Hat, Inc.
+# Copyright (C) 2005, 2006, 2008 Red Hat, Inc.
# This file is part of Red Hat elfutils.
# Written by Ulrich Drepper <drepper@redhat.com>, 2005.
#
@@ -29,9 +29,6 @@
files="testfile `seq 2 9 | while read n; do echo testfile$n; done`"
testfiles $files
-LC_ALL=C
-export LC_ALL
-
testrun_compare ../src/strings -tx -f $files <<\EOF
testfile: f4 /lib/ld-linux.so.2
testfile: 1c9 __gmon_start__
diff --git a/tests/test-subr.sh b/tests/test-subr.sh
index 7fda05a0..cb34b93b 100644
--- a/tests/test-subr.sh
+++ b/tests/test-subr.sh
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2005, 2007 Red Hat, Inc.
+# Copyright (C) 2005, 2007, 2008 Red Hat, Inc.
# This file is part of Red Hat elfutils.
#
# Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -30,6 +30,9 @@
set -e
+#LC_ALL=C
+#export LC_ALL
+
remove_files=
trap 'rm -f $remove_files' 0