[meta-oe][PATCH 5/5] bcc: Stop baking the build directory into the ptest binaries
Khem Raj <[email protected]> Tue, 28 Jul 2026 22:29:00 -0700
| Newsgroups | org.openembedded.lists.openembedded-devel |
|---|---|
| Message-ID | <[email protected]> |
From: Khem Raj <[email protected]> tests/cc passes -DCMAKE_CURRENT_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}" to every test object so the tests can find archive.zip, the debuginfo libraries and dummy_proc_map.txt at runtime. That put 13 copies of the absolute build directory into the installed test binary: QA Issue: File /usr/lib/bcc/ptest/tests/cc/test_libbcc_no_libbpf in package bcc-ptest contains reference to TMPDIR [buildpaths] and, on autobuilders whose TMPDIR sits below $HOME, additionally: QA Issue: ... contains a reference to the build host HOME directory. The recipe worked around this by installing the assets to ${D}${B}/tests/cc, i.e. by reproducing the build path inside the image, and by demoting buildpaths to a warning. Add a patch introducing a TEST_ASSET_DIR cache variable, defaulting to CMAKE_CURRENT_BINARY_DIR so the upstream default is unchanged, and point it at ${PTEST_PATH}/tests/cc. The assets are now installed next to the test binaries and no build path is embedded, so the buildpaths overrides can go away. Also install dummy_proc_map.txt, which the tests reference but which was never shipped. Signed-off-by: Khem Raj <[email protected]> --- ...verriding-the-runtime-location-of-te.patch | 49 +++++++++++++++++++ .../recipes-devtools/bcc/bcc_0.37.0.bb | 24 +++++---- 2 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/bcc/bcc/0001-tests-cc-Allow-overriding-the-runtime-location-of-te.patch diff --git a/meta-oe/dynamic-layers/meta-python/recipes-devtools/bcc/bcc/0001-tests-cc-Allow-overriding-the-runtime-location-of-te.patch b/meta-oe/dynamic-layers/meta-python/recipes-devtools/bcc/bcc/0001-tests-cc-Allow-overriding-the-runtime-location-of-te.patch new file mode 100644 index 0000000000..71fc2f5b7e --- /dev/null +++ b/meta-oe/dynamic-layers/meta-python/recipes-devtools/bcc/bcc/0001-tests-cc-Allow-overriding-the-runtime-location-of-te.patch @@ -0,0 +1,49 @@ +From ba4c3827dd93a21e35d324b41b90ffbd1dff5c4f Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Tue, 28 Jul 2026 21:04:15 -0700 +Subject: [PATCH] tests/cc: Allow overriding the runtime location of test + assets + +tests/cc bakes CMAKE_CURRENT_BINARY_DIR into every test object so that the +tests can find archive.zip, the debuginfo test libraries and +dummy_proc_map.txt at runtime. + +That makes the build directory part of the installed test binaries. For +distributions which build the tests in one place and run them somewhere else +this is both useless and a reproducibility problem: the absolute build path +ends up embedded in a shipped binary, and the assets have to be installed at +that same path for the tests to pass. + +Introduce a TEST_ASSET_DIR cache variable which defaults to +CMAKE_CURRENT_BINARY_DIR, so the default behaviour is unchanged, and use it +for the macro definition. Packagers can now point it at wherever the assets +are installed. + +The macro keeps its current name to avoid churn in the test sources. + +Upstream-Status: Submitted [https://github.com/iovisor/bcc/issues] + +Signed-off-by: Khem Raj <[email protected]> +--- + tests/cc/CMakeLists.txt | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/tests/cc/CMakeLists.txt b/tests/cc/CMakeLists.txt +index b4dd3f9..8f56fc9 100644 +--- a/tests/cc/CMakeLists.txt ++++ b/tests/cc/CMakeLists.txt +@@ -19,7 +19,13 @@ else() + endif() + + add_test(NAME c_test_static COMMAND ${TEST_WRAPPER} c_test_static sudo ${CMAKE_CURRENT_BINARY_DIR}/test_static) +-add_compile_options(-DCMAKE_CURRENT_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}") ++# The tests locate their assets (archive.zip, the debuginfo libraries, ++# dummy_proc_map.txt, ...) through this macro. Let the runtime location be ++# overridden so that distributions can install the assets next to the test ++# binaries instead of baking the build directory into them. ++set(TEST_ASSET_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE STRING ++ "Directory containing the test assets at runtime") ++add_compile_options(-DCMAKE_CURRENT_BINARY_DIR="${TEST_ASSET_DIR}") + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result -fPIC") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-result -fPIC") diff --git a/meta-oe/dynamic-layers/meta-python/recipes-devtools/bcc/bcc_0.37.0.bb b/meta-oe/dynamic-layers/meta-python/recipes-devtools/bcc/bcc_0.37.0.bb index 9ecc30b58b..9315a6e603 100644 --- a/meta-oe/dynamic-layers/meta-python/recipes-devtools/bcc/bcc_0.37.0.bb +++ b/meta-oe/dynamic-layers/meta-python/recipes-devtools/bcc/bcc_0.37.0.bb @@ -22,6 +22,7 @@ RDEPENDS:${PN}-ptest = "kernel-devsrc packagegroup-core-buildessential cmake bas SRC_URI = "gitsm://github.com/iovisor/bcc;branch=master;protocol=https;lfs=0;tag=v${PV} \ file://0001-CMakeLists.txt-override-the-PY_CMD_ESCAPED.patch \ file://0001-Vendor-just-enough-extra-headers-to-allow-libbpf-to-.patch \ + file://0001-tests-cc-Allow-overriding-the-runtime-location-of-te.patch \ file://run-ptest \ file://ptest_wrapper.sh \ " @@ -44,6 +45,11 @@ EXTRA_OECMAKE = " \ -DPYTHON_FLAGS=--install-lib=${PYTHON_SITEPACKAGES_DIR} \ " +# The C tests hardcode the location of their assets at build time. Point that at +# where do_install_ptest puts them so the build directory does not end up baked +# into the installed test binaries. +EXTRA_OECMAKE += "-DTEST_ASSET_DIR=${PTEST_PATH}/tests/cc" + # Avoid stripping debuginfo.so to fix some tests. INHIBIT_PACKAGE_STRIP = "1" INHIBIT_PACKAGE_DEBUG_SPLIT = "1" @@ -58,10 +64,11 @@ do_install:append() { do_install_ptest() { install -d ${D}${PTEST_PATH}/tests/cc - # ptest searches for shared libs and archive files in the build folder. - # Hence, these files are copied to the image to fix these tests. - install -d ${D}${B}/tests/cc - install ${B}/tests/cc/archive.zip ${B}/tests/cc/libdebuginfo_test_lib.so ${B}/tests/cc/with_gnu_debuglink.so ${B}/tests/cc/with_gnu_debugdata.so ${B}/tests/cc/debuginfo.so ${D}${B}/tests/cc + # The C tests look their assets up under TEST_ASSET_DIR, which is pointed at + # ${PTEST_PATH}/tests/cc at configure time, so install them next to the test + # binaries rather than at the (build host specific) build directory path. + install ${B}/tests/cc/archive.zip ${B}/tests/cc/libdebuginfo_test_lib.so ${B}/tests/cc/with_gnu_debuglink.so ${B}/tests/cc/with_gnu_debugdata.so ${B}/tests/cc/debuginfo.so ${D}${PTEST_PATH}/tests/cc + install -m 0644 ${B}/tests/cc/dummy_proc_map.txt ${D}${PTEST_PATH}/tests/cc install -d ${D}/opt install ${B}/tests/cc/test_libbcc_no_libbpf ${B}/tests/cc/libusdt_test_lib.so ${D}${PTEST_PATH}/tests/cc cp -rf ${S}/tests/python ${D}${PTEST_PATH}/tests/python @@ -75,18 +82,9 @@ do_install_ptest() { } FILES:${PN} += "${PYTHON_SITEPACKAGES_DIR}" -FILES:${PN} += "${B}/tests/cc" FILES:${PN}-ptest += "${libdir}/libbcc.so" FILES:${PN}-ptest += "${libdir}/tools/" FILES:${PN}-ptest += "/opt/" FILES:${PN}-doc += "${datadir}/${PN}/man" COMPATIBLE_HOST = "(x86_64.*|aarch64.*|powerpc64.*|riscv64.*)-linux" - -# WARNING: bcc-0.30.0+git-r0 do_package_qa: QA Issue: File /usr/lib/bcc/ptest/tests/cc/test_libbcc_no_libbpf in package bcc-ptest contains reference to TMPDIR [buildpaths] -# this one is difficult to resolve, because the tests use CMAKE_CURRENT_BINARY_DIR directly in .cc e.g.: -# https://github.com/iovisor/bcc/commit/7271bfc946a19413761be2e3c60c48bf72c5eea1#diff-233a0bfa490f3d7466c49935b64c86dd93956bbc0461f5af703b344cf6601461 -# we would probably need to use separate variable for "runtime" path for test assets from the standard CMAKE_CURRENT_BINARY_DIR variable or use relative -# path from the test binary -WARN_QA:append = "${@bb.utils.contains('PTEST_ENABLED', '1', ' buildpaths', '', d)}" -ERROR_QA:remove = "${@bb.utils.contains('PTEST_ENABLED', '1', 'buildpaths', '', d)}"