mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
test: Show debug log on unit test failure
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
const RegTestingSetup* g_testing_setup = nullptr;
|
const RegTestingSetup* g_testing_setup = nullptr;
|
||||||
|
const std::function<void(const std::string&)> G_TEST_LOG_FUN{};
|
||||||
|
|
||||||
void benchmark::ConsolePrinter::header()
|
void benchmark::ConsolePrinter::header()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const std::function<void(const std::string&)> G_TEST_LOG_FUN{};
|
||||||
|
|
||||||
// This is all you need to run all the tests
|
// This is all you need to run all the tests
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,10 +4,14 @@
|
|||||||
|
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
|
|
||||||
|
#include <test/util/setup_common.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
const std::function<void(const std::string&)> G_TEST_LOG_FUN{};
|
||||||
|
|
||||||
static bool read_stdin(std::vector<uint8_t>& data)
|
static bool read_stdin(std::vector<uint8_t>& data)
|
||||||
{
|
{
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
|
|||||||
@@ -2,6 +2,21 @@
|
|||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See https://www.boost.org/doc/libs/1_71_0/libs/test/doc/html/boost_test/utf_reference/link_references/link_boost_test_module_macro.html
|
||||||
|
*/
|
||||||
#define BOOST_TEST_MODULE Bitcoin Core Test Suite
|
#define BOOST_TEST_MODULE Bitcoin Core Test Suite
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
|
#include <test/util/setup_common.h>
|
||||||
|
|
||||||
|
/** Redirect debug log to boost log */
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
|
|||||||
SelectParams(chainName);
|
SelectParams(chainName);
|
||||||
SeedInsecureRand();
|
SeedInsecureRand();
|
||||||
gArgs.ForceSetArg("-printtoconsole", "0");
|
gArgs.ForceSetArg("-printtoconsole", "0");
|
||||||
|
if (G_TEST_LOG_FUN) LogInstance().PushBackCallback(G_TEST_LOG_FUN);
|
||||||
InitLogging();
|
InitLogging();
|
||||||
LogInstance().StartLogging();
|
LogInstance().StartLogging();
|
||||||
SHA256AutoDetect();
|
SHA256AutoDetect();
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
|
|
||||||
|
/** This is connected to the logger. Can be used to redirect logs to any other log */
|
||||||
|
extern const std::function<void(const std::string&)> G_TEST_LOG_FUN;
|
||||||
|
|
||||||
// Enable BOOST_CHECK_EQUAL for enum class types
|
// Enable BOOST_CHECK_EQUAL for enum class types
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::ostream& operator<<(typename std::enable_if<std::is_enum<T>::value, std::ostream>::type& stream, const T& e)
|
std::ostream& operator<<(typename std::enable_if<std::is_enum<T>::value, std::ostream>::type& stream, const T& e)
|
||||||
|
|||||||
@@ -7,6 +7,14 @@ deadlock:WalletBatch
|
|||||||
# Intentional deadlock in tests
|
# Intentional deadlock in tests
|
||||||
deadlock:TestPotentialDeadLockDetected
|
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
|
# Wildcard for all gui tests, should be replaced with non-wildcard suppressions
|
||||||
race:src/qt/test/*
|
race:src/qt/test/*
|
||||||
deadlock:src/qt/test/*
|
deadlock:src/qt/test/*
|
||||||
|
|||||||
Reference in New Issue
Block a user