-
Notifications
You must be signed in to change notification settings - Fork 37.7k
test: Fix 'make cov' with clang #19709
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
@hebasto What is the root cause of this issue? :) |
|
That's pretty important to figure out imo, we can't just randomly perturb the test code to make a tool happy. |
Agree we should know what is going on but since I have had this issue locally I have gone ahead and tested it. So, I am tACK this PR cherry-picked on top of #19688 modulo an explanation of why this failed previously. Thanks for fixing this! |
@practicalswift @laanwj @fjahr
Thank you for forcing me to find the root of this issue!
To solve this issues some variants of the patch are available:
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -559,11 +559,10 @@ BOOST_AUTO_TEST_CASE(util_ReadConfigStream)
&& test_args.m_settings.ro_config[""].count("h")
&& test_args.m_settings.ro_config[""].count("i")
);
- BOOST_CHECK(test_args.m_settings.ro_config["sec1"].count("ccc")
- && test_args.m_settings.ro_config["sec1"].count("h")
- && test_args.m_settings.ro_config["sec2"].count("ccc")
- && test_args.m_settings.ro_config["sec2"].count("iii")
+ BOOST_CHECK(((test_args.m_settings.ro_config["sec1"].count("ccc")
+ && test_args.m_settings.ro_config["sec1"].count("h"))
+ && test_args.m_settings.ro_config["sec2"].count("ccc"))
+ && test_args.m_settings.ro_config["sec2"].count("iii")
);
BOOST_CHECK(test_args.IsArgSet("-a")
&& test_args.IsArgSet("-b")
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -559,11 +559,10 @@ BOOST_AUTO_TEST_CASE(util_ReadConfigStream)
&& test_args.m_settings.ro_config[""].count("h")
&& test_args.m_settings.ro_config[""].count("i")
);
- BOOST_CHECK(test_args.m_settings.ro_config["sec1"].count("ccc")
- && test_args.m_settings.ro_config["sec1"].count("h")
- && test_args.m_settings.ro_config["sec2"].count("ccc")
- && test_args.m_settings.ro_config["sec2"].count("iii")
- );
+ bool test_value = test_args.m_settings.ro_config["sec1"].count("ccc")
+ && test_args.m_settings.ro_config["sec1"].count("h")
+ && test_args.m_settings.ro_config["sec2"].count("ccc")
+ && test_args.m_settings.ro_config["sec2"].count("iii");
+ BOOST_CHECK(test_value);
BOOST_CHECK(test_args.IsArgSet("-a")
&& test_args.IsArgSet("-b")
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -559,11 +559,10 @@ BOOST_AUTO_TEST_CASE(util_ReadConfigStream)
&& test_args.m_settings.ro_config[""].count("h")
&& test_args.m_settings.ro_config[""].count("i")
);
- BOOST_CHECK(test_args.m_settings.ro_config["sec1"].count("ccc")
- && test_args.m_settings.ro_config["sec1"].count("h")
- && test_args.m_settings.ro_config["sec2"].count("ccc")
- && test_args.m_settings.ro_config["sec2"].count("iii")
- );
+ BOOST_CHECK(test_args.m_settings.ro_config["sec1"].count("ccc"));
+ BOOST_CHECK(test_args.m_settings.ro_config["sec1"].count("h"));
+ BOOST_CHECK(test_args.m_settings.ro_config["sec2"].count("ccc"));
+ BOOST_CHECK(test_args.m_settings.ro_config["sec2"].count("iii")); );
BOOST_CHECK(test_args.IsArgSet("-a")
&& test_args.IsArgSet("-b") The last variant has the following benefits:
Update: but https://www.boost.org/doc/libs/1_73_0/libs/test/doc/html/boost_test/utf_reference/testing_tool_ref/assertion_boost_level.html says that for |
Tested, code review ACK 568d42b Changes are straightforward and they assert the same thing as they did before so should be fine. test_bitcoin coverage: https://crypt-iq.github.io/pr19709/test_bitcoin.coverage/ |
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.
Approach ACK. This will also print nicer error messages in case of failure
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.
ACK 568d42b
It is always better to have
assert(a);
assert(b);
instead of
assert(a && b);
due to better diagnostics in case of failure.
The patch is good as is, but if you are in a mood for it - take the suggestion below.
src/test/util_tests.cpp
Outdated
BOOST_CHECK(!test_args.IsArgSet("-zzz")); | ||
BOOST_CHECK(!test_args.IsArgSet("-iii")); | ||
|
||
BOOST_CHECK(test_args.GetArg("-a", "xxx") == ""); |
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.
BOOST_CHECK(test_args.GetArg("-a", "xxx") == ""); | |
BOOST_CHECK_EQUAL(test_args.GetArg("-a", "xxx"), ""); |
would produce a better error message, if it fails some day.
Same in all places below where BOOST_CHECK(a == b);
can be replaced with BOOST_CHECK_EQUAL(a, b);
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.
Thank you! Updated.
Updated 568d42b -> 35cd2da (pr19709.01 -> pr19709.02, diff):
|
ACK 35cd2da |
1 similar comment
ACK 35cd2da |
This is a follow up of #19688.
With this PR it is possible to do the following:
Currently, on master (8a85377),
make cov
fails toProcessing src/test/test_bitcoin-util_tests.gcda
.