diff mbox series

[3/5] babeltrace2: Fix python bindings ptests

Message ID 20250817205124.3384337-3-richard.purdie@linuxfoundation.org
State New
Headers show
Series [1/5] lttng-ust: Upgrade 2.13.9 -> 2.14.0 | expand

Commit Message

Richard Purdie Aug. 17, 2025, 8:51 p.m. UTC
From: Michael Jeanson <mjeanson@efficios.com>

The python bindings ptests weren't functional. This patch:

  * Adds a patch to allow the tests to be executed on target standalone
  * Sets a variable to allow the right install path to be passed to setup.py
  * Sets the right paths in the ptest runner script for the python modules
  * Installs the missing data needed to run the tests

Base patch was written by Michael Jeanson, RP then tweaked working
and formatting and added config to complete the work on all arches.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 .../babeltrace2/external-python-tests.patch   | 126 ++++++++++++++++++
 .../lttng/babeltrace2/run-ptest               |   3 +
 .../recipes-kernel/lttng/babeltrace2_2.1.1.bb |   7 +-
 3 files changed, 134 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-kernel/lttng/babeltrace2/external-python-tests.patch

Comments

patchtest@automation.yoctoproject.org Aug. 17, 2025, 9:03 p.m. UTC | #1
Thank you for your submission. Patchtest identified one
or more issues with the patch. Please see the log below for
more information:

---
Testing patch /home/patchtest/share/mboxes/3-5-babeltrace2-Fix-python-bindings-ptests.patch

FAIL: test Signed-off-by presence: A patch file has been added without a Signed-off-by tag: 'external-python-tests.patch' (test_patch.TestPatch.test_signed_off_by_presence)

PASS: pretest src uri left files (test_metadata.TestMetadata.pretest_src_uri_left_files)
PASS: test CVE check ignore (test_metadata.TestMetadata.test_cve_check_ignore)
PASS: test CVE tag format (test_patch.TestPatch.test_cve_tag_format)
PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test Upstream-Status presence (test_patch.TestPatch.test_upstream_status_presence_format)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test commit message user tags (test_mbox.TestMbox.test_commit_message_user_tags)
PASS: test lic files chksum modified not mentioned (test_metadata.TestMetadata.test_lic_files_chksum_modified_not_mentioned)
PASS: test max line length (test_metadata.TestMetadata.test_max_line_length)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test shortlog format (test_mbox.TestMbox.test_shortlog_format)
PASS: test shortlog length (test_mbox.TestMbox.test_shortlog_length)
PASS: test src uri left files (test_metadata.TestMetadata.test_src_uri_left_files)
PASS: test target mailing list (test_mbox.TestMbox.test_target_mailing_list)

SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test lic files chksum presence: No added recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_presence)
SKIP: test license presence: No added recipes, skipping test (test_metadata.TestMetadata.test_license_presence)
SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)
SKIP: test summary presence: No added recipes, skipping test (test_metadata.TestMetadata.test_summary_presence)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this
email with an explanation of why the patch should be accepted. If you
believe these results are due to an error in patchtest, please submit a
bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category
under 'Yocto Project Subprojects'). For more information on specific
failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank
you!
diff mbox series

Patch

