From 33ba099be73c8de32a8fab15fdd75ed320219c17 Mon Sep 17 00:00:00 2001 From: Antoine Busque Date: Mon, 28 Sep 2015 06:01:52 -0400 Subject: [PATCH] Tests: add unit tests for bt_dwarf MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Antoine Busque Signed-off-by: Jérémie Galarneau --- .gitignore | 1 + tests/Makefile.am | 6 ++ tests/debuginfo-data/libhello.so | Bin 0 -> 40456 bytes tests/lib/Makefile.am | 11 ++++ tests/lib/test_dwarf.c | 107 +++++++++++++++++++++++++++++++ tests/lib/test_dwarf_complete | 22 +++++++ tests/tests_debuginfo | 1 + 7 files changed, 148 insertions(+) create mode 100644 tests/debuginfo-data/libhello.so create mode 100644 tests/lib/test_dwarf.c create mode 100755 tests/lib/test_dwarf_complete create mode 100644 tests/tests_debuginfo diff --git a/.gitignore b/.gitignore index e357e204..0548058e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ /tests/lib/test_bt_objects /tests/lib/test_bt_values /tests/lib/test_ctf_ir_ref +/tests/lib/test_durin *.o *.a *.la diff --git a/tests/Makefile.am b/tests/Makefile.am index 507b1ba4..56e93c11 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,9 @@ SUBDIRS = utils bin lib EXTRA_DIST = $(srcdir)/ctf-traces/** tests +if ENABLE_DEBUGINFO +EXTRA_DIST += $(srcdir)/debuginfo-data/** tests_debuginfo +endif SCRIPT_LIST = run.sh @@ -22,3 +25,6 @@ clean-local: check-am: ./run.sh $(srcdir)/tests +if ENABLE_DEBUGINFO + ./run.sh $(srcdir)/tests_debuginfo +endif diff --git a/tests/debuginfo-data/libhello.so b/tests/debuginfo-data/libhello.so new file mode 100644 index 0000000000000000000000000000000000000000..f0a93e5acf0965f5b5018e3fc7a1709bcb534288 GIT binary patch literal 40456 zcmeHw3w&Hf+4r11+2m}KY_?4=Nw3>BZNsH$TH268OVg%-E%XvgD+PtkCfP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xu^s}#Re ze+3qeh-e(a2JoC=5B2v0bpForw}F`WmoXQXue~y&L%%98@#E1W&3;{g5eXir`O@EO z&>?>2nsQNI_6xtTNa5G({5m{hCq`Va=jaeW6Hei;QV1PZI3AWXpBB5_!LPqBp+jX( zP0qGTBoMh(@h9qUs>JGjhPNFB_Dgi){&B>}ehL1W5~cSes$?>8_a|a9asYvye?al; z@Pvcjp^o^jgJ17!=I7*K8A1$^Y5ptOXncmMRmlUNkNZg(LPXR+)JDOkbla!tz z|55N#`8B`ZPpMV>&itI|Upx5qzDu3r?{*l>4|@CcDiY-TI)A-CGcaFL(f2Fq(qeS} zJ_#1I?rhgz@8cX%FKeh$bUM)dIy~jz_o?4<`_7jf)IRN(=F=hlOwOLa-WS@h_&e;( zi2EJs90$K%|M6E!LTCO?{xJ@Iy`H#N@oPKjY_;AxT?&4JY5Vu9^``@h|EMNZq2H0F zmu%xd-cOo(X?{od!L&q4Jaknkewj+%?^F5LB|#k1d>ULc41e)LNwKL!Q_9fE|Gr`P zKX$dG@5j2a{c`dLhv8q-Ah~|59ajl)@?WR;o%Wm9EE&$jTYK!6=GWmS#c!vf_?jCf zq)rBjyXMmXsvlkV8b;wa75{bzgCoiHsQX?!eI}qb4?z205g~EW_>d|8 QS{fK|RnnkoyPWy|AA{drVE_OC literal 0 HcmV?d00001 diff --git a/tests/lib/Makefile.am b/tests/lib/Makefile.am index f1efac69..13df7157 100644 --- a/tests/lib/Makefile.am +++ b/tests/lib/Makefile.am @@ -46,6 +46,17 @@ SCRIPT_LIST = test_seek_big_trace \ test_ctf_writer_complete EXTRA_DIST = test_seek_big_trace.in test_seek_empty_packet.in +if ENABLE_DEBUGINFO +test_dwarf_LDFLAGS = -static +test_dwarf_LDADD = $(LIBTAP) \ + $(top_builddir)/lib/libbabeltrace.la \ + $(top_builddir)/lib/libdebuginfo.la +test_dwarf_SOURCES = test_dwarf.c + +noinst_PROGRAMS += test_dwarf +SCRIPT_LIST += test_dwarf_complete +endif + dist_noinst_SCRIPTS = $(SCRIPT_LIST) all-local: diff --git a/tests/lib/test_dwarf.c b/tests/lib/test_dwarf.c new file mode 100644 index 00000000..cee2d446 --- /dev/null +++ b/tests/lib/test_dwarf.c @@ -0,0 +1,107 @@ +/* + * test_dwarf.c + * + * Babeltrace bt_dwarf (DWARF utilities) tests + * + * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation + * Copyright (c) 2015 Antoine Busque + * + * This program 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; under version 2 of the License. + * + * This program 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include +#include +#include +#include +#include "tap/tap.h" + +#define NR_TESTS 15 + +static +void test_bt_dwarf(const char *data_dir) +{ + int fd, ret, tag; + char path[PATH_MAX]; + char *die_name = NULL; + struct bt_dwarf_cu *cu = NULL; + struct bt_dwarf_die *die = NULL; + Dwarf *dwarf_info = NULL; + + snprintf(path, PATH_MAX, "%s/libhello.so", data_dir); + + fd = open(path, O_RDONLY); + ok(fd >= 0, "Open DWARF file %s", path); + dwarf_info = dwarf_begin(fd, DWARF_C_READ); + ok(dwarf_info != NULL, "dwarf_begin successful"); + cu = bt_dwarf_cu_create(dwarf_info); + ok(cu != NULL, "bt_dwarf_cu_create successful"); + ret = bt_dwarf_cu_next(cu); + ok(ret == 0, "bt_dwarf_cu_next successful"); + die = bt_dwarf_die_create(cu); + ok(die != NULL, "bt_dwarf_die_create successful"); + /* + * Test bt_dwarf_die_next twice, as the code path is different + * for DIEs at depth 0 (just created) and other depths. + */ + ret = bt_dwarf_die_next(die); + ok(ret == 0, "bt_dwarf_die_next from root DIE successful"); + ok(die->depth == 1, + "bt_dwarf_die_next from root DIE - correct depth value"); + ret = bt_dwarf_die_next(die); + ok(ret == 0, + "bt_dwarf_die_next from non-root DIE successful"); + ok(die->depth == 1, + "bt_dwarf_die_next from non-root DIE - correct depth value"); + + /* Reset DIE to test dwarf_child */ + bt_dwarf_die_destroy(die); + die = bt_dwarf_die_create(cu); + + ret = bt_dwarf_die_child(die); + ok(ret == 0, "bt_dwarf_die_child successful"); + ok(die->depth == 1, "bt_dwarf_die_child - correct depth value"); + + ret = bt_dwarf_die_get_tag(die, &tag); + ok(ret == 0, "bt_dwarf_die_get_tag successful"); + ok(tag == DW_TAG_typedef, "bt_dwarf_die_get_tag - correct tag value"); + ret = bt_dwarf_die_get_name(die, &die_name); + ok(ret == 0, "bt_dwarf_die_get_name successful"); + ok(strcmp(die_name, "size_t") == 0, + "bt_dwarf_die_get_name - correct name value"); + + bt_dwarf_die_destroy(die); + bt_dwarf_cu_destroy(cu); + dwarf_end(dwarf_info); + free(die_name); + close(fd); +} + +int main(int argc, char **argv) +{ + const char *data_dir; + + plan_tests(NR_TESTS); + + if (argc != 2) { + return EXIT_FAILURE; + } else { + data_dir = argv[1]; + } + + test_bt_dwarf(data_dir); + + return EXIT_SUCCESS; +} diff --git a/tests/lib/test_dwarf_complete b/tests/lib/test_dwarf_complete new file mode 100755 index 00000000..c6330160 --- /dev/null +++ b/tests/lib/test_dwarf_complete @@ -0,0 +1,22 @@ +#!/bin/sh +# +# Copyright (C) 2015 - Antoine Busque +# +# This program 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; only version 2 +# of the License. +# +# This program 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +CURDIR=$(dirname $0)/ +ROOTDIR=$CURDIR../.. + +$CURDIR/test_dwarf $ROOTDIR/tests/debuginfo-data diff --git a/tests/tests_debuginfo b/tests/tests_debuginfo new file mode 100644 index 00000000..0fe64513 --- /dev/null +++ b/tests/tests_debuginfo @@ -0,0 +1 @@ +lib/test_durin_complete \ No newline at end of file -- 2.34.1