-
Notifications
You must be signed in to change notification settings - Fork 37.7k
test: Show debug log on unit test failure #16975
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
fa758c2
to
fa8e20a
Compare
Can be tested by injecting a failure in any test case and then running |
Concept ACK. Ran diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
index fed65afdbf..d0948dcbca 100644
--- a/src/test/net_tests.cpp
+++ b/src/test/net_tests.cpp
@@ -88,6 +88,7 @@ BOOST_AUTO_TEST_CASE(cnode_listen_port)
BOOST_CHECK(gArgs.SoftSetArg("-port", std::to_string(altPort)));
port = GetListenPort();
BOOST_CHECK(port == altPort);
+ BOOST_CHECK(false);
}
BOOST_AUTO_TEST_CASE(caddrdb_read)
|
Whoops. Fixing ... |
faaa2d3
to
fa006d8
Compare
Fixed |
src/logging.h
Outdated
@@ -77,6 +77,9 @@ namespace BCLog { | |||
|
|||
std::string LogTimestampStr(const std::string& str); | |||
|
|||
/** Slots that connect to the print signal */ | |||
std::list<std::function<void(const std::string&)>> m_print_callbacks /* GUARDED_BY(m_cs) */ {}; |
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.
Why comment the lock annotation?
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 can't compile otherwise. If you include sync.h
, the tests won't run after compilation.
src/logging.h
Outdated
} | ||
|
||
/** Delete a connection */ | ||
void DeleteCallback(std::list<std::function<void(const std::string&)>>::iterator it) |
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.
Unused?
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.
Used in #16540
64fac9a
to
fa39655
Compare
Concept ACK |
Concept ACK. |
Concept ACK. |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
fa116ab
to
faa5a01
Compare
Ah, forgot to push one more tsan suppression. Fixed. Though, longer term I'd like to do #8670 (comment) |
utACK faa5a01. Tried a few different scenarios and noted that logging is provided for multiple failed test cases in a file before exiting. For example:
|
faa5a01
to
fa031ab
Compare
Rebased for minor merge conflict |
Concept ACK If there are multiple test cases in a single test file and one of them fails currently the logs of all the test cases are printed, also the succeeding ones. Could that be improved? It could be especially annoying if there are a lot of logs for every test case and the developer would have to search for the failing one (I discovered this on |
@fjahr I don't think I can solve that without having a way to detect (inside the Also, I think having too much logs is better than having no logs to debug at all. |
fa031ab
to
fa9ab18
Compare
Concept ACK.
Usually true, though having too much (unrelated) logging can also distract. And CI web interfaces make the experience of browsing large files quite horrible. Also, too much logging can slow down the tests. But I don't think that's the case with this change. |
fa55a17
to
fab72a3
Compare
Agree on the distraction part, but if you set the log level to "debug" or "test_suite" I think a verbose log should be expected. Note that this is not printed to the ci log unless the test fails. Also note that the tests already log to the debug.log, so logging to the test log shouldn't slow them down. See the comparison:
So it might or might not be slower, but I don't think there is any significant difference |
fab72a3
to
fad5fe2
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.
ACK fad5fe2.
Anything left to do here? |
ACK fad5fe2 -- diff looks correct |
fad5fe2
to
fa37e0a
Compare
Rebased to fix trivial merge conflict |
Would-be ACK fa37e0a but it looks like I've hit a deadlock. Modified the coins test for failure: diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp
index 436c1bffa0..2c20efc12b 100644
--- a/src/test/coins_tests.cpp
+++ b/src/test/coins_tests.cpp
@@ -213,6 +213,7 @@ BOOST_AUTO_TEST_CASE(coins_cache_simulation_test)
unsigned int flushIndex = InsecureRandRange(stack.size() - 1);
BOOST_CHECK(stack[flushIndex]->Flush());
}
+ assert(false);
}
if (InsecureRandRange(100) == 0) {
// Every 100 iterations, change the cache stack. and ran with Noticed the test seemed to be hanging, so straced:
|
ACK fa37e0a ( Confirmed that Show signature data
|
fa37e0a test: Show debug log on unit test failure (MarcoFalke) Pull request description: Often, it is hard to debug unit test failures without the debug log. Especially when the failure happens remotely (e.g. on a ci system). Fix that by printing the log on failure. ACKs for top commit: jamesob: ACK fa37e0a ([`jamesob/ackr/16975.1.MarcoFalke.test_show_debug_log_on_u`](https://github.com/jamesob/bitcoin/tree/ackr/16975.1.MarcoFalke.test_show_debug_log_on_u)) Tree-SHA512: 2ca4150c4ae3d4ad47e03b5e5e70da2baffec928ddef1fdf53a3ebc061f14aee249205387cb1b12ef6d4eb55711ef0080c0b41d9d18000b5da124ca80299793b
fa37e0a test: Show debug log on unit test failure (MarcoFalke) Pull request description: Often, it is hard to debug unit test failures without the debug log. Especially when the failure happens remotely (e.g. on a ci system). Fix that by printing the log on failure. ACKs for top commit: jamesob: ACK fa37e0a ([`jamesob/ackr/16975.1.MarcoFalke.test_show_debug_log_on_u`](https://github.com/jamesob/bitcoin/tree/ackr/16975.1.MarcoFalke.test_show_debug_log_on_u)) Tree-SHA512: 2ca4150c4ae3d4ad47e03b5e5e70da2baffec928ddef1fdf53a3ebc061f14aee249205387cb1b12ef6d4eb55711ef0080c0b41d9d18000b5da124ca80299793b
7777703 doc: Explain new test logging (MarcoFalke) Pull request description: Explain logging added in bitcoin#18472 and bitcoin#16975 ACKs for top commit: jonatack: ACK 7777703 Tree-SHA512: 3a0aa7bab32a6753d8894d29cf82604b044b23e512102dd275b717eefda3c2212dbf43ea7e9155267350dd9f3bc5badba2eb660152db3efeab30a04f52126c95
fa37e0a test: Show debug log on unit test failure (MarcoFalke) Pull request description: Often, it is hard to debug unit test failures without the debug log. Especially when the failure happens remotely (e.g. on a ci system). Fix that by printing the log on failure. ACKs for top commit: jamesob: ACK fa37e0a ([`jamesob/ackr/16975.1.MarcoFalke.test_show_debug_log_on_u`](https://github.com/jamesob/bitcoin/tree/ackr/16975.1.MarcoFalke.test_show_debug_log_on_u)) Tree-SHA512: 2ca4150c4ae3d4ad47e03b5e5e70da2baffec928ddef1fdf53a3ebc061f14aee249205387cb1b12ef6d4eb55711ef0080c0b41d9d18000b5da124ca80299793b
Summary: This is a backport of [[bitcoin/bitcoin#16975 | core#16975]] Test Plan: `ninja check` Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Subscribers: majcosta Differential Revision: https://reviews.bitcoinabc.org/D9971
Often, it is hard to debug unit test failures without the debug log. Especially when the failure happens remotely (e.g. on a ci system).
Fix that by printing the log on failure.