mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-11 21:20:39 +02:00
Merge bitcoin/bitcoin#35396: ci: Rewrite broken wrap-valgrind.sh to .py
fa98d44951ci: Rewrite broken wrap-valgrind.sh to .py (MarcoFalke)faf7e38973ci: refactor: Avoid warning: INSTALL_BCC_TRACING_TOOLS: unbound variable (MarcoFalke) Pull request description: The first commit fixes an error about `INSTALL_BCC_TRACING_TOOLS` being unbound. The second commit rewrites the wrap-valgrind Bash script to Python to fix the shellcheck SC2044 violation. Without this, the script would fail in CI when a path with spaces was used: ``` ... + /ci_container_base/ci/test/wrap-valgrind.sh Wrap /ci_container_base/ci/scratch_ ... mv: cannot stat '/ci_container_base/ci/scratch_': No such file or directory Wrap ₿🧪_/out/bin/bitcoin ... mv: cannot stat '₿🧪_/out/bin/bitcoin': No such file or directory /ci_container_base/ci/test/wrap-valgrind.sh: line 14: ₿🧪_/out/bin/bitcoin: No such file or directory /ci_container_base/ci/test/wrap-valgrind.sh: line 15: ₿🧪_/out/bin/bitcoin: No such file or directory chmod: cannot access '₿🧪_/out/bin/bitcoin': No such file or directory ACKs for top commit: fanquake: ACKfa98d44951- tested both on x86_64 hebasto: ACKfa98d44951, tested on Ubuntu 26.04. I also verified the actual content of the created wrappers. Tree-SHA512: fd9ccdd08a3af3aa9431eef29e17da0d785c7fe57fd0bfc9a6afdd979dc8860f4f9f0153ba3bb4b516cdec7ef0e071b846fddc1f2d28395cbe9356d2e9c55fb7
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
32
ci/test/wrap-valgrind.py
Executable file
32
ci/test/wrap-valgrind.py
Executable file
@@ -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()
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user