This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi, I'd like to extend elfutils testsuite, so I've examined lcov coverage report and picked up a function from libdw, dwarf_getstring(), which had coverage 0%, with this test it is 100% covered. The .c and .sh files are attached. Tested on x86_64. What do you folks think, is it sufficient? Any comments or suggestions are very welcome. Thanks, Marek tests/ChangeLog: 2011-03-02 Marek Polacek <mpolacek@redhat.com> * dwarf-getstring.c: New test. * run-dwarf-getstring.sh: And its wrapper. * Makefile.am (EXTRA_DIST): Add and update all. diff -d -urpN src/elfutils/tests/Makefile.am rpmbuild/BUILD/elfutils-0.152/tests/Makefile.am --- src/elfutils/tests/Makefile.am 2011-02-28 14:59:12.189848145 +0100 +++ rpmbuild/BUILD/elfutils-0.152/tests/Makefile.am 2011-03-02 20:56:30.089749019 +0100 @@ -57,7 +57,7 @@ noinst_PROGRAMS = arextract arsymtest ne dwfl-bug-addr-overflow arls dwfl-bug-fd-leak \ dwfl-addr-sect dwfl-bug-report early-offscn \ dwfl-bug-getmodules dwarf-getmacros addrcfi \ - test-flag-nobits + test-flag-nobits dwarf-getstring asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \ asm-tst6 asm-tst7 asm-tst8 asm-tst9 @@ -83,7 +83,8 @@ TESTS = run-arextract.sh run-arsymtest.s run-dwfl-bug-offline-rel.sh run-dwfl-addr-sect.sh \ run-disasm-x86.sh run-disasm-x86-64.sh \ run-early-offscn.sh run-dwarf-getmacros.sh \ - run-test-flag-nobits.sh run-prelink-addr-test.sh + run-test-flag-nobits.sh run-prelink-addr-test.sh \ + run-dwarf-getstring.sh # run-show-ciefde.sh if !STANDALONE @@ -117,6 +118,7 @@ EXTRA_DIST = run-arextract.sh run-arsymt run-addrname-test.sh run-dwfl-bug-offline-rel.sh \ run-dwfl-addr-sect.sh run-early-offscn.sh \ run-dwarf-getmacros.sh run-test-flag-nobits.sh \ + run-dwarf-getstring.sh \ testfile15.bz2 testfile15.debug.bz2 \ testfile16.bz2 testfile16.debug.bz2 \ testfile17.bz2 testfile17.debug.bz2 \ @@ -246,6 +248,7 @@ dwfl_bug_getmodules_LDADD = $(libdw) $(l dwfl_addr_sect_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl sha1_tst_LDADD = $(libeu) $(libmudflap) dwarf_getmacros_LDADD = $(libdw) $(libmudflap) +dwarf_getstring_LDADD = $(libdw) $(libmudflap) addrcfi_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl test_flag_nobits_LDADD = $(libelf) $(libmudflap)
/* Copyright (C) 2011 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Marek Polacek <mpolacek@redhat.com>, 2011. 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>. */ #ifdef HAVE_CONFIG_H # include <config.h> #endif #include ELFUTILS_HEADER(dwfl) #include <assert.h> #include <dwarf.h> #include <fcntl.h> #include <stdio.h> #include <unistd.h> int main (int argc, char *argv[]) { int cnt; for (cnt = 1; cnt < argc; ++cnt) { Dwarf_Off offset = 0; size_t len; int fd = open64 (argv[cnt], O_RDONLY); if (fd == -1) { printf ("cannot open '%s': %m\n", argv[cnt]); return 1; } Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ); if (dbg == NULL) { printf ("%s not usable: %s\n", argv[cnt], dwarf_errmsg (-1)); close (fd); return 1; } /* Try to use NULL Dwarf object. */ const char *str = dwarf_getstring (NULL, offset, &len); assert (str == NULL); /* Use insane offset. */ str = dwarf_getstring (dbg, ~0UL, &len); assert (str == NULL); /* Now do some real work. */ for (int i = 0; i < 100; ++i) { str = dwarf_getstring (dbg, offset, &len); puts (str); /* Advance. */ offset += len + 1; } close (fd); } return 0; }
Attachment:
run-dwarf-getstring.sh
Description: application/shellscript
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |