fuzz: Add fuzz-only build mode option for targets#31028
fuzz: Add fuzz-only build mode option for targets#31028marcofleon wants to merge 1 commit intobitcoin:masterfrom
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process. ConflictsReviewers, 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. |
|
To test, build with |
|
If we already know at compile-time that |
src/test/fuzz/fuzz.cpp
Outdated
There was a problem hiding this comment.
I think this patch is still incomplete. This will just turn the timeout into an early error. Obviously a fast error is better than a long timeout, but it would be better to exclude the test from the non-fuzz-only builds in the CI and mention in the pull request description that require_build_for_fuzzing targets must be excluded manually in non-fuzz-only builds.
An alternative would be to not register it, as explained by Cory.
09917ed to
7272a0c
Compare
There was a problem hiding this comment.
style nit: Seems fine, but I preferred the previous approach where all fuzz targets are registered with the same macro. This should be possible by guarding the FuzzFrameworkRegisterTarget behind a if constexpr (opts.require_build_for_fuzzing and not build_for_fuzzing).
This should also make #30882 easier to implement, because it doesn't have to deal with two macros.
There was a problem hiding this comment.
This may also work around the CI false positive?
There was a problem hiding this comment.
Agreed, that's a better way to do it. Let me know what you think about d470af3. Another possibility I was thinking of was something like:
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
#define CONDITIONAL_REGISTER(name, target, opts) FuzzFrameworkRegisterTarget(name, target, opts)
#else
#define CONDITIONAL_REGISTER(name, target, opts)
do {
if (!(opts).requires_fuzz_build) {
FuzzFrameworkRegisterTarget(name, target, opts);
}
} while(0)
#endif
Is there an approach I'm missing?
There was a problem hiding this comment.
Dealing with the logic in DETAIL_FUZZ seems better. And not as many macros.
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
7272a0c to
d470af3
Compare
| #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION | ||
| constexpr bool should_register = true; | ||
| #else | ||
| constexpr bool should_register = false; | ||
| #endif |
There was a problem hiding this comment.
| #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION | |
| constexpr bool should_register = true; | |
| #else | |
| constexpr bool should_register = false; | |
| #endif | |
| constexpr bool build_for_fuzzing | |
| #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION | |
| {true}; | |
| #else | |
| {false}; | |
| #endif |
nit: Could rename, so that it can be re-used in the future for other stuff, if needed?
|
Closing, as #31093 has been merged. |
Addresses #30950.
Any targets that require BUILD_ON_FUZZING=ON (currently only
p2p_headers_presync) to work properly can now setrequire_build_for_fuzzingas an option. If BUILD_FOR_FUZZING is not on and you try to run a target that has this option, then there's a message printed upon exit.With this change, the CI will be able to run the fuzz test runner without any timeouts/failures.