Skip to content

Commit

Permalink
test: Remove unsafe BOOST_TEST_MESSAGE
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed Mar 30, 2020
1 parent 5f9cd62 commit fa93702
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/Makefile.test.include
Expand Up @@ -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)
Expand Down
16 changes: 9 additions & 7 deletions src/test/main.cpp
Expand Up @@ -11,12 +11,14 @@

#include <test/util/setup_common.h>

/** Redirect debug log to boost log */
/** 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;
};
8 changes: 0 additions & 8 deletions test/sanitizer_suppressions/tsan
Expand Up @@ -7,14 +7,6 @@ deadlock:WalletBatch
# Intentional deadlock in tests
deadlock:TestPotentialDeadLockDetected

# Race due to unprotected calls to thread-unsafe BOOST_TEST_MESSAGE from different threads:
# * G_TEST_LOG_FUN in the index thread
# * boost test case invoker (entering a test case) in the main thread
# TODO: get rid of BOOST_ macros, see also https://github.com/bitcoin/bitcoin/issues/8670
race:blockfilter_index_initial_sync_invoker
race:txindex_initial_sync_invoker
race:validation_block_tests::TestSubscriber

# Wildcard for all gui tests, should be replaced with non-wildcard suppressions
race:src/qt/test/*
deadlock:src/qt/test/*
Expand Down

0 comments on commit fa93702

Please sign in to comment.