Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions .github/ci-windows-cross.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ def run_unit_tests():

def main():
parser = argparse.ArgumentParser(description="Utility to run Windows CI steps.")
steps = [
"print_version",
"check_manifests",
"prepare_tests",
"run_unit_tests",
"run_functional_tests",
]
steps = list(map(lambda f: f.__name__, [
print_version,
check_manifests,
prepare_tests,
run_unit_tests,
run_functional_tests,
]))
parser.add_argument("step", choices=steps, help="CI step to perform.")
args = parser.parse_args()

Expand All @@ -149,16 +149,7 @@ def main():
str(Path.cwd() / "previous_releases"),
)

if args.step == "print_version":
print_version()
elif args.step == "check_manifests":
check_manifests()
elif args.step == "prepare_tests":
prepare_tests()
elif args.step == "run_unit_tests":
run_unit_tests()
elif args.step == "run_functional_tests":
run_functional_tests()
exec(f'{args.step}()')


if __name__ == "__main__":
Expand Down
51 changes: 33 additions & 18 deletions .github/ci-windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,29 @@ def run(cmd, **kwargs):
}


def github_import_vs_env(_ci_type):
vswhere_path = Path(os.environ["ProgramFiles(x86)"]) / "Microsoft Visual Studio" / "Installer" / "vswhere.exe"
installation_path = run(
[str(vswhere_path), "-latest", "-property", "installationPath"],
capture_output=True,
text=True,
).stdout.strip()
vsdevcmd = Path(installation_path) / "Common7" / "Tools" / "vsdevcmd.bat"
comspec = os.environ["COMSPEC"]
output = run(
f'"{comspec}" /s /c ""{vsdevcmd}" -arch=x64 -no_logo && set"',
capture_output=True,
text=True,
).stdout
github_env = os.environ["GITHUB_ENV"]
with open(github_env, "a") as env_file:
for line in output.splitlines():
if "=" not in line:
continue
name, value = line.split("=", 1)
env_file.write(f"{name}={value}\n")


def generate(ci_type):
command = [
"cmake",
Expand All @@ -50,7 +73,7 @@ def generate(ci_type):
run(command)


def build():
def build(_ci_type):
command = [
"cmake",
"--build",
Expand Down Expand Up @@ -180,26 +203,18 @@ def run_tests(ci_type):
def main():
parser = argparse.ArgumentParser(description="Utility to run Windows CI steps.")
parser.add_argument("ci_type", choices=GENERATE_OPTIONS, help="CI type to run.")
steps = [
"generate",
"build",
"check_manifests",
"prepare_tests",
"run_tests",
]
steps = list(map(lambda f: f.__name__, [
github_import_vs_env,
generate,
build,
check_manifests,
prepare_tests,
run_tests,
]))
parser.add_argument("step", choices=steps, help="CI step to perform.")
args = parser.parse_args()

if args.step == "generate":
generate(args.ci_type)
elif args.step == "build":
build()
elif args.step == "check_manifests":
check_manifests(args.ci_type)
elif args.step == "prepare_tests":
prepare_tests(args.ci_type)
elif args.step == "run_tests":
run_tests(args.ci_type)
exec(f'{args.step}("{args.ci_type}")')


if __name__ == "__main__":
Expand Down
29 changes: 12 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ jobs:
name: 'test ancestor commits'
needs: runners
runs-on: ${{ needs.runners.outputs.provider == 'cirrus' && 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-md' || 'ubuntu-24.04' }}
env:
TEST_RUNNER_PORT_MIN: "14000" # Use a larger port, to avoid colliding with CIRRUS_CACHE_HOST port 12321.
if: github.event_name == 'pull_request' && github.event.pull_request.commits != 1
timeout-minutes: 360 # Use maximum time, see https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes.
steps:
Expand Down Expand Up @@ -236,26 +238,19 @@ jobs:

- *CHECKOUT

- &SET_UP_VS
name: Set up VS Developer Prompt
shell: pwsh -Command "$PSVersionTable; $PSNativeCommandUseErrorActionPreference = $true; $ErrorActionPreference = 'Stop'; & '{0}'"
run: |
$vswherePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$installationPath = & $vswherePath -latest -property installationPath
& "${env:COMSPEC}" /s /c "`"$installationPath\Common7\Tools\vsdevcmd.bat`" -arch=x64 -no_logo && set" | foreach-object {
$name, $value = $_ -split '=', 2
echo "$name=$value" >> $env:GITHUB_ENV
}
- &IMPORT_VS_ENV
name: Import Visual Studio env vars
run: py -3 .github/ci-windows.py "standard" github_import_vs_env

- name: Get tool information
shell: pwsh
run: |
cmake -version | Tee-Object -FilePath "cmake_version"
Write-Output "---"
msbuild -version | Tee-Object -FilePath "msbuild_version"
$env:VCToolsVersion | Tee-Object -FilePath "toolset_version"
set -o errexit -o pipefail -o xtrace -o nounset

cmake -version | tee cmake_version
echo '---'
msbuild.exe -version | tee msbuild_version
echo "${VCToolsVersion-}" | tee toolset_version
py -3 --version
Write-Host "PowerShell version $($PSVersionTable.PSVersion.ToString())"
bash --version

- name: Using vcpkg with MSBuild
Expand Down Expand Up @@ -428,7 +423,7 @@ jobs:
- name: Run bitcoind.exe
run: py -3 .github/ci-windows-cross.py print_version

- *SET_UP_VS
- *IMPORT_VS_ENV

- name: Check executable manifests
run: py -3 .github/ci-windows-cross.py check_manifests
Expand Down
2 changes: 1 addition & 1 deletion ci/test/wrap-valgrind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/common/netif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include <ifaddrs.h>
#endif

#include <type_traits>

namespace {

//! Return CNetAddr for the specified OS-level network address.
Expand Down Expand Up @@ -134,7 +136,9 @@ std::optional<CNetAddr> QueryDefaultGatewayImpl(sa_family_t family)
return std::nullopt;
}

for (nlmsghdr* hdr = (nlmsghdr*)response; NLMSG_OK(hdr, recv_result); hdr = NLMSG_NEXT(hdr, recv_result)) {
using recv_result_t = std::conditional_t<std::is_signed_v<decltype(NLMSG_HDRLEN)>, int64_t, decltype(NLMSG_HDRLEN)>;

for (nlmsghdr* hdr = (nlmsghdr*)response; NLMSG_OK(hdr, static_cast<recv_result_t>(recv_result)); hdr = NLMSG_NEXT(hdr, recv_result)) {
if (!(hdr->nlmsg_flags & NLM_F_MULTI)) {
done = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/threadpool_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ BOOST_AUTO_TEST_CASE(stop_active_wait_drains_queue)
}
BOOST_CHECK_EQUAL(threadPool.WorkQueueSize(), num_tasks);

// Delay release so Stop() drain all tasks from the calling thread
// Delay release so Stop() drains all tasks from the calling thread
std::thread unblocker([&blocker, &threadPool]() {
while (threadPool.WorkQueueSize() > 0) {
std::this_thread::yield();
Expand Down
2 changes: 1 addition & 1 deletion test/functional/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] / "test" / "sanitizer_suppressions" / "valgrind.supp"
self.valgrind_cmd = [
"valgrind",
f"--suppressions={suppressions_file}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
Loading