test: Fix 'make cov' with clang#19709
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/ |
maflcko
left a comment
There was a problem hiding this comment.
Approach ACK. This will also print nicer error messages in case of failure
| 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.
| 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);
|
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 covfails toProcessing src/test/test_bitcoin-util_tests.gcda.