diff --git a/meta/recipes-kernel/lttng/babeltrace2/external-python-tests.patch b/meta/recipes-kernel/lttng/babeltrace2/external-python-tests.patch
new file mode 100644
index 00000000000..960b33d9595
--- /dev/null
+++ b/meta/recipes-kernel/lttng/babeltrace2/external-python-tests.patch
@@ -0,0 +1,126 @@ 
+From d2f528aa09a9001e63710470f6b700d122494961 Mon Sep 17 00:00:00 2001
+From: Michael Jeanson <mjeanson@efficios.com>
+Date: Thu, 14 Aug 2025 12:27:16 -0400
+Subject: [PATCH babeltrace] bindings/python: Allow tests to be run externally
+
+Upstream doesn't officially support running their tests externally. The python
+bindings need some tweaks to work in this configuration.
+
+The patch was created by Michael Jeanson <mjeanson@efficios.com> and is under
+discussion with upstream to see if there is a way to support OE's ue case.
+
+Upstream-Status: Inappropriate [oe specific]
+
+Change-Id: I89555a3fbd821baa7088acc154e81665102286b8
+---
+ .../python/bt2/test_component_descriptor.py   |   2 +-
+ tests/bindings/python/bt2/test_graph.py       |   2 +-
+ tests/bindings/python/bt2/test_plugin.py      |  10 +-
+ .../python/bt2/test_query_executor.py         |   2 +-
+ tests/utils/utils.sh                          |   2 +-
+ 6 files changed, 117 insertions(+), 9 deletions(-)
+ create mode 100644 tests/0001-wip-tests-yocto.patch
+
+diff --git a/tests/bindings/python/bt2/test_component_descriptor.py b/tests/bindings/python/bt2/test_component_descriptor.py
+index dcad514eb..49a3c054d 100644
+--- a/tests/bindings/python/bt2/test_component_descriptor.py
++++ b/tests/bindings/python/bt2/test_component_descriptor.py
+@@ -19,7 +19,7 @@ class ComponentDescriptorTestCase(unittest.TestCase):
+         self._comp_descr = bt2.ComponentDescriptor(_DummySink, {"zoom": -23}, self._obj)
+ 
+     def _get_comp_cls_from_plugin(self):
+-        plugin = bt2.find_plugin("text", find_in_user_dir=False, find_in_sys_dir=False)
++        plugin = bt2.find_plugin("text", find_in_user_dir=False, find_in_sys_dir=True)
+         assert plugin is not None
+         cc = plugin.source_component_classes["dmesg"]
+         assert cc is not None
+diff --git a/tests/bindings/python/bt2/test_graph.py b/tests/bindings/python/bt2/test_graph.py
+index 9661667a9..7fe247bd9 100644
+--- a/tests/bindings/python/bt2/test_graph.py
++++ b/tests/bindings/python/bt2/test_graph.py
+@@ -113,7 +113,7 @@ class GraphTestCase(unittest.TestCase):
+         del comp_obj
+ 
+     def test_add_component_obj_non_python_comp_cls(self):
+-        plugin = bt2.find_plugin("text", find_in_user_dir=False, find_in_sys_dir=False)
++        plugin = bt2.find_plugin("text", find_in_user_dir=False, find_in_sys_dir=True)
+         assert plugin is not None
+         cc = plugin.source_component_classes["dmesg"]
+         assert cc is not None
+diff --git a/tests/bindings/python/bt2/test_plugin.py b/tests/bindings/python/bt2/test_plugin.py
+index 0d7a9e775..39451f93a 100644
+--- a/tests/bindings/python/bt2/test_plugin.py
++++ b/tests/bindings/python/bt2/test_plugin.py
+@@ -41,7 +41,7 @@ class FindPluginsTestCase(unittest.TestCase):
+             )
+ 
+     def test_find_none_existing_dir(self):
+-        plugins = bt2.find_plugins_in_path(_TEST_PLUGIN_PLUGINS_PATH, recurse=False)
++        plugins = bt2.find_plugins_in_path(os.environ["BT_TESTS_BUILDDIR"], recurse=False)
+         self.assertIsNone(plugins)
+ 
+     def test_find_dir(self):
+@@ -53,7 +53,7 @@ class FindPluginsTestCase(unittest.TestCase):
+             os.environ["BT_TESTS_OS_TYPE"], "so"
+         )
+         plugin_name = "babeltrace-plugin-utils.{}".format(extension)
+-        path = os.path.join(_TEST_PLUGIN_PLUGINS_PATH, "utils", ".libs", plugin_name)
++        path = os.path.join(_TEST_PLUGIN_PLUGINS_PATH, plugin_name)
+         pset = bt2.find_plugins_in_path(path)
+         self.assertTrue(len(pset) == 1)
+ 
+@@ -66,14 +66,14 @@ class FindPluginTestCase(unittest.TestCase):
+         self.assertIsNone(plugin)
+ 
+     def test_find_existing(self):
+-        plugin = bt2.find_plugin("ctf", find_in_user_dir=False, find_in_sys_dir=False)
++        plugin = bt2.find_plugin("ctf", find_in_user_dir=False, find_in_sys_dir=True)
+         self.assertIsNotNone(plugin)
+ 
+ 
+ class PluginTestCase(unittest.TestCase):
+     def setUp(self):
+         self._plugin = bt2.find_plugin(
+-            "ctf", find_in_user_dir=False, find_in_sys_dir=False
++            "ctf", find_in_user_dir=False, find_in_sys_dir=True
+         )
+ 
+     def tearDown(self):
+@@ -125,7 +125,7 @@ class PluginTestCase(unittest.TestCase):
+         self.assertEqual(plugins["lttng-live"].name, "lttng-live")
+ 
+     def test_filter_comp_classes_len(self):
+-        plugin = bt2.find_plugin("utils", find_in_user_dir=False, find_in_sys_dir=False)
++        plugin = bt2.find_plugin("utils", find_in_user_dir=False, find_in_sys_dir=True)
+         self.assertEqual(len(plugin.filter_component_classes), 2)
+ 
+     def test_sink_comp_classes_len(self):
+diff --git a/tests/bindings/python/bt2/test_query_executor.py b/tests/bindings/python/bt2/test_query_executor.py
+index 099457197..9bbfd417a 100644
+--- a/tests/bindings/python/bt2/test_query_executor.py
++++ b/tests/bindings/python/bt2/test_query_executor.py
+@@ -129,7 +129,7 @@ class QueryExecutorTestCase(unittest.TestCase):
+         del query_method_obj
+ 
+     def test_query_with_method_obj_non_python_comp_cls(self):
+-        plugin = bt2.find_plugin("text", find_in_user_dir=False, find_in_sys_dir=False)
++        plugin = bt2.find_plugin("text", find_in_user_dir=False, find_in_sys_dir=True)
+         assert plugin is not None
+         cc = plugin.source_component_classes["dmesg"]
+         assert cc is not None
+diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh
+index 28db595d1..05b87f64e 100644
+--- a/tests/utils/utils.sh
++++ b/tests/utils/utils.sh
+@@ -143,7 +143,7 @@ export BT_TESTS_BT2_BIN
+ # bt_run_in_py_env() to use it.
+ #
+ # TODO: Remove when `tests/bindings/python/bt2/test_plugin.py` is fixed.
+-_bt_tests_plugins_path=$BT_TESTS_BUILDDIR/../src/plugins
++_bt_tests_plugins_path=/usr/lib/babeltrace2/plugins
+ 
+ # Colon-separated list of project plugin paths, if not set
+ _bt_tests_set_var_def BT_TESTS_BABELTRACE_PLUGIN_PATH \
+-- 
+2.47.2
+
diff --git a/meta/recipes-kernel/lttng/babeltrace2/run-ptest b/meta/recipes-kernel/lttng/babeltrace2/run-ptest
index a0bf33b75de..55397c2dd62 100755
--- a/meta/recipes-kernel/lttng/babeltrace2/run-ptest
+++ b/meta/recipes-kernel/lttng/babeltrace2/run-ptest
@@ -6,6 +6,9 @@ 
 # test plan to raise ERRORs; this is just noise.
 makeargs="LOG_DRIVER_FLAGS=--ignore-exit abs_top_srcdir=$PWD abs_top_builddir=$PWD"
 
