-
Notifications
You must be signed in to change notification settings - Fork 37.7k
test: Parse command line arguments from unit and fuzz tests, make addrman consistency check ratio easier to change #23373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial lightly tested code review ACK, was distracted by addrman unit test failures I was seeing that turned out to be already on master (and spurious, not sure yet what happened); will come back to finish reviewing here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK, I think it would be useful to have the option of providing arguments to unit and fuzz tests.
Is all the code processing -- DEBUG_LOG_OUT
still needed when we might do as well -- -printttoconsole=1
?
Not needed anymore. I did not remove it because I do not want to break existing functionality - I do not know how many scripts out there use it, or in CI, or how many devs are just used to it. Given that it is just for testing/development purposes, not used in real/production nodes I think it should be ok to remove it in a followup PR some time after this is merged. |
9b6098f
to
0c541a6
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a bit more testing. It seems it could be very helpful for this patch to print the parsed arguments and values as feedback to the user, to be sure they are correct. A few minor comments follow.
0c541a6
to
17fac01
Compare
|
17fac01
to
b374709
Compare
|
b374709
to
51b241b
Compare
|
ACK 72544a0 verified the change using |
@@ -71,6 +71,14 @@ block^@M-^?M-^?M-^?M-^?M-^?nM-^?M-^? | |||
|
|||
In this case the fuzzer managed to create a `block` message which when passed to `ProcessMessage(...)` increased coverage. | |||
|
|||
It is possible to specify `bitcoind` arguments to the `fuzz` executable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should only be possible if that specific FUZZ
test starts a Bitcoin Core node
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, added some more words to make it clearer (hopefully). Feel free to suggest how to explain it better, if still unclear.
|
||
test_bitcoin --log_level=all --run_test=getarg_tests -- DEBUG_LOG_OUT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think --printtoconsole=1
is a replacement for -- DEBUG_LOG_OUT
. DEBUG_LOG_OUT
would work even if the unit test didn't start a Bitcoin Core node internally, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. However, currently all unit tests create such a node: BOOST_FIXTURE_TEST_SUITE(..., X)
where X
is BasicTestingSetup
or something that has inherited from it. So I think DEBUG_LOG_OUT
can be completely phased out, following this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible to create "pure" unit tests without any fixture, IIRC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, are you suggesting to restore the mention of DEBUG_LOG_OUT
in src/test/README.md
or to not phase out DEBUG_LOG_OUT
after this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is fine to remove DEBUG_LOG_OUT
. I just wanted to mention that not all test spin up a node.
72544a0
to
e25dce2
Compare
Invalidates ACK from @mzumsande, @josibake |
ACK e25dce2 after rebase. |
Oh, I didn't realize this meant re-ACK. I interpreted it as I'll ack after rebase, so I didn't merge this. |
Retrieve the command line arguments from boost and pass them to `BasicTestingSetup` so that we gain extra flexibility of passing any config options on the test command line, e.g.: ``` test_bitcoin -- -printtoconsole=1 -checkaddrman=5 ```
Retrieve the command line arguments from the fuzzer and save them for later retrieval by `BasicTestingSetup` so that we gain extra flexibility of passing any config options on the test command line, e.g.: ``` FUZZ=addrman ./src/test/fuzz/fuzz --checkaddrman=5 ``` A fuzz test should call `MakeNoLogFileContext<>()` in its initialize function in order to invoke the constructor of `BasicTestingSetup`, which sets `gArgs`.
So that it is easy to modify through the file `bench/addrman.cpp`.
In addrman unit tests, make it possible to override the check ratio from the command line, without recompiling: ``` test_bitcoin --run_test="addrman_tests/*" -- -checkaddrman=1 ``` Also, make the arguments of the constructor of `AddrManTest` the same as the arguments of `AddrMan`.
Make it possible to override from the command line (without recompiling) the addrman check ratio in the common `TestingSetup::m_node::addrman` (used by all unit tests) instead of hardcoding it to 0: ``` test_bitcoin --run_test="transaction_tests/tx_valid" -- -checkaddrman=1 ```
Make it possible to override from the command line (without recompiling) the addrman check ratio in addrman fuzz tests instead of hardcoding it to 0: ``` FUZZ=addrman ./src/test/fuzz/fuzz --checkaddrman=5 ```
Make it possible to override from the command line (without recompiling) the addrman check ratio in non-addrman fuzz tests (connman and deserialize) instead of hardcoding it to 0: ``` FUZZ=connman ./src/test/fuzz/fuzz --checkaddrman=5 ```
Invalidates ACK from @mzumsande Previously invalidated ACK from @josibake |
e25dce2
to
7f122a4
Compare
re-ACK 7f122a4 |
reACK 7f122a4 |
Previously command line arguments passed to unit and fuzz tests would be ignored by the tests themselves. They would be used by the boost test framework (e.g.
--run_test="addrman_tests/*"
) or by the fuzzer (e.g.-runs=1
). However both provide ways to pass down the extra arguments to the test itself. Use that, parse the arguments and make them available to the tests viagArgs
.This makes the tests more flexible as they can be run with any bitcoind config option specified on the command line.
When creating
AddrMan
objects in tests, use-checkaddrman=
(if provided) instead of hardcoding the check ratio in many different places. See #20233 (comment) for further motivation for this.