From fa9cf81d39e1354e4239933a053f6c91a6727fec Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 25 Feb 2026 14:36:10 +0100 Subject: [PATCH 1/2] test: Add missing resolve() to valgrind.supp file Normally, when a symlinked test script is executed directly (e.g., `./bld-cmake/test/functional/wallet_disable.py`), Python's default behavior is to resolve the symlink of the script itself, setting `sys.path[0]` to the directory containing the physical source file. Consequently, the test framework util.py is imported from the source tree, and `Path(__file__).parents[3]` correctly resolves to the source root. However, `feature_framework_testshell.py` is unique because it manually inserts `Path(__file__).parent` into `sys.path`. That refers to the build tree and when importing the test framework util.py, the `Path(__file__).parents[3]` will incorrectly point to the build directory instead of the source root. Use `.resolve()` to ensure the Valgrind suppressions file path is always calculated relative to the physical source file, regardless of how the framework was imported. --- test/functional/test_framework/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index b6aa3568a58..b9a76aef304 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -251,7 +251,7 @@ class Binaries: def __init__(self, paths, bin_dir, *, use_valgrind=False): self.paths = paths self.bin_dir = bin_dir - suppressions_file = pathlib.Path(__file__).parents[3] / "contrib" / "valgrind.supp" + suppressions_file = pathlib.Path(__file__).resolve().parents[3] / "contrib" / "valgrind.supp" self.valgrind_cmd = [ "valgrind", f"--suppressions={suppressions_file}", From fab51e470e738944dfc832926b05019e8b70f8c6 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 25 Feb 2026 15:00:17 +0100 Subject: [PATCH 2/2] test: Move valgrind.supp to the other sanitizer_suppressions files --- ci/test/wrap-valgrind.sh | 2 +- doc/developer-notes.md | 6 +++--- test/functional/test_framework/util.py | 2 +- {contrib => test/sanitizer_suppressions}/valgrind.supp | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) rename {contrib => test/sanitizer_suppressions}/valgrind.supp (81%) diff --git a/ci/test/wrap-valgrind.sh b/ci/test/wrap-valgrind.sh index e351cf24839..4ed3f2d66c5 100755 --- a/ci/test/wrap-valgrind.sh +++ b/ci/test/wrap-valgrind.sh @@ -12,7 +12,7 @@ for b_name in "${BASE_OUTDIR}/bin"/*; 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}/contrib/valgrind.supp \"${b}_orig\" \"\$@\"" >> "$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 diff --git a/doc/developer-notes.md b/doc/developer-notes.md index 97ffc0cd1b6..31ffd370c2f 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -384,13 +384,13 @@ other input. Valgrind is a programming tool for memory debugging, memory leak detection, and profiling. The repo contains a Valgrind suppressions file -([`valgrind.supp`](https://github.com/bitcoin/bitcoin/blob/master/contrib/valgrind.supp)) +([`valgrind.supp`](/test/sanitizer_suppressions/valgrind.supp)) which includes known Valgrind warnings in our dependencies that cannot be fixed in-tree. Example use: ```shell -$ valgrind --suppressions=contrib/valgrind.supp build/bin/test_bitcoin -$ valgrind --suppressions=contrib/valgrind.supp --leak-check=full \ +$ valgrind --suppressions=test/sanitizer_suppressions/valgrind.supp build/bin/test_bitcoin +$ valgrind --suppressions=test/sanitizer_suppressions/valgrind.supp --leak-check=full \ --show-leak-kinds=all build/bin/test_bitcoin --log_level=test_suite $ valgrind -v --leak-check=full build/bin/bitcoind -printtoconsole $ ./build/test/functional/test_runner.py --valgrind diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index b9a76aef304..d246a74405e 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -251,7 +251,7 @@ class Binaries: def __init__(self, paths, bin_dir, *, use_valgrind=False): self.paths = paths self.bin_dir = bin_dir - suppressions_file = pathlib.Path(__file__).resolve().parents[3] / "contrib" / "valgrind.supp" + suppressions_file = pathlib.Path(__file__).resolve().parents[3] / "test" / "sanitizer_suppressions" / "valgrind.supp" self.valgrind_cmd = [ "valgrind", f"--suppressions={suppressions_file}", diff --git a/contrib/valgrind.supp b/test/sanitizer_suppressions/valgrind.supp similarity index 81% rename from contrib/valgrind.supp rename to test/sanitizer_suppressions/valgrind.supp index c7a890aa5a4..584cdcf755e 100644 --- a/contrib/valgrind.supp +++ b/test/sanitizer_suppressions/valgrind.supp @@ -2,12 +2,12 @@ # dependencies that cannot be fixed in-tree. # # Example use: -# $ valgrind --suppressions=contrib/valgrind.supp build/bin/test_bitcoin -# $ valgrind --suppressions=contrib/valgrind.supp --leak-check=full \ +# $ valgrind --suppressions=test/sanitizer_suppressions/valgrind.supp build/bin/test_bitcoin +# $ valgrind --suppressions=test/sanitizer_suppressions/valgrind.supp --leak-check=full \ # --show-leak-kinds=all build/bin/test_bitcoin # # To create suppressions for found issues, use the --gen-suppressions=all option: -# $ valgrind --suppressions=contrib/valgrind.supp --leak-check=full \ +# $ valgrind --suppressions=test/sanitizer_suppressions/valgrind.supp --leak-check=full \ # --show-leak-kinds=all --gen-suppressions=all --show-reachable=yes \ # --error-limit=no build/bin/test_bitcoin #