From d8992d68ea94b3e02ab275bb4be33c5b3a8b7d73 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 2 Nov 2017 13:20:18 -0400 Subject: [PATCH] Add basic flt.lttng-utils.debug-info tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This new test uses the bt2 Python bindings to test the flt.lttng-utils.debug-info component class. The test opens the tests/debug-info-data/trace trace and makes it pass through a flt.lttng-utils.debug-info component to inject debugging information. The test then checks that specific debugging information fields in specific event notifications have the expected values. This patch also removes the old tests/cli/test_debug_info.in test which is not even enabled and relied on the output of sink.text.pretty. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- .gitignore | 3 +- configure.ac | 2 +- tests/Makefile.am | 6 ++++ tests/cli/test_debug_info.in | 28 --------------- tests/plugins/Makefile.am | 12 +++++-- tests/plugins/test_lttng_utils_debug_info.in | 38 ++++++++++++++++++++ tests/plugins/test_lttng_utils_debug_info.py | 26 ++++++++++++++ 7 files changed, 83 insertions(+), 32 deletions(-) delete mode 100644 tests/cli/test_debug_info.in create mode 100644 tests/plugins/test_lttng_utils_debug_info.in create mode 100644 tests/plugins/test_lttng_utils_debug_info.py diff --git a/.gitignore b/.gitignore index 710c7077..a1740cb1 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ /tests/lib/test_graph_topo /tests/plugins/test-utils-muxer /tests/plugins/test-utils-muxer-complete +/tests/plugins/test_lttng_utils_debug_info /tests/plugins/test_bin_info_complete /tests/plugins/test_bin_info /tests/plugins/test_dwarf_complete @@ -89,4 +90,4 @@ doc/api/Doxyfile *.gcda *.gcov *.html -*.stamp \ No newline at end of file +*.stamp diff --git a/configure.ac b/configure.ac index 60b48d04..2f605658 100644 --- a/configure.ac +++ b/configure.ac @@ -777,7 +777,6 @@ AC_CONFIG_FILES([ AC_CONFIG_FILES([tests/cli/intersection/test_intersection], [chmod +x tests/cli/intersection/test_intersection]) AC_CONFIG_FILES([tests/cli/test_convert_args], [chmod +x tests/cli/test_convert_args]) -AC_CONFIG_FILES([tests/cli/test_debug_info], [chmod +x tests/cli/test_debug_info]) AC_CONFIG_FILES([tests/cli/test_packet_seq_num], [chmod +x tests/cli/test_packet_seq_num]) AC_CONFIG_FILES([tests/cli/test_trace_copy], [chmod +x tests/cli/test_trace_copy]) AC_CONFIG_FILES([tests/cli/test_trace_read], [chmod +x tests/cli/test_trace_read]) @@ -785,6 +784,7 @@ AC_CONFIG_FILES([tests/cli/test_trimmer], [chmod +x tests/cli/test_trimmer]) AC_CONFIG_FILES([tests/lib/test_ctf_writer_complete], [chmod +x tests/lib/test_ctf_writer_complete]) AC_CONFIG_FILES([tests/lib/test_plugin_complete], [chmod +x tests/lib/test_plugin_complete]) AC_CONFIG_FILES([tests/plugins/test-utils-muxer-complete], [chmod +x tests/plugins/test-utils-muxer-complete]) +AC_CONFIG_FILES([tests/plugins/test_lttng_utils_debug_info], [chmod +x tests/plugins/test_lttng_utils_debug_info]) AC_CONFIG_FILES([tests/plugins/test_dwarf_complete], [chmod +x tests/plugins/test_dwarf_complete]) AC_CONFIG_FILES([tests/plugins/test_bin_info_complete], [chmod +x tests/plugins/test_bin_info_complete]) diff --git a/tests/Makefile.am b/tests/Makefile.am index 19c2483e..a0f26a1f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -43,6 +43,12 @@ TESTS_PLUGINS = if !ENABLE_BUILT_IN_PLUGINS TESTS_PLUGINS += plugins/test-utils-muxer-complete + +if ENABLE_DEBUG_INFO +if ENABLE_PYTHON_BINDINGS +TESTS_PLUGINS += plugins/test_lttng_utils_debug_info +endif +endif endif if ENABLE_DEBUG_INFO diff --git a/tests/cli/test_debug_info.in b/tests/cli/test_debug_info.in deleted file mode 100644 index e0c9204c..00000000 --- a/tests/cli/test_debug_info.in +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# -# Copyright (C) - 2017 Julien Desfossez -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License, version 2 only, as -# published by the Free Software Foundation. -# -# 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. - -. "@abs_top_builddir@/tests/utils/common.sh" - -DEBUG_INFO_TRACE="${BT_SRC_PATH}/tests/debug-info-data/trace/" - -NUM_TESTS=1 - -plan_tests $NUM_TESTS - -"${BT_BIN}" --debug-info-target-prefix "${BT_SRC_PATH}" "${DEBUG_INFO_TRACE}" 2>/dev/null \ - | @GREP@ 'debug_info = { bin = "libhello_so+0x15a6", func = "bar+0xa9", src = "libhello.c:13" }' >/dev/null -ok $? "Extract debug information" diff --git a/tests/plugins/Makefile.am b/tests/plugins/Makefile.am index 9527a87a..7ea42392 100644 --- a/tests/plugins/Makefile.am +++ b/tests/plugins/Makefile.am @@ -16,7 +16,7 @@ test_utils_muxer_LDADD = $(COMMON_TEST_LDADD) noinst_PROGRAMS += test-utils-muxer check_SCRIPTS += test-utils-muxer-complete -endif +endif # !ENABLE_BUILT_IN_PLUGINS if ENABLE_DEBUG_INFO test_dwarf_LDADD = \ @@ -37,4 +37,12 @@ test_bin_info_SOURCES = test_bin_info.c noinst_PROGRAMS += test_dwarf test_bin_info check_SCRIPTS += test_dwarf_complete test_bin_info_complete -endif + +if !ENABLE_BUILT_IN_PLUGINS +if ENABLE_PYTHON_BINDINGS +check_SCRIPTS += test_lttng_utils_debug_info +endif # !ENABLE_BUILT_IN_PLUGINS +endif # ENABLE_PYTHON_BINDINGS +endif # ENABLE_DEBUG_INFO + +EXTRA_DIST = test_lttng_utils_debug_info.py diff --git a/tests/plugins/test_lttng_utils_debug_info.in b/tests/plugins/test_lttng_utils_debug_info.in new file mode 100644 index 00000000..46fb9173 --- /dev/null +++ b/tests/plugins/test_lttng_utils_debug_info.in @@ -0,0 +1,38 @@ +#!/bin/bash +# +# Copyright (C) 2017 - Philippe Proulx +# +# 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. +# + +NO_SH_TAP=1 +. "@abs_top_builddir@/tests/utils/common.sh" + +PYTHON_BUILD_DIR="${BT_BUILD_PATH}/bindings/python/bt2/build/build_lib" +TESTS_UTILS_PYTHON_DIR="${BT_SRC_PATH}/tests/utils/python" +TESTRUNNER_PY="${BT_SRC_PATH}/tests/utils/python/testrunner.py" +THIS_DIR="${BT_SRC_PATH}/tests/plugins" +export BABELTRACE_PLUGIN_PATH="${BT_BUILD_PATH}/plugins/utils:${BT_BUILD_PATH}/plugins/ctf:${BT_BUILD_PATH}/plugins/lttng-utils" +export DEBUG_INFO_DATA_DIR="${BT_SRC_PATH}/tests/debug-info-data" + +if [ "x${MSYSTEM}" != "x" ]; then + export PATH="${BT_BUILD_PATH}/lib/.libs:${PATH}" +else + export LD_LIBRARY_PATH="${BT_BUILD_PATH}/lib/.libs:${LD_LIBRARY_PATH}" +fi + +PYTHONPATH="${PYTHON_BUILD_DIR}:${TESTS_UTILS_PYTHON_DIR}" \ + "@PYTHON@" "${TESTRUNNER_PY}" "${THIS_DIR}" +exit $? diff --git a/tests/plugins/test_lttng_utils_debug_info.py b/tests/plugins/test_lttng_utils_debug_info.py new file mode 100644 index 00000000..c98ae70e --- /dev/null +++ b/tests/plugins/test_lttng_utils_debug_info.py @@ -0,0 +1,26 @@ +import unittest +import os.path +import bt2 +import os + + +class LttngUtilsDebugInfoTestCase(unittest.TestCase): + def test_debug_info(self): + debug_info_data_dir = os.environ['DEBUG_INFO_DATA_DIR'] + trace_path = os.path.join(debug_info_data_dir, 'trace') + target_prefix = os.path.join(debug_info_data_dir, '..', '..') + src = bt2.ComponentSpec('ctf', 'fs', trace_path) + flt = bt2.ComponentSpec('lttng-utils', 'debug-info', { + 'target-prefix': target_prefix, + }) + it = bt2.TraceCollectionNotificationIterator(src, flt, + [bt2.EventNotification]) + notifs = list(it) + debug_info = notifs[2].event['debug_info'] + self.assertEqual(debug_info['bin'], 'libhello_so+0x14d4') + self.assertEqual(debug_info['func'], 'foo+0xa9') + self.assertEqual(debug_info['src'], 'libhello.c:7') + debug_info = notifs[3].event['debug_info'] + self.assertEqual(debug_info['bin'], 'libhello_so+0x15a6') + self.assertEqual(debug_info['func'], 'bar+0xa9') + self.assertEqual(debug_info['src'], 'libhello.c:13') -- 2.34.1