From faf7e38973673e13aff30dba8f8c57df02537c74 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 27 May 2026 15:44:01 +0200 Subject: [PATCH 1/2] ci: refactor: Avoid warning: INSTALL_BCC_TRACING_TOOLS: unbound variable The variable is never set and will always be unbound. The only way to set it correctly is via this hack: .github/workflows/ci.yml- # In the image build step, no external environment variables are available, .github/workflows/ci.yml- # so any settings will need to be written to the settings env file: .github/workflows/ci.yml: run: sed -i "s|\${INSTALL_BCC_TRACING_TOOLS}|true|g" ./ci/test/00_setup_env_native_asan.sh So just silence the warning, which happens when running the task locally: ``` ./ci/test/00_setup_env_native_asan.sh: line 12: INSTALL_BCC_TRACING_TOOLS: unbound variable ``` --- ci/test/00_setup_env_native_asan.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/test/00_setup_env_native_asan.sh b/ci/test/00_setup_env_native_asan.sh index 2465c70bb48..58be89fa104 100755 --- a/ci/test/00_setup_env_native_asan.sh +++ b/ci/test/00_setup_env_native_asan.sh @@ -9,7 +9,7 @@ export LC_ALL=C.UTF-8 export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04" # Only install BCC tracing packages in CI. Container has to match the host for BCC to work. -if [[ "${INSTALL_BCC_TRACING_TOOLS}" == "true" ]]; then +if [[ "${INSTALL_BCC_TRACING_TOOLS:-}" == "true" ]]; then # Required for USDT functional tests to run BPFCC_PACKAGE="bpfcc-tools linux-headers-$(uname --kernel-release)" export CI_CONTAINER_CAP="--privileged -v /sys/kernel:/sys/kernel:rw" From fa98d449517da406203e042aaccb8acc698d7a0c Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 27 May 2026 16:53:31 +0200 Subject: [PATCH 2/2] ci: Rewrite broken wrap-valgrind.sh to .py Shellcheck marked the script as violating SC2044. Instead of re-writing the Bash from scratch, just use Python. --- ci/test/03_test_script.sh | 2 +- ci/test/wrap-valgrind.py | 32 ++++++++++++++++++++++++++++++++ ci/test/wrap-valgrind.sh | 18 ------------------ 3 files changed, 33 insertions(+), 19 deletions(-) create mode 100755 ci/test/wrap-valgrind.py delete mode 100755 ci/test/wrap-valgrind.sh diff --git a/ci/test/03_test_script.sh b/ci/test/03_test_script.sh index b3ab1729853..5ecbe863a39 100755 --- a/ci/test/03_test_script.sh +++ b/ci/test/03_test_script.sh @@ -168,7 +168,7 @@ if [ -n "${CI_LIMIT_STACK_SIZE}" ]; then fi if [ -n "$USE_VALGRIND" ]; then - "${BASE_ROOT_DIR}/ci/test/wrap-valgrind.sh" + "${BASE_ROOT_DIR}/ci/test/wrap-valgrind.py" fi if [ "$RUN_CHECK_DEPS" = "true" ]; then diff --git a/ci/test/wrap-valgrind.py b/ci/test/wrap-valgrind.py new file mode 100755 index 00000000000..6a79f2aaae1 --- /dev/null +++ b/ci/test/wrap-valgrind.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# Copyright (c) The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or https://opensource.org/license/mit/. + +import os +import shlex +from pathlib import Path + + +def main(): + base_root = Path(os.environ["BASE_ROOT_DIR"]) + base_out = Path(os.environ["BASE_OUTDIR"]) + suppressions_file = base_root / "test" / "sanitizer_suppressions" / "valgrind.supp" + target_names = {b.name for b in (base_out / "bin").iterdir()} + + for exe in base_root.rglob("*"): + if exe.name in target_names and exe.is_file() and os.access(exe, os.X_OK): + print(f"Wrap {exe} ...") + original_path = exe.with_name(f"{exe.name}_orig") + exe.rename(original_path) + exe.write_text( + "#!/usr/bin/env bash\n" + "exec valgrind --gen-suppressions=all --quiet --error-exitcode=1 " + f"--suppressions={shlex.quote(str(suppressions_file))} " + f'{shlex.quote(str(original_path))} "$@"\n' + ) + exe.chmod(exe.stat().st_mode | 0o111) + + +if __name__ == "__main__": + main() diff --git a/ci/test/wrap-valgrind.sh b/ci/test/wrap-valgrind.sh deleted file mode 100755 index 4ed3f2d66c5..00000000000 --- a/ci/test/wrap-valgrind.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (c) 2018-present The Bitcoin Core developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. - -export LC_ALL=C.UTF-8 - -for b_name in "${BASE_OUTDIR}/bin"/*; do - # shellcheck disable=SC2044 - for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name "$(basename "$b_name")"); do - echo "Wrap $b ..." - mv "$b" "${b}_orig" - echo '#!/usr/bin/env bash' > "$b" - echo "exec valgrind --gen-suppressions=all --quiet --error-exitcode=1 --suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/valgrind.supp \"${b}_orig\" \"\$@\"" >> "$b" - chmod +x "$b" - done -done