From 022dd2b409eb3126f414986c91db128d79f1ee9b Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Fri, 29 Apr 2016 14:35:06 -0400 Subject: [PATCH 01/16] Tests: Replace prove by autotools tap runner MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch removes the dependency on the prove perl script to run the TAP test suite. It replaces it with the autotools shell TAP driver that only requires a shell and awk. Custom arguments can be passed to the test runner with env variables as follow: env LOG_DRIVER_FLAGS='--comments --ignore-exit' \ TESTS='foo.test baz.test' make -e check This tap driver also creates a log file for each test that can then be used by another system to build a test report. Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- .gitignore | 1 + configure.ac | 2 ++ tests/Makefile.am | 41 ++++++++++++++--------------------------- tests/run.sh | 22 ---------------------- tests/tests | 7 ------- tests/tests_debuginfo | 2 -- 6 files changed, 17 insertions(+), 58 deletions(-) delete mode 100755 tests/run.sh delete mode 100644 tests/tests delete mode 100644 tests/tests_debuginfo diff --git a/.gitignore b/.gitignore index 177307d18..3bb772bef 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ .libs .deps *.bkp +*.trs ctf-lexer.c ctf-parser.c ctf-parser.h diff --git a/configure.ac b/configure.ac index 193504ac6..d2245d1af 100644 --- a/configure.ac +++ b/configure.ac @@ -15,6 +15,8 @@ AM_MAINTAINER_MODE([enable]) # Enable silent rules if available (Introduced in AM 1.11) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) +AC_REQUIRE_AUX_FILE([tap-driver.sh]) + # Checks for C compiler AC_USE_SYSTEM_EXTENSIONS AC_SYS_LARGEFILE diff --git a/tests/Makefile.am b/tests/Makefile.am index 5927f59ef..5ad2cc59e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,34 +1,21 @@ 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 - -dist_noinst_SCRIPTS = $(SCRIPT_LIST) +LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \ + $(top_srcdir)/config/tap-driver.sh -all-local: - @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ - for script in $(SCRIPT_LIST); do \ - cp -f $(srcdir)/$$script $(builddir); \ - done; \ - fi +TESTS = bin/test_trace_read \ + bin/test_trace_read \ + bin/test_packet_seq_num \ + bin/test_intersection \ + lib/test_bitfield \ + lib/test_seek_empty_packet \ + lib/test_seek_big_trace \ + lib/test_ctf_writer_complete -clean-local: - @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ - for script in $(SCRIPT_LIST); do \ - rm -f $(builddir)/$$script; \ - done; \ - fi +EXTRA_DIST = $(srcdir)/ctf-traces/** \ + $(srcdir)/debuginfo-data/** -TEMPLIST := $(shell mktemp -u) -check-am: - @cat $(srcdir)/tests > $(TEMPLIST) if ENABLE_DEBUGINFO - @echo '' >> $(TEMPLIST) - @cat $(srcdir)/tests_debuginfo >> $(TEMPLIST) +TESTS += lib/test_dwarf_complete \ + lib/test_bin_info_complete endif - ./run.sh $(TEMPLIST) - rm $(TEMPLIST) diff --git a/tests/run.sh b/tests/run.sh deleted file mode 100755 index c6c50fd9c..000000000 --- a/tests/run.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2013 - Christian Babeux -# -# 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. -# - -[ -z "$1" ] && echo "Error: No testlist. Please specify a testlist to run." && exit 1 - -prove --merge --exec '' - < $1 diff --git a/tests/tests b/tests/tests deleted file mode 100644 index 6e028df27..000000000 --- a/tests/tests +++ /dev/null @@ -1,7 +0,0 @@ -bin/test_trace_read -bin/test_packet_seq_num -bin/test_intersection -lib/test_bitfield -lib/test_seek_empty_packet -lib/test_seek_big_trace -lib/test_ctf_writer_complete \ No newline at end of file diff --git a/tests/tests_debuginfo b/tests/tests_debuginfo deleted file mode 100644 index df87fc1d5..000000000 --- a/tests/tests_debuginfo +++ /dev/null @@ -1,2 +0,0 @@ -lib/test_dwarf_complete -lib/test_bin_info_complete -- 2.34.1 From 2413cbd9bee54024ac25a44655b622bd793cb16b Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Fri, 29 Apr 2016 16:58:14 -0400 Subject: [PATCH 02/16] Use tar-ustar format for dist MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is required to support file names longuer than 99 characters when generating the dist tarball, which we require because of the sphinx theme files in the python bindings documentation. Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d2245d1af..b26e6a9c8 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,7 @@ AC_CONFIG_MACRO_DIR([m4]) AC_CANONICAL_TARGET AC_CANONICAL_HOST -AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip]) +AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip tar-ustar]) AM_MAINTAINER_MODE([enable]) # Enable silent rules if available (Introduced in AM 1.11) -- 2.34.1 From e5c8b0a6fa916208fc800c3e46378dbd0bd8b0b4 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Fri, 29 Apr 2016 17:05:31 -0400 Subject: [PATCH 03/16] Tests: Add missing debuginfo files to dist MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- tests/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 5ad2cc59e..7045aef90 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -13,7 +13,8 @@ TESTS = bin/test_trace_read \ lib/test_ctf_writer_complete EXTRA_DIST = $(srcdir)/ctf-traces/** \ - $(srcdir)/debuginfo-data/** + $(srcdir)/debuginfo-data/** \ + $(srcdir)/debuginfo-data/.build-id/cd/** if ENABLE_DEBUGINFO TESTS += lib/test_dwarf_complete \ -- 2.34.1 From 7b006b957b724087865e4244e1d1e23cfda741f5 Mon Sep 17 00:00:00 2001 From: Antoine Busque Date: Mon, 2 May 2016 15:46:48 -0400 Subject: [PATCH 04/16] Python bindings: make intersect_mode read-only property 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 --- bindings/python/babeltrace.i.in | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bindings/python/babeltrace.i.in b/bindings/python/babeltrace.i.in index 914ea87f8..a5cbcf5b8 100644 --- a/bindings/python/babeltrace.i.in +++ b/bindings/python/babeltrace.i.in @@ -141,7 +141,7 @@ class TraceCollection: def __init__(self, intersect_mode=False): self._tc = _bt_context_create() - self.intersect_mode = intersect_mode + self._intersect_mode = intersect_mode def __del__(self): _bt_context_put(self._tc) @@ -213,6 +213,10 @@ class TraceCollection: raise TypeError("in remove_trace, " "argument 2 must be a TraceHandle instance") + @property + def intersect_mode(self): + return self._intersect_mode + @property def events(self): """ @@ -232,9 +236,9 @@ class TraceCollection: """ begin_pos_ptr = _bt_python_create_iter_pos() end_pos_ptr = _bt_python_create_iter_pos() - if not self.intersection_mode: - begin_pos_ptr.type = SEEK_BEGIN - end_pos_ptr.type = SEEK_LAST + if not self.intersect_mode: + begin_pos_ptr.type = SEEK_BEGIN + end_pos_ptr.type = SEEK_LAST for event in self._events(begin_pos_ptr, end_pos_ptr): yield event -- 2.34.1 From 54d1c81f52d1f8ac081a4b06996cc69db9294ce6 Mon Sep 17 00:00:00 2001 From: Antoine Busque Date: Mon, 2 May 2016 15:50:02 -0400 Subject: [PATCH 05/16] Python bindings: add has_intersection property to TraceCollection 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 --- bindings/python/babeltrace.i.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bindings/python/babeltrace.i.in b/bindings/python/babeltrace.i.in index a5cbcf5b8..f9d2c736d 100644 --- a/bindings/python/babeltrace.i.in +++ b/bindings/python/babeltrace.i.in @@ -217,6 +217,10 @@ class TraceCollection: def intersect_mode(self): return self._intersect_mode + @property + def has_intersection(self): + return _bt_python_has_intersection(self._tc) + @property def events(self): """ @@ -289,8 +293,7 @@ class TraceCollection: def _events(self, begin_pos_ptr, end_pos_ptr): if self.intersect_mode: - has_intersection = _bt_python_has_intersection(self._tc) - if not has_intersection: + if not self.has_intersection: # There are no events to provide. return -- 2.34.1 From 8fce55a9e73a91f7bf06d04f1bf6b5f51f014e4e Mon Sep 17 00:00:00 2001 From: Antoine Busque Date: Fri, 29 Apr 2016 18:13:39 -0400 Subject: [PATCH 06/16] Tests: strip ELF symbols from debuginfo-data executables with separate DWARF MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Stripping the symbols prevents the framework from falling back to ELF lookup should the separate DWARF files be missing, which would cause tests to succeed when they should fail. Signed-off-by: Antoine Busque Signed-off-by: Jérémie Galarneau --- tests/debuginfo-data/libhello_build_id.so | Bin 22304 -> 16736 bytes tests/debuginfo-data/libhello_debug_link.so | Bin 16800 -> 16776 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/tests/debuginfo-data/libhello_build_id.so b/tests/debuginfo-data/libhello_build_id.so index 563e0ed9b69e04b1761491fc45d7692229ca69f9..a5055ee72f1d720f8039735b8023b13555412709 100644 GIT binary patch delta 250 zcmX}kze)o^7zFU0cuK&=CYUA(8$k|iEKfM|rLoTaFNIYLD@kExBjyRjc>xzBr6|6H zg}#7Q7ANR)Q}&^_yP(WvHaJG#u8W)}P^7J;Ek^E$A|+J=#V9 Lx@LfV-Zg_2qmfDd delta 4209 zcmaKvU2Gf25y$6r5=q&XOp5xl7)fMQId%*yf@4XvW1FO9Id&@9s;$BZT6BFRk1}h1 z;qGKmekj$X1qweDa@Gja^r2D_1bIjUw+UJ&Pey?PP12@rkcYkmkcyx|Qov}?JQM+n zc6N7;B2Q`$(B9r}{xiEfJG-Lbtlp3#J?8U4ar~=h7sZ`9zIF@frrl`*B}D-<5BF1zIwhT z`(1EgJX#~9UeDo63>*wKVfZnAYJku)(O-~0NqXTgo_Fz2#Q81p1xW!uCf?hnz$(!A zUy|WfGJHr59XMqXs2Wz_P2vZUYnZ3C{R%{hUy*zOUZNETh~FapeUJVg<{twMz?#Rw zUD=&p6~Vi*-af^>EBh|-RT}v37+);lE8-F2UlFhM^eggnGK5={!*7Vw!r>tC_lT!R zKTUl1J_Y>5OT@c~y92+7T!Risiedthf1HVU-ggaOQ{OHJT}Zm&D((FW>csOT@r@%< z`JJRVIpku+hiTyFr4`_1;&+LkksQbWfDB)fp+XLwttwD)nhBJM3NP*k5vVk_S;(oY06_p0}R80`SPkdgv!Mx-VSUsln z7*{@3XH^X*WnXu9 zP}iZK|7@zq&|x1$J)140Iu@C?I27Odm69Q;(czKCPuc$w7E>2Dv~b%`>%CuLFDlsJ z2ZCYV|J0)#e@Ffw*0rCwTC)$UFN9ZHl*;%jY0n}L?ra+yb8N?-HWhmadm+sCRmyjq6m!UB zPTIch_6Bc}*4-Od`!;fw(?627`zY4ESnMIsVq1}iuxwXoLXXpMCy}cyxQ@LbUNbMz zQb+(55mBb&hotb{H@96y+pE}9lYgh)`^dGneu_Pwigyp{yTl~hVcv84+L4EFsO}nL z&rDxpv*#}_Fa}xEG8glo46j;_NTQ)P6s*oucD+SXr zvtyITo{YneB9_aS^31R-W0{#H$Eqzu&N7N7%Ptj*%jnba#Zc-rXocCajEq?+=SvP# z<|Qk$#O&o_lg(B}FUy+vugh{%mdLxWd^sehjGl7D~4)=W@_|X`5V9;lv;M z`onp{8Y`?Ma$Yb?Oxk(b|5&F74f!AKWX!yQ zyM&u&7P2<~A~3ogb@M0uAzZIgE}9Or^EXX?I}qk8{&43uJQ^Ws#WE{~Wn%DxC^*|O zGS^+V0p<2TB%{HG(PSE2zr9<-xqNg_eY|qIKCj*G0E&(B_x<|SF-ivH{m*W3?Q zuYb$TWy(vU@;v!0I1cWjjHv49{|d}1R<$R>*-NRp88&m_3?4!{k?u!B#mjPZr(}IF80wbbi_adB*zZaE^<25kSN#W3 z)5Sjv9KL{eRTi=Zyb*1)NsSpy+qQ}ist#lc)vE^BGdI{Jx>ctOhHaZR|4&=wT(*F> zmN!Iy zw!h|^*xu){Qwi-4+`#rPd>z}5`6jlX^H?IG{gWHm{)?|C5-pm>|C%_};@9}2$x~Vn zHOG9F%lPM=cRPCb?SdJl L8r;PnP7VDR7bX%) diff --git a/tests/debuginfo-data/libhello_debug_link.so b/tests/debuginfo-data/libhello_debug_link.so index 8387faba048660e73c0e9242390b767c1f89d4ce..340c828eb9c45c7d391a11478a6ef43ba635871e 100644 GIT binary patch delta 585 zcmZXOzi-n(6vywStyIcb0xYOC6qTxy1)V~h_>zf%g{4ym^AfwUAwE~OQ#DhBDkMgv z?_3Epm63r3fz*warBbJ=miP+ap((jN7Gjn!XL1-rk`NpDRSXC3gItUZB4(yZEej_WnpG2f6`c< zM8}P)aE3RnCA@TI>+(@Ou8RM7j6dzwxkYIap3vfrZ_}w2bec=JsLjIb+@cGNI;(#H D``)mQ delta 542 zcmYk0y-(ag5XE;65SWHYQOI2df#MPotwIwWaCna@GDsB3AK)x^=4^7dPqz8EiUJ8? z(nNYyy3nOfMSHDjkPt0Jl!k^jN|%gn5Lsz|`(|cm-kcoKw`GV1u8`Ya;1#jmakh55JumoF zbi@O{{I=&ru@?qB*y-tf7MIy5583O#KQm!qM?&tj84pgj+u?|tco%FgJ;&8j^}TH; zk#0Nv&V}CdL_73-Cnz&QCe8uNd|g{dksg$dr3THvqt~#O6>T78 zenrOo0AoebJ}l-(q|9H)Ru-NaLWl{z`KgwVxPj4BbPKDgDx-wcrb%y+acUgKs-iPk z%+E-fbI4XzWtuQ)nw3eyx@poeQd7|mGG+~iQuG%V^A0JKkTEY|v=p7gYN^@<+vY2b x+}jTuvxOSstW~f5W=(wG6uCzX@v~JQYvxrf(o?#|i?#aL6vrb){0Dli{ttn;o(%v1 -- 2.34.1 From d4832a198f532126379f5f469f5185f1a0af8b9e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 27 Apr 2016 17:11:08 -0400 Subject: [PATCH 07/16] Typo: succesful* -> successful* MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- include/babeltrace/bin-info.h | 2 +- tests/lib/test_bin_info.c | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/babeltrace/bin-info.h b/include/babeltrace/bin-info.h index e2af89528..c94761f8f 100644 --- a/include/babeltrace/bin-info.h +++ b/include/babeltrace/bin-info.h @@ -179,7 +179,7 @@ int bin_info_lookup_function_name(struct bin_info *bin, uint64_t addr, * address within an executable. * * If no DWARF info is available, the source location cannot be found - * and the function will return unsuccesfully. + * and the function will return unsuccessfully. * * On success, if found, the out parameter `src_loc` is set. The ownership * of `src_loc` is passed to the caller. On failure, `src_loc` remains diff --git a/tests/lib/test_bin_info.c b/tests/lib/test_bin_info.c index 011b09a18..5122ed2d8 100644 --- a/tests/lib/test_bin_info.c +++ b/tests/lib/test_bin_info.c @@ -66,22 +66,22 @@ void test_bin_info_build_id(const char *data_dir) snprintf(path, PATH_MAX, "%s/%s", data_dir, SO_NAME_BUILD_ID); bin = bin_info_create(path, SO_LOW_ADDR, SO_MEMSZ, true); - ok(bin != NULL, "bin_info_create succesful"); + ok(bin != NULL, "bin_info_create successful"); /* Test setting build_id */ ret = bin_info_set_build_id(bin, build_id, BUILD_ID_LEN); - ok(ret == 0, "bin_info_set_build_id succesful"); + ok(ret == 0, "bin_info_set_build_id successful"); /* Test function name lookup (with DWARF) */ ret = bin_info_lookup_function_name(bin, FUNC_FOO_ADDR, &func_name); - ok(ret == 0, "bin_info_lookup_function_name succesful"); + ok(ret == 0, "bin_info_lookup_function_name successful"); ok(strcmp(func_name, FUNC_FOO_NAME) == 0, "bin_info_lookup_function_name - correct func_name value"); free(func_name); /* Test source location lookup */ ret = bin_info_lookup_source_location(bin, FUNC_FOO_ADDR, &src_loc); - ok(ret == 0, "bin_info_lookup_source_location succesful"); + ok(ret == 0, "bin_info_lookup_source_location successful"); ok(src_loc->line_no == FUNC_FOO_LINE_NO, "bin_info_lookup_source_location - correct line_no"); ok(strcmp(src_loc->filename, FUNC_FOO_FILENAME) == 0, @@ -107,16 +107,16 @@ void test_bin_info_debug_link(const char *data_dir) snprintf(path, PATH_MAX, "%s/%s", data_dir, SO_NAME_DEBUG_LINK); bin = bin_info_create(path, SO_LOW_ADDR, SO_MEMSZ, true); - ok(bin != NULL, "bin_info_create succesful"); + ok(bin != NULL, "bin_info_create successful"); /* Test setting debug link */ ret = bin_info_set_debug_link(bin, dbg_filename, crc); - ok(ret == 0, "bin_info_set_debug_link succesful"); + ok(ret == 0, "bin_info_set_debug_link successful"); /* Test function name lookup (with DWARF) */ ret = bin_info_lookup_function_name(bin, FUNC_FOO_ADDR_DBG_LINK, &func_name); - ok(ret == 0, "bin_info_lookup_function_name succesful"); + ok(ret == 0, "bin_info_lookup_function_name successful"); ok(strcmp(func_name, FUNC_FOO_NAME) == 0, "bin_info_lookup_function_name - correct func_name value"); free(func_name); @@ -124,7 +124,7 @@ void test_bin_info_debug_link(const char *data_dir) /* Test source location lookup */ ret = bin_info_lookup_source_location(bin, FUNC_FOO_ADDR_DBG_LINK, &src_loc); - ok(ret == 0, "bin_info_lookup_source_location succesful"); + ok(ret == 0, "bin_info_lookup_source_location successful"); ok(src_loc->line_no == FUNC_FOO_LINE_NO, "bin_info_lookup_source_location - correct line_no"); ok(strcmp(src_loc->filename, FUNC_FOO_FILENAME) == 0, @@ -148,11 +148,11 @@ void test_bin_info_elf(const char *data_dir) snprintf(path, PATH_MAX, "%s/%s", data_dir, SO_NAME_ELF); bin = bin_info_create(path, SO_LOW_ADDR, SO_MEMSZ, true); - ok(bin != NULL, "bin_info_create succesful"); + ok(bin != NULL, "bin_info_create successful"); /* Test function name lookup (with ELF) */ ret = bin_info_lookup_function_name(bin, FUNC_FOO_ADDR_ELF, &func_name); - ok(ret == 0, "bin_info_lookup_function_name succesful"); + ok(ret == 0, "bin_info_lookup_function_name successful"); ok(strcmp(func_name, FUNC_FOO_NAME_ELF) == 0, "bin_info_lookup_function_name - correct func_name value"); free(func_name); @@ -185,7 +185,7 @@ void test_bin_info(const char *data_dir) snprintf(path, PATH_MAX, "%s/%s", data_dir, SO_NAME); bin = bin_info_create(path, SO_LOW_ADDR, SO_MEMSZ, true); - ok(bin != NULL, "bin_info_create succesful"); + ok(bin != NULL, "bin_info_create successful"); /* Test bin_info_has_address */ ret = bin_info_has_address(bin, 0); @@ -201,7 +201,7 @@ void test_bin_info(const char *data_dir) /* Test function name lookup (with DWARF) */ ret = bin_info_lookup_function_name(bin, FUNC_FOO_ADDR, &func_name); - ok(ret == 0, "bin_info_lookup_function_name succesful"); + ok(ret == 0, "bin_info_lookup_function_name successful"); ok(strcmp(func_name, FUNC_FOO_NAME) == 0, "bin_info_lookup_function_name - correct func_name value"); free(func_name); @@ -214,7 +214,7 @@ void test_bin_info(const char *data_dir) /* Test source location lookup */ ret = bin_info_lookup_source_location(bin, FUNC_FOO_ADDR, &src_loc); - ok(ret == 0, "bin_info_lookup_source_location succesful"); + ok(ret == 0, "bin_info_lookup_source_location successful"); ok(src_loc->line_no == FUNC_FOO_LINE_NO, "bin_info_lookup_source_location - correct line_no"); ok(strcmp(src_loc->filename, FUNC_FOO_FILENAME) == 0, @@ -225,7 +225,7 @@ void test_bin_info(const char *data_dir) /* Test source location lookup - inlined function */ ret = bin_info_lookup_source_location(bin, FUNC_FOO_TP_ADDR, &src_loc); ok(ret == 0, - "bin_info_lookup_source_location (inlined func) succesful"); + "bin_info_lookup_source_location (inlined func) successful"); ok(src_loc->line_no == FUNC_FOO_TP_LINE_NO, "bin_info_lookup_source_location (inlined func) - correct line_no"); ok(strcmp(src_loc->filename, FUNC_FOO_TP_FILENAME) == 0, @@ -254,7 +254,7 @@ int main(int argc, char **argv) } ret = bin_info_init(); - ok(ret == 0, "bin_info_init succesful"); + ok(ret == 0, "bin_info_init successful"); test_bin_info(opt_debug_info_dir); test_bin_info_elf(opt_debug_info_dir); -- 2.34.1 From 612889660cb18982f2ceae01952112aabc09c3a7 Mon Sep 17 00:00:00 2001 From: Antoine Busque Date: Fri, 29 Apr 2016 18:12:42 -0400 Subject: [PATCH 08/16] Tests: skip certain bin-info tests on failure to prevent segfault 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 --- tests/lib/test_bin_info.c | 104 +++++++++++++++++++++++++------------- 1 file changed, 68 insertions(+), 36 deletions(-) diff --git a/tests/lib/test_bin_info.c b/tests/lib/test_bin_info.c index 5122ed2d8..0a7da604b 100644 --- a/tests/lib/test_bin_info.c +++ b/tests/lib/test_bin_info.c @@ -75,18 +75,26 @@ void test_bin_info_build_id(const char *data_dir) /* Test function name lookup (with DWARF) */ ret = bin_info_lookup_function_name(bin, FUNC_FOO_ADDR, &func_name); ok(ret == 0, "bin_info_lookup_function_name successful"); - ok(strcmp(func_name, FUNC_FOO_NAME) == 0, - "bin_info_lookup_function_name - correct func_name value"); - free(func_name); + if (func_name) { + ok(strcmp(func_name, FUNC_FOO_NAME) == 0, + "bin_info_lookup_function_name - correct func_name value"); + free(func_name); + } else { + skip(1, "bin_info_lookup_function_name - func_name is NULL"); + } /* Test source location lookup */ ret = bin_info_lookup_source_location(bin, FUNC_FOO_ADDR, &src_loc); ok(ret == 0, "bin_info_lookup_source_location successful"); - ok(src_loc->line_no == FUNC_FOO_LINE_NO, - "bin_info_lookup_source_location - correct line_no"); - ok(strcmp(src_loc->filename, FUNC_FOO_FILENAME) == 0, - "bin_info_lookup_source_location - correct filename"); - source_location_destroy(src_loc); + if (src_loc) { + ok(src_loc->line_no == FUNC_FOO_LINE_NO, + "bin_info_lookup_source_location - correct line_no"); + ok(strcmp(src_loc->filename, FUNC_FOO_FILENAME) == 0, + "bin_info_lookup_source_location - correct filename"); + source_location_destroy(src_loc); + } else { + skip(2, "bin_info_lookup_source_location - src_loc is NULL"); + } bin_info_destroy(bin); } @@ -117,19 +125,27 @@ void test_bin_info_debug_link(const char *data_dir) ret = bin_info_lookup_function_name(bin, FUNC_FOO_ADDR_DBG_LINK, &func_name); ok(ret == 0, "bin_info_lookup_function_name successful"); - ok(strcmp(func_name, FUNC_FOO_NAME) == 0, - "bin_info_lookup_function_name - correct func_name value"); - free(func_name); + if (func_name) { + ok(strcmp(func_name, FUNC_FOO_NAME) == 0, + "bin_info_lookup_function_name - correct func_name value"); + free(func_name); + } else { + skip(1, "bin_info_lookup_function_name - func_name is NULL"); + } /* Test source location lookup */ ret = bin_info_lookup_source_location(bin, FUNC_FOO_ADDR_DBG_LINK, &src_loc); ok(ret == 0, "bin_info_lookup_source_location successful"); - ok(src_loc->line_no == FUNC_FOO_LINE_NO, - "bin_info_lookup_source_location - correct line_no"); - ok(strcmp(src_loc->filename, FUNC_FOO_FILENAME) == 0, - "bin_info_lookup_source_location - correct filename"); - source_location_destroy(src_loc); + if (src_loc) { + ok(src_loc->line_no == FUNC_FOO_LINE_NO, + "bin_info_lookup_source_location - correct line_no"); + ok(strcmp(src_loc->filename, FUNC_FOO_FILENAME) == 0, + "bin_info_lookup_source_location - correct filename"); + source_location_destroy(src_loc); + } else { + skip(2, "bin_info_lookup_source_location - src_loc is NULL"); + } bin_info_destroy(bin); } @@ -153,10 +169,14 @@ void test_bin_info_elf(const char *data_dir) /* Test function name lookup (with ELF) */ ret = bin_info_lookup_function_name(bin, FUNC_FOO_ADDR_ELF, &func_name); ok(ret == 0, "bin_info_lookup_function_name successful"); - ok(strcmp(func_name, FUNC_FOO_NAME_ELF) == 0, - "bin_info_lookup_function_name - correct func_name value"); - free(func_name); - func_name = NULL; + if (func_name) { + ok(strcmp(func_name, FUNC_FOO_NAME_ELF) == 0, + "bin_info_lookup_function_name - correct func_name value"); + free(func_name); + func_name = NULL; + } else { + skip(1, "bin_info_lookup_function_name - func_name is NULL"); + } /* Test function name lookup - erroneous address */ ret = bin_info_lookup_function_name(bin, 0, &func_name); @@ -202,10 +222,14 @@ void test_bin_info(const char *data_dir) /* Test function name lookup (with DWARF) */ ret = bin_info_lookup_function_name(bin, FUNC_FOO_ADDR, &func_name); ok(ret == 0, "bin_info_lookup_function_name successful"); - ok(strcmp(func_name, FUNC_FOO_NAME) == 0, - "bin_info_lookup_function_name - correct func_name value"); - free(func_name); - func_name = NULL; + if (func_name) { + ok(strcmp(func_name, FUNC_FOO_NAME) == 0, + "bin_info_lookup_function_name - correct func_name value"); + free(func_name); + func_name = NULL; + } else { + skip(1, "bin_info_lookup_function_name - func_name is NULL"); + } /* Test function name lookup - erroneous address */ ret = bin_info_lookup_function_name(bin, 0, &func_name); @@ -215,23 +239,31 @@ void test_bin_info(const char *data_dir) /* Test source location lookup */ ret = bin_info_lookup_source_location(bin, FUNC_FOO_ADDR, &src_loc); ok(ret == 0, "bin_info_lookup_source_location successful"); - ok(src_loc->line_no == FUNC_FOO_LINE_NO, - "bin_info_lookup_source_location - correct line_no"); - ok(strcmp(src_loc->filename, FUNC_FOO_FILENAME) == 0, - "bin_info_lookup_source_location - correct filename"); - source_location_destroy(src_loc); - src_loc = NULL; + if (src_loc) { + ok(src_loc->line_no == FUNC_FOO_LINE_NO, + "bin_info_lookup_source_location - correct line_no"); + ok(strcmp(src_loc->filename, FUNC_FOO_FILENAME) == 0, + "bin_info_lookup_source_location - correct filename"); + source_location_destroy(src_loc); + src_loc = NULL; + } else { + skip(2, "bin_info_lookup_source_location - src_loc is NULL"); + } /* Test source location lookup - inlined function */ ret = bin_info_lookup_source_location(bin, FUNC_FOO_TP_ADDR, &src_loc); ok(ret == 0, "bin_info_lookup_source_location (inlined func) successful"); - ok(src_loc->line_no == FUNC_FOO_TP_LINE_NO, - "bin_info_lookup_source_location (inlined func) - correct line_no"); - ok(strcmp(src_loc->filename, FUNC_FOO_TP_FILENAME) == 0, - "bin_info_lookup_source_location (inlined func) - correct filename"); - source_location_destroy(src_loc); - src_loc = NULL; + if (src_loc) { + ok(src_loc->line_no == FUNC_FOO_TP_LINE_NO, + "bin_info_lookup_source_location (inlined func) - correct line_no"); + ok(strcmp(src_loc->filename, FUNC_FOO_TP_FILENAME) == 0, + "bin_info_lookup_source_location (inlined func) - correct filename"); + source_location_destroy(src_loc); + src_loc = NULL; + } else { + skip(2, "bin_info_lookup_source_location (inlined func) - src_loc is NULL"); + } /* Test source location lookup - erroneous address */ ret = bin_info_lookup_source_location(bin, 0, &src_loc); -- 2.34.1 From 14221de15ab3a854d57d9984c08c976ab8a70a0f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 29 Apr 2016 18:55:12 -0400 Subject: [PATCH 09/16] Add tap-driver.sh from automake MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Solaris 11's automake does not include tap-driver.sh. Signed-off-by: Jérémie Galarneau --- config/tap-driver.sh | 651 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 651 insertions(+) create mode 100755 config/tap-driver.sh diff --git a/config/tap-driver.sh b/config/tap-driver.sh new file mode 100755 index 000000000..4254e2b3d --- /dev/null +++ b/config/tap-driver.sh @@ -0,0 +1,651 @@ +#! /bin/sh +# Copyright (C) 2011-2014 Free Software Foundation, Inc. +# +# 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; either version 2, or (at your option) +# any later version. +# +# 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, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +scriptversion=2013-12-23.17; # UTC + +# Make unconditional expansion of undefined variables an error. This +# helps a lot in preventing typo-related bugs. +set -u + +me=tap-driver.sh + +fatal () +{ + echo "$me: fatal: $*" >&2 + exit 1 +} + +usage_error () +{ + echo "$me: $*" >&2 + print_usage >&2 + exit 2 +} + +print_usage () +{ + cat < + # + trap : 1 3 2 13 15 + if test $merge -gt 0; then + exec 2>&1 + else + exec 2>&3 + fi + "$@" + echo $? + ) | LC_ALL=C ${AM_TAP_AWK-awk} \ + -v me="$me" \ + -v test_script_name="$test_name" \ + -v log_file="$log_file" \ + -v trs_file="$trs_file" \ + -v expect_failure="$expect_failure" \ + -v merge="$merge" \ + -v ignore_exit="$ignore_exit" \ + -v comments="$comments" \ + -v diag_string="$diag_string" \ +' +# TODO: the usages of "cat >&3" below could be optimized when using +# GNU awk, and/on on systems that supports /dev/fd/. + +# Implementation note: in what follows, `result_obj` will be an +# associative array that (partly) simulates a TAP result object +# from the `TAP::Parser` perl module. + +## ----------- ## +## FUNCTIONS ## +## ----------- ## + +function fatal(msg) +{ + print me ": " msg | "cat >&2" + exit 1 +} + +function abort(where) +{ + fatal("internal error " where) +} + +# Convert a boolean to a "yes"/"no" string. +function yn(bool) +{ + return bool ? "yes" : "no"; +} + +function add_test_result(result) +{ + if (!test_results_index) + test_results_index = 0 + test_results_list[test_results_index] = result + test_results_index += 1 + test_results_seen[result] = 1; +} + +# Whether the test script should be re-run by "make recheck". +function must_recheck() +{ + for (k in test_results_seen) + if (k != "XFAIL" && k != "PASS" && k != "SKIP") + return 1 + return 0 +} + +# Whether the content of the log file associated to this test should +# be copied into the "global" test-suite.log. +function copy_in_global_log() +{ + for (k in test_results_seen) + if (k != "PASS") + return 1 + return 0 +} + +function get_global_test_result() +{ + if ("ERROR" in test_results_seen) + return "ERROR" + if ("FAIL" in test_results_seen || "XPASS" in test_results_seen) + return "FAIL" + all_skipped = 1 + for (k in test_results_seen) + if (k != "SKIP") + all_skipped = 0 + if (all_skipped) + return "SKIP" + return "PASS"; +} + +function stringify_result_obj(result_obj) +{ + if (result_obj["is_unplanned"] || result_obj["number"] != testno) + return "ERROR" + + if (plan_seen == LATE_PLAN) + return "ERROR" + + if (result_obj["directive"] == "TODO") + return result_obj["is_ok"] ? "XPASS" : "XFAIL" + + if (result_obj["directive"] == "SKIP") + return result_obj["is_ok"] ? "SKIP" : COOKED_FAIL; + + if (length(result_obj["directive"])) + abort("in function stringify_result_obj()") + + return result_obj["is_ok"] ? COOKED_PASS : COOKED_FAIL +} + +function decorate_result(result) +{ + color_name = color_for_result[result] + if (color_name) + return color_map[color_name] "" result "" color_map["std"] + # If we are not using colorized output, or if we do not know how + # to colorize the given result, we should return it unchanged. + return result +} + +function report(result, details) +{ + if (result ~ /^(X?(PASS|FAIL)|SKIP|ERROR)/) + { + msg = ": " test_script_name + add_test_result(result) + } + else if (result == "#") + { + msg = " " test_script_name ":" + } + else + { + abort("in function report()") + } + if (length(details)) + msg = msg " " details + # Output on console might be colorized. + print decorate_result(result) msg + # Log the result in the log file too, to help debugging (this is + # especially true when said result is a TAP error or "Bail out!"). + print result msg | "cat >&3"; +} + +function testsuite_error(error_message) +{ + report("ERROR", "- " error_message) +} + +function handle_tap_result() +{ + details = result_obj["number"]; + if (length(result_obj["description"])) + details = details " " result_obj["description"] + + if (plan_seen == LATE_PLAN) + { + details = details " # AFTER LATE PLAN"; + } + else if (result_obj["is_unplanned"]) + { + details = details " # UNPLANNED"; + } + else if (result_obj["number"] != testno) + { + details = sprintf("%s # OUT-OF-ORDER (expecting %d)", + details, testno); + } + else if (result_obj["directive"]) + { + details = details " # " result_obj["directive"]; + if (length(result_obj["explanation"])) + details = details " " result_obj["explanation"] + } + + report(stringify_result_obj(result_obj), details) +} + +# `skip_reason` should be empty whenever planned > 0. +function handle_tap_plan(planned, skip_reason) +{ + planned += 0 # Avoid getting confused if, say, `planned` is "00" + if (length(skip_reason) && planned > 0) + abort("in function handle_tap_plan()") + if (plan_seen) + { + # Error, only one plan per stream is acceptable. + testsuite_error("multiple test plans") + return; + } + planned_tests = planned + # The TAP plan can come before or after *all* the TAP results; we speak + # respectively of an "early" or a "late" plan. If we see the plan line + # after at least one TAP result has been seen, assume we have a late + # plan; in this case, any further test result seen after the plan will + # be flagged as an error. + plan_seen = (testno >= 1 ? LATE_PLAN : EARLY_PLAN) + # If testno > 0, we have an error ("too many tests run") that will be + # automatically dealt with later, so do not worry about it here. If + # $plan_seen is true, we have an error due to a repeated plan, and that + # has already been dealt with above. Otherwise, we have a valid "plan + # with SKIP" specification, and should report it as a particular kind + # of SKIP result. + if (planned == 0 && testno == 0) + { + if (length(skip_reason)) + skip_reason = "- " skip_reason; + report("SKIP", skip_reason); + } +} + +function extract_tap_comment(line) +{ + if (index(line, diag_string) == 1) + { + # Strip leading `diag_string` from `line`. + line = substr(line, length(diag_string) + 1) + # And strip any leading and trailing whitespace left. + sub("^[ \t]*", "", line) + sub("[ \t]*$", "", line) + # Return what is left (if any). + return line; + } + return ""; +} + +# When this function is called, we know that line is a TAP result line, +# so that it matches the (perl) RE "^(not )?ok\b". +function setup_result_obj(line) +{ + # Get the result, and remove it from the line. + result_obj["is_ok"] = (substr(line, 1, 2) == "ok" ? 1 : 0) + sub("^(not )?ok[ \t]*", "", line) + + # If the result has an explicit number, get it and strip it; otherwise, + # automatically assing the next progresive number to it. + if (line ~ /^[0-9]+$/ || line ~ /^[0-9]+[^a-zA-Z0-9_]/) + { + match(line, "^[0-9]+") + # The final `+ 0` is to normalize numbers with leading zeros. + result_obj["number"] = substr(line, 1, RLENGTH) + 0 + line = substr(line, RLENGTH + 1) + } + else + { + result_obj["number"] = testno + } + + if (plan_seen == LATE_PLAN) + # No further test results are acceptable after a "late" TAP plan + # has been seen. + result_obj["is_unplanned"] = 1 + else if (plan_seen && testno > planned_tests) + result_obj["is_unplanned"] = 1 + else + result_obj["is_unplanned"] = 0 + + # Strip trailing and leading whitespace. + sub("^[ \t]*", "", line) + sub("[ \t]*$", "", line) + + # This will have to be corrected if we have a "TODO"/"SKIP" directive. + result_obj["description"] = line + result_obj["directive"] = "" + result_obj["explanation"] = "" + + if (index(line, "#") == 0) + return # No possible directive, nothing more to do. + + # Directives are case-insensitive. + rx = "[ \t]*#[ \t]*([tT][oO][dD][oO]|[sS][kK][iI][pP])[ \t]*" + + # See whether we have the directive, and if yes, where. + pos = match(line, rx "$") + if (!pos) + pos = match(line, rx "[^a-zA-Z0-9_]") + + # If there was no TAP directive, we have nothing more to do. + if (!pos) + return + + # Let`s now see if the TAP directive has been escaped. For example: + # escaped: ok \# SKIP + # not escaped: ok \\# SKIP + # escaped: ok \\\\\# SKIP + # not escaped: ok \ # SKIP + if (substr(line, pos, 1) == "#") + { + bslash_count = 0 + for (i = pos; i > 1 && substr(line, i - 1, 1) == "\\"; i--) + bslash_count += 1 + if (bslash_count % 2) + return # Directive was escaped. + } + + # Strip the directive and its explanation (if any) from the test + # description. + result_obj["description"] = substr(line, 1, pos - 1) + # Now remove the test description from the line, that has been dealt + # with already. + line = substr(line, pos) + # Strip the directive, and save its value (normalized to upper case). + sub("^[ \t]*#[ \t]*", "", line) + result_obj["directive"] = toupper(substr(line, 1, 4)) + line = substr(line, 5) + # Now get the explanation for the directive (if any), with leading + # and trailing whitespace removed. + sub("^[ \t]*", "", line) + sub("[ \t]*$", "", line) + result_obj["explanation"] = line +} + +function get_test_exit_message(status) +{ + if (status == 0) + return "" + if (status !~ /^[1-9][0-9]*$/) + abort("getting exit status") + if (status < 127) + exit_details = "" + else if (status == 127) + exit_details = " (command not found?)" + else if (status >= 128 && status <= 255) + exit_details = sprintf(" (terminated by signal %d?)", status - 128) + else if (status > 256 && status <= 384) + # We used to report an "abnormal termination" here, but some Korn + # shells, when a child process die due to signal number n, can leave + # in $? an exit status of 256+n instead of the more standard 128+n. + # Apparently, both behaviours are allowed by POSIX (2008), so be + # prepared to handle them both. See also Austing Group report ID + # 0000051 + exit_details = sprintf(" (terminated by signal %d?)", status - 256) + else + # Never seen in practice. + exit_details = " (abnormal termination)" + return sprintf("exited with status %d%s", status, exit_details) +} + +function write_test_results() +{ + print ":global-test-result: " get_global_test_result() > trs_file + print ":recheck: " yn(must_recheck()) > trs_file + print ":copy-in-global-log: " yn(copy_in_global_log()) > trs_file + for (i = 0; i < test_results_index; i += 1) + print ":test-result: " test_results_list[i] > trs_file + close(trs_file); +} + +BEGIN { + +## ------- ## +## SETUP ## +## ------- ## + +'"$init_colors"' + +# Properly initialized once the TAP plan is seen. +planned_tests = 0 + +COOKED_PASS = expect_failure ? "XPASS": "PASS"; +COOKED_FAIL = expect_failure ? "XFAIL": "FAIL"; + +# Enumeration-like constants to remember which kind of plan (if any) +# has been seen. It is important that NO_PLAN evaluates "false" as +# a boolean. +NO_PLAN = 0 +EARLY_PLAN = 1 +LATE_PLAN = 2 + +testno = 0 # Number of test results seen so far. +bailed_out = 0 # Whether a "Bail out!" directive has been seen. + +# Whether the TAP plan has been seen or not, and if yes, which kind +# it is ("early" is seen before any test result, "late" otherwise). +plan_seen = NO_PLAN + +## --------- ## +## PARSING ## +## --------- ## + +is_first_read = 1 + +while (1) + { + # Involutions required so that we are able to read the exit status + # from the last input line. + st = getline + if (st < 0) # I/O error. + fatal("I/O error while reading from input stream") + else if (st == 0) # End-of-input + { + if (is_first_read) + abort("in input loop: only one input line") + break + } + if (is_first_read) + { + is_first_read = 0 + nextline = $0 + continue + } + else + { + curline = nextline + nextline = $0 + $0 = curline + } + # Copy any input line verbatim into the log file. + print | "cat >&3" + # Parsing of TAP input should stop after a "Bail out!" directive. + if (bailed_out) + continue + + # TAP test result. + if ($0 ~ /^(not )?ok$/ || $0 ~ /^(not )?ok[^a-zA-Z0-9_]/) + { + testno += 1 + setup_result_obj($0) + handle_tap_result() + } + # TAP plan (normal or "SKIP" without explanation). + else if ($0 ~ /^1\.\.[0-9]+[ \t]*$/) + { + # The next two lines will put the number of planned tests in $0. + sub("^1\\.\\.", "") + sub("[^0-9]*$", "") + handle_tap_plan($0, "") + continue + } + # TAP "SKIP" plan, with an explanation. + else if ($0 ~ /^1\.\.0+[ \t]*#/) + { + # The next lines will put the skip explanation in $0, stripping + # any leading and trailing whitespace. This is a little more + # tricky in truth, since we want to also strip a potential leading + # "SKIP" string from the message. + sub("^[^#]*#[ \t]*(SKIP[: \t][ \t]*)?", "") + sub("[ \t]*$", ""); + handle_tap_plan(0, $0) + } + # "Bail out!" magic. + # Older versions of prove and TAP::Harness (e.g., 3.17) did not + # recognize a "Bail out!" directive when preceded by leading + # whitespace, but more modern versions (e.g., 3.23) do. So we + # emulate the latter, "more modern" behaviour. + else if ($0 ~ /^[ \t]*Bail out!/) + { + bailed_out = 1 + # Get the bailout message (if any), with leading and trailing + # whitespace stripped. The message remains stored in `$0`. + sub("^[ \t]*Bail out![ \t]*", ""); + sub("[ \t]*$", ""); + # Format the error message for the + bailout_message = "Bail out!" + if (length($0)) + bailout_message = bailout_message " " $0 + testsuite_error(bailout_message) + } + # Maybe we have too look for dianogtic comments too. + else if (comments != 0) + { + comment = extract_tap_comment($0); + if (length(comment)) + report("#", comment); + } + } + +## -------- ## +## FINISH ## +## -------- ## + +# A "Bail out!" directive should cause us to ignore any following TAP +# error, as well as a non-zero exit status from the TAP producer. +if (!bailed_out) + { + if (!plan_seen) + { + testsuite_error("missing test plan") + } + else if (planned_tests != testno) + { + bad_amount = testno > planned_tests ? "many" : "few" + testsuite_error(sprintf("too %s tests run (expected %d, got %d)", + bad_amount, planned_tests, testno)) + } + if (!ignore_exit) + { + # Fetch exit status from the last line. + exit_message = get_test_exit_message(nextline) + if (exit_message) + testsuite_error(exit_message) + } + } + +write_test_results() + +exit 0 + +} # End of "BEGIN" block. +' + +# TODO: document that we consume the file descriptor 3 :-( +} 3>"$log_file" + +test $? -eq 0 || fatal "I/O or internal error" + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: -- 2.34.1 From 5f07b6ce3098d87af3d413a67dacb5e85b2bcafe Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 2 May 2016 15:26:08 -0400 Subject: [PATCH 10/16] Clean-up: fix comment style in bin-info.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- lib/bin-info.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/bin-info.c b/lib/bin-info.c index 14b0dea3d..3bd080760 100644 --- a/lib/bin-info.c +++ b/lib/bin-info.c @@ -266,8 +266,7 @@ int bin_info_set_dwarf_info_build_id(struct bin_info *bin) dbg_dir = opt_debug_info_dir ? : DEFAULT_DEBUG_DIR; - /* 2 characters per byte printed in hex, +1 for '/' and +1 for - * '\0' */ + /* 2 characters per byte printed in hex, +1 for '/' and +1 for '\0' */ build_id_file_len = (2 * bin->build_id_len) + 1 + strlen(BUILD_ID_SUFFIX) + 1; build_id_file = malloc(build_id_file_len); -- 2.34.1 From 213811aecfe11c446167e68f4fdfbc033c76c610 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 2 May 2016 15:26:32 -0400 Subject: [PATCH 11/16] Clean-up: remove extra newline in bin-info.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- lib/bin-info.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/bin-info.c b/lib/bin-info.c index 3bd080760..b76180c30 100644 --- a/lib/bin-info.c +++ b/lib/bin-info.c @@ -517,7 +517,6 @@ error: return -1; } - BT_HIDDEN void source_location_destroy(struct source_location *src_loc) { -- 2.34.1 From 483791a59d157ec8c9ee754c926f758603872af0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 2 May 2016 15:26:50 -0400 Subject: [PATCH 12/16] Clean-up: add missing new line after end of function MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- lib/bin-info.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/bin-info.c b/lib/bin-info.c index b76180c30..813c6830e 100644 --- a/lib/bin-info.c +++ b/lib/bin-info.c @@ -527,6 +527,7 @@ void source_location_destroy(struct source_location *src_loc) free(src_loc->filename); g_free(src_loc); } + /** * Append a string representation of an address offset to an existing * string. -- 2.34.1 From 180123a5e1288f21576e6e2f621d4c6717340f81 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 2 May 2016 16:02:43 -0400 Subject: [PATCH 13/16] Set version to 1.4.0-pre MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b26e6a9c8..b9726b713 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.50]) -AC_INIT([babeltrace],[1.3.2],[jeremie.galarneau@efficios.com],[],[https://diamon.org/babeltrace]) +AC_INIT([babeltrace],[1.4.0-pre],[jeremie.galarneau@efficios.com],[],[https://diamon.org/babeltrace]) AC_SUBST([BABELTRACE_LIBRARY_VERSION], [1:0:0]) AC_CONFIG_HEADERS([config.h]) -- 2.34.1 From 15e220d0fe11ab0b103645443574366de97862b7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 2 May 2016 16:39:20 -0400 Subject: [PATCH 14/16] Fix: use of spaces instead of tabs in babeltrace.i.in MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- bindings/python/babeltrace.i.in | 44 ++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/bindings/python/babeltrace.i.in b/bindings/python/babeltrace.i.in index f9d2c736d..aaa102094 100644 --- a/bindings/python/babeltrace.i.in +++ b/bindings/python/babeltrace.i.in @@ -101,9 +101,9 @@ int _bt_python_field_integer_get_signedness(const struct bt_ctf_field *field); enum ctf_type_id _bt_python_get_field_type(const struct bt_ctf_field *field); struct bt_iter_pos *_bt_python_create_iter_pos(void); struct bt_ctf_iter *_bt_python_ctf_iter_create_intersect( - struct bt_context *ctx, - struct bt_iter_pos *inter_begin_pos, - struct bt_iter_pos *inter_end_pos); + struct bt_context *ctx, + struct bt_iter_pos *inter_begin_pos, + struct bt_iter_pos *inter_end_pos); int _bt_python_has_intersection(struct bt_context *ctx); /* ================================================================= @@ -141,7 +141,7 @@ class TraceCollection: def __init__(self, intersect_mode=False): self._tc = _bt_context_create() - self._intersect_mode = intersect_mode + self._intersect_mode = intersect_mode def __del__(self): _bt_context_put(self._tc) @@ -213,13 +213,13 @@ class TraceCollection: raise TypeError("in remove_trace, " "argument 2 must be a TraceHandle instance") - @property - def intersect_mode(self): - return self._intersect_mode + @property + def intersect_mode(self): + return self._intersect_mode - @property - def has_intersection(self): - return _bt_python_has_intersection(self._tc) + @property + def has_intersection(self): + return _bt_python_has_intersection(self._tc) @property def events(self): @@ -292,18 +292,18 @@ class TraceCollection: return ev.timestamp def _events(self, begin_pos_ptr, end_pos_ptr): - if self.intersect_mode: - if not self.has_intersection: - # There are no events to provide. - return - - ctf_it_ptr = _bt_python_ctf_iter_create_intersect( - self._tc, begin_pos_ptr, end_pos_ptr - ) - else: - ctf_it_ptr = _bt_ctf_iter_create( - self._tc, begin_pos_ptr, end_pos_ptr - ) + if self.intersect_mode: + if not self.has_intersection: + # There are no events to provide. + return + + ctf_it_ptr = _bt_python_ctf_iter_create_intersect( + self._tc, begin_pos_ptr, end_pos_ptr + ) + else: + ctf_it_ptr = _bt_ctf_iter_create( + self._tc, begin_pos_ptr, end_pos_ptr + ) if ctf_it_ptr is None: raise NotImplementedError( -- 2.34.1 From bfadaf1262452a3f84ab5d6ea8350235b0e99a2c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 2 May 2016 16:27:58 -0400 Subject: [PATCH 15/16] Fix: potential close() of uninitialized elf_fd MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit elf_fd is uninitialized whenever bin is NULL. Signed-off-by: Jérémie Galarneau --- lib/bin-info.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/bin-info.c b/lib/bin-info.c index 813c6830e..e5d515005 100644 --- a/lib/bin-info.c +++ b/lib/bin-info.c @@ -482,7 +482,7 @@ end: static int bin_info_set_elf_file(struct bin_info *bin) { - int elf_fd; + int elf_fd = -1; Elf *elf_file = NULL; if (!bin) { @@ -512,7 +512,9 @@ int bin_info_set_elf_file(struct bin_info *bin) return 0; error: - close(elf_fd); + if (elf_fd >= 0) { + close(elf_fd); + } elf_end(elf_file); return -1; } -- 2.34.1 From 8aaa05176231002977b5a84530bf5ab72b88e144 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 2 May 2016 22:46:28 -0400 Subject: [PATCH 16/16] Fix: overflow of signed integer results in undefined behaviour MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The expression "min_value = -((int64_t)1 << (size - 1))" will result in a signed integer overflow when size is 64 ((1ULL << 63) > LONG_MAX). Note that larger sizes are unsupported and checked for in the setter. Signed overflows result in undefined behaviour and llvm takes advantage of this to optimize away the range check "if (value < min_value || value > max_value) {" Surprisingly, this was not catched by GCC, Coverity, scan-build or cppcheck. The fix consists in computing both bounds using an unsigned long long type and, in the case of the lower bound, negating it (resulting in a long long). Signed-off-by: Jérémie Galarneau --- formats/ctf/writer/event-fields.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/formats/ctf/writer/event-fields.c b/formats/ctf/writer/event-fields.c index c49bc3fa6..1ffbd4a35 100644 --- a/formats/ctf/writer/event-fields.c +++ b/formats/ctf/writer/event-fields.c @@ -524,8 +524,8 @@ int bt_ctf_field_signed_integer_set_value(struct bt_ctf_field *field, } size = integer_type->declaration.len; - min_value = -((int64_t)1 << (size - 1)); - max_value = ((int64_t)1 << (size - 1)) - 1; + min_value = -(1ULL << (size - 1)); + max_value = (1ULL << (size - 1)) - 1; if (value < min_value || value > max_value) { ret = -1; goto end; -- 2.34.1