+declare -x BT_TESTS_BABELTRACE_PLUGIN_PATH="/usr/lib/babeltrace2/ptest/tests/utils/python"
+declare -x BT_TESTS_PROVIDER_DIR="/usr/lib/babeltrace2/plugin-providers"
+
 exec 2> error.log
 make -C tests -k -s $makeargs $target
 exitcode=$?
diff --git a/meta/recipes-kernel/lttng/babeltrace2_2.1.1.bb b/meta/recipes-kernel/lttng/babeltrace2_2.1.1.bb
index 88f589eafbc..52768f6ce3c 100644
--- a/meta/recipes-kernel/lttng/babeltrace2_2.1.1.bb
+++ b/meta/recipes-kernel/lttng/babeltrace2_2.1.1.bb
@@ -13,6 +13,7 @@  SRC_URI = "git://git.efficios.com/babeltrace.git;branch=stable-2.1;protocol=http
            file://0001-tests-fix-test-applications-in-cpp-common.patch \
            file://0001-tests-set-the-correct-plugin-directory.patch \
            file://0001-Make-bt_field_blob_get_length-return-size_t-instead-.patch \
+           file://external-python-tests.patch \
            "
 SRCREV = "7f2f8cd6dac497cbb466efb31219b531c62013f5"
 UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>2(\.\d+)+)$"
@@ -21,6 +22,8 @@  inherit autotools pkgconfig ptest python3targetconfig
 
 EXTRA_OECONF = "--disable-debug-info --disable-Werror --enable-python-plugins --enable-python-bindings"
 
+export DISTSETUPOPTS = " --install-lib=${PYTHON_SITEPACKAGES_DIR}"
+
 PACKAGECONFIG ??= "manpages"
 PACKAGECONFIG[manpages] = ", --disable-man-pages, asciidoc-native xmlto-native"
 
@@ -67,8 +70,8 @@  do_install_ptest () {
 	find "${S}/tests/$d" -maxdepth 1 -name *.json \
 	     -exec install -t "${D}${PTEST_PATH}/tests/$d" {} \;
     done
-    install -d "${D}${PTEST_PATH}/tests/data/ctf-traces/"
-    cp -a ${S}/tests/data/ctf-traces/* ${D}${PTEST_PATH}/tests/data/ctf-traces/
+    install -d "${D}${PTEST_PATH}/tests/data/"
+    cp -a ${S}/tests/data/* ${D}${PTEST_PATH}/tests/data/
 
     # Copy the tests directory tree and the executables and
     # Makefiles found within.