Skip to content

Commit 72ef366

Browse files
author
MarcoFalke
committed
Merge #18472: test: Remove unsafe BOOST_TEST_MESSAGE
fa3cc0b 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 fa3cc0b mzumsande: Tested ACK fa3cc0b Tree-SHA512: f63b110d77882cd7c0d7574ff6c9c948db8febb3400ecdac45164746b587b0fa223463041801271b3959267ddc1d9a4a67ba76939e242e7dd2f92a2834a400a0
2 parents d52ba21 + fa3cc0b commit 72ef366

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

src/Makefile.test.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ endif
10111011

10121012
%.cpp.test: %.cpp
10131013
@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 $<
1014-
$(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)
1014+
$(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)
10151015

10161016
%.json.h: %.json
10171017
@$(MKDIR_P) $(@D)

src/test/main.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@
1111

1212
#include <test/util/setup_common.h>
1313

14-
/** Redirect debug log to boost log */
14+
#include <iostream>
15+
16+
/** Redirect debug log to unit_test.log files */
1517
const std::function<void(const std::string&)> G_TEST_LOG_FUN = [](const std::string& s) {
16-
if (s.back() == '\n') {
17-
// boost will insert the new line
18-
BOOST_TEST_MESSAGE(s.substr(0, s.size() - 1));
19-
} else {
20-
BOOST_TEST_MESSAGE(s);
21-
}
18+
static const bool should_log{std::any_of(
19+
&boost::unit_test::framework::master_test_suite().argv[1],
20+
&boost::unit_test::framework::master_test_suite().argv[boost::unit_test::framework::master_test_suite().argc],
21+
[](const char* arg) {
22+
return std::string{"DEBUG_LOG_OUT"} == arg;
23+
})};
24+
if (!should_log) return;
25+
std::cout << s;
2226
};

test/sanitizer_suppressions/tsan

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@ deadlock:WalletBatch
77
# Intentional deadlock in tests
88
deadlock:TestPotentialDeadLockDetected
99

10-
# Race due to unprotected calls to thread-unsafe BOOST_TEST_MESSAGE from different threads:
11-
# * G_TEST_LOG_FUN in the index thread
12-
# * boost test case invoker (entering a test case) in the main thread
13-
# TODO: get rid of BOOST_ macros, see also https://github.com/bitcoin/bitcoin/issues/8670
14-
race:blockfilter_index_initial_sync_invoker
15-
race:txindex_initial_sync_invoker
16-
race:validation_block_tests::TestSubscriber
17-
1810
# Wildcard for all gui tests, should be replaced with non-wildcard suppressions
1911
race:src/qt/test/*
2012
deadlock:src/qt/test/*

0 commit comments

Comments
 (0)