aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-03-31 15:39:08 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-03-31 15:39:15 -0400
commit72ef366564394bad798484ba935c96b68579043f (patch)
tree001a6dda3b5936658dc8606d5bb1f324e06a7796 /src
parentd52ba21dfff99173abb927bc964ce7ceb711d789 (diff)
parentfa3cc0bfc4c4fc13a384fc291403c9fd41082f18 (diff)
Merge #18472: test: Remove unsafe BOOST_TEST_MESSAGE
fa3cc0bfc4c4fc13a384fc291403c9fd41082f18 test: Remove unsafe BOOST_TEST_MESSAGE (MarcoFalke) Pull request description: Fixes #17987 Can be tested with ``` ./src/test/test_bitcoin -l test_suite -- DEBUG_LOG_OUT ACKs for top commit: fjahr: tested ACK fa3cc0bfc4c4fc13a384fc291403c9fd41082f18 mzumsande: Tested ACK fa3cc0bfc4c4fc13a384fc291403c9fd41082f18 Tree-SHA512: f63b110d77882cd7c0d7574ff6c9c948db8febb3400ecdac45164746b587b0fa223463041801271b3959267ddc1d9a4a67ba76939e242e7dd2f92a2834a400a0
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.test.include2
-rw-r--r--src/test/main.cpp18
2 files changed, 12 insertions, 8 deletions
diff --git a/src/Makefile.test.include b/src/Makefile.test.include
index 059876bec8..93c5973a21 100644
--- a/src/Makefile.test.include
+++ b/src/Makefile.test.include
@@ -1011,7 +1011,7 @@ endif
%.cpp.test: %.cpp
@echo Running tests: `cat $< | grep -E "(BOOST_FIXTURE_TEST_SUITE\\(|BOOST_AUTO_TEST_SUITE\\()" | cut -d '(' -f 2 | cut -d ',' -f 1 | cut -d ')' -f 1` from $<
- $(AM_V_at)$(TEST_BINARY) --catch_system_errors=no -l test_suite -t "`cat $< | grep -E "(BOOST_FIXTURE_TEST_SUITE\\(|BOOST_AUTO_TEST_SUITE\\()" | cut -d '(' -f 2 | cut -d ',' -f 1 | cut -d ')' -f 1`" > $<.log 2>&1 || (cat $<.log && false)
+ $(AM_V_at)$(TEST_BINARY) --catch_system_errors=no -l test_suite -t "`cat $< | grep -E "(BOOST_FIXTURE_TEST_SUITE\\(|BOOST_AUTO_TEST_SUITE\\()" | cut -d '(' -f 2 | cut -d ',' -f 1 | cut -d ')' -f 1`" -- DEBUG_LOG_OUT > $<.log 2>&1 || (cat $<.log && false)
%.json.h: %.json
@$(MKDIR_P) $(@D)
diff --git a/src/test/main.cpp b/src/test/main.cpp
index e6529949e2..f32243d1d3 100644
--- a/src/test/main.cpp
+++ b/src/test/main.cpp
@@ -11,12 +11,16 @@
#include <test/util/setup_common.h>
-/** Redirect debug log to boost log */
+#include <iostream>
+
+/** Redirect debug log to unit_test.log files */
const std::function<void(const std::string&)> G_TEST_LOG_FUN = [](const std::string& s) {
- if (s.back() == '\n') {
- // boost will insert the new line
- BOOST_TEST_MESSAGE(s.substr(0, s.size() - 1));
- } else {
- BOOST_TEST_MESSAGE(s);
- }
+ static const bool should_log{std::any_of(
+ &boost::unit_test::framework::master_test_suite().argv[1],
+ &boost::unit_test::framework::master_test_suite().argv[boost::unit_test::framework::master_test_suite().argc],
+ [](const char* arg) {
+ return std::string{"DEBUG_LOG_OUT"} == arg;
+ })};
+ if (!should_log) return;
+ std::cout << s;
};