Add basic flt.lttng-utils.debug-info tests
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 2 Nov 2017 17:20:18 +0000 (13:20 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 2 Nov 2017 20:11:00 +0000 (16:11 -0400)
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 <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
.gitignore
configure.ac
tests/Makefile.am
tests/cli/test_debug_info.in [deleted file]
tests/plugins/Makefile.am
tests/plugins/test_lttng_utils_debug_info.in [new file with mode: 0644]
tests/plugins/test_lttng_utils_debug_info.py [new file with mode: 0644]

index 710c707798845581ab3289173e9e6e6da24ab89e..a1740cb1f087058f9b7ef6eada9886f2398308a3 100644 (file)
@@ -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
index 60b48d04eda52eb8f003000dad2a519608ec3df0..2f60565886188ae5c3ec521a1b274b83df2aab82 100644 (file)
@@ -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])
 
index 19c2483eb3b76762b68fe1688b30cde02c25e502..a0f26a1fbf3506b0f6255733d6faba599be0ffa3 100644 (file)
@@ -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 (file)
index e0c9204..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) - 2017 Julien Desfossez <jdesfossez@efficios.com>
-#
-# 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"
index 9527a87a98a26e5fdff247d9a1f1188c6bc70863..7ea42392dd7aa32536f7530bc355ed275d1f2e36 100644 (file)
@@ -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 (file)
index 0000000..46fb917
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+#
+# Copyright (C) 2017 - Philippe Proulx <pproulx@efficios.com>
+#
+# 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 (file)
index 0000000..c98ae70
--- /dev/null
@@ -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')
This page took 0.029809 seconds and 4 git commands to generate.