mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:47:36 +00:00
test: optionally run functional tests via CTest #35762
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!35762
Loading…
Reference in a new issue
No description provided.
Delete branch "ctest-functional-v6"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Expose individual functional tests through the same CTest interface used for unit tests, making them easier to select, inspect, and rerun from the command line or CTest-aware IDEs.
Scheduling unit and functional tests together may improve parallel execution. It also enables per-test results and timings to be uploaded to our Bitcoin Core CDash instance, helping track failures and runtime changes across builds.
Registration is opt-in with
BUILD_FUNCTIONAL_TESTS=ONand requires CMake 4.4 or newer. The existing runner remains available for RPC coverage and CSV results. The native macOS CI job exercises the combined CTest workflow and passes. Seetest/README.mdfor usage and limitations.The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
The
MacOS nativeCI job shows ctest orchestrating the unit and functional tests altogether: https://github.com/bitcoin/bitcoin/actions/runs/29824697919/job/88615235560?pr=35762#step:9:3919d2b4bd40f23067cad97ba6553fe0832d57424c26: Unrelated change?
d2b4bd40f23067cad97ba6553fe0832d57424c26: Why not follow the docs and call the test_runner from the build dir, which avoids having to pass the new option?
a9e0c71ca4dee40abce66aad0bbb27682ccdcd7f: Could drop this, or add least add a short rationale for stuff like this?
Not quite, although it was incorrect (thanks!)
(somethign like this) is needed because native/upstream
discover_tests()preserves the empty\5replacement for tests without an optional argument. Without filtering it,--ctest-directsees the script plus an empty second “test” and rejects the invocation.The explicit
--separator is needed separately becauseargparseallows option abbreviation by default: CTest’s child option--tmpdir(tdestined for test_framework.py) can otherwise be consumed as the runner’s--tmpdirprefixoption instead of being forwarded. Thearg != "--"filter removes that separator before invoking the child test.(in fact, I think this is a seperate bug and we could disable argparse allow_abbrev to fix it properly. Or perhaps makes better sense to fix that first, before these changes...)
Addressed in latest push by invoking the generated
build/test/functional/test_runner.pylink/copy. The runner can therefore continue locatingtest/config.inirelative to itself, without adding a runner-level--configfileoption.Nice, thanks. I didn't think of it because I always run everythign from the source directory, for no good reason.
added a short comment documenting the source-tree resolution (and dropped
PYTHON_GIL=1which is set by test/CMakeLists.txt on each test already.🚧 At least one of the CI tasks failed.
Task
riscv32 bare metal, static libbitcoin_consensus: https://github.com/bitcoin/bitcoin/actions/runs/30046119080/job/90826618769LLM reason (✨ experimental): CI failed because submodule cloning of
newlib-cygwin.gitfromsourceware.orgwas rate-limited (HTTP 429), causing the base install step to exit with code 2.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
not sure about exposing this in CI. This will silently ignore
TEST_RUNNER_EXTRA, and having two ways to achieve the same seems confusing anyway.However, not exposing it in CI will also make it less useful ...
Thank you for taking a look, and fair point!
I don't consider these strict duplicates:
CTEST_TESTSis a coarse CTest label selection: all, functional, or nonfunctional whereasTEST_RUNNER_EXTRAcontains runner-specific behavior and test arguments.However they do certainly overlap, and I think (for now) I will amend the commit to fail if
TEST_RUNNER_EXTRAis non-empty inCTESTmode as a check on silently doing something else than the tests might have indented.Longer-term, say we switch all tests over to ctest, I would see us dropping
RUN_FUNCTIONAL_TESTS_WITH_CTEST(it would be default/on for all and unneeded), probably alos removeCTEST_TESTSand instead have each job just construct its own ctest command directly, and maybe even removeTEST_RUNNER_EXTRA(depening on whether we can get all supported options ported to ctest).Why would porting be hard? The leftover from "${TEST_RUNNER_EXTRA[@]}" would just end up in
passon_argsand be exported to the test list, no?This pull is adding 500 LOC of logic complexity, so my preference would be to at least keep the overhead low.
Recall the alternative to this would be to write it in a few trivial lines of Python (https://github.com/bitcoin/bitcoin/issues/32770#issuecomment-3714857697)
Also, recall that Python would work when testing win64-cross builds, but CTest does not.
unrelated nit: You may want to rebase this on top of https://github.com/bitcoin/bitcoin/pull/35846, for better error (message) handling
Base:
a773e1e33b349dc819b5a0edc1c7a4839dc73b48Head:
f5741987366395a11dd57c518bf4098251d8b805Findings
Minor
CTest discovery can fail when the benchmark executable has not been built (test/functional/test_runner.py:608, head)
When
BUILD_BENCHis enabled, benchmark expansion runs before the--dump-ctestbranch and invokesbench_bitcoin -list. If benchmarks are configured butbench_bitcoinhas not been built,subprocess.check_outputraisesFileNotFoundError, preventing CTest from loading the functional test inventory. Skip or defer benchmark expansion when the executable is unavailable. No checked-in CI invocation was found that runs CTest after a partial benchmark build; the failure is established for user or IDE workflows that load CTest before buildingbench_bitcoin.Design and approach
A single clean-chain CTest selection still builds an unused shared cache (test/functional/CMakeLists.txt:19, head)
FIXTURES_REQUIREDapplies to every discovered case, so selecting onlyfunctional.rpc_bind.ipv6still runs the cache-removal and cache-creation fixture. That test setssetup_clean_chain=Trueand initializes an empty chain instead of copying the shared cache, so building the 199-block cache is unnecessary. The legacy runner creates that cache only when running multiple tests in parallel. Require the fixture only for selected cases that use the shared cache, while preserving it for cache-dependent and parallel runs.Review coverage was incomplete.
Review limitations
Full review report
🐙 This pull request conflicts with the target branch and needs rebase.
Are you still working on this?
Yes, thanks. Will update shortly.
🚧 At least one of the CI tasks failed.
Task
macOS native: https://github.com/bitcoin/bitcoin/actions/runs/37589945926/job/112688773432LLM reason (✨ experimental): CI failed because parallel benchmark tests collided on the same temporary directory, causing
bench_PrevectorDeserializeTrivialto fail withFileExistsError.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
rebased on master
Agreed this change was getting too large. About half was supporting this new feature on old cmake versions, so I dropped that. It now just requires cmake >= 4.4 to use.
Also dropped the duplicate selector.
CTest now invokes the generated build/test/functional/test_runner.py, which locates config.ini relative to itself. The added runner-level --configfile option is gone.
now removed.
PR description updated with the new, more limited, scope.
Windows cross remains a limitation for now. It can be made to work without too much tinkering, but I don't think that's needed in this pull.
I also considered a commit to have the macos_native ci job (using ctest) actually push results to cdash, but I think that can also come in a separate followup pull.
🐙 This pull request conflicts with the target branch and needs rebase.
Tested ACK
f574198736An opt-in way to run the functional tests through CTest is valuable for developers integrating Bitcoin Core into CMake/CTest/CDash workflows, and for anyone who wants finer-grained control (filtering, parallel scheduling, fixtures, dashboard reporting) while replacing the existing
test_runner.pyunchanged.Tested on Ubuntu 24.04 with CMake 4.4.2.
Build and discovery
Build and discovery logs:
build-and-discovery.txt
Execution
Execution logs:
ctest logs.txt
Cache fixture behavior
Cache logs;
cache-fixture-runs.txt
CDash submission
Submitted functional test runs to a local CDash instance (Experimental track) via a dashboard script. Results appear correctly with the functional label.
Notes