aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-06-20 09:34:45 -0400
committerMarcoFalke <falke.marco@gmail.com>2019-06-20 12:12:24 -0400
commitfabc57e07dc34c103552cb51c9277bb48ef97739 (patch)
tree34b541df706817511b175e3a75e3060d593d99a5 /src
parentfa4a04a5a942d582c62773d815c7e1e9897975d0 (diff)
test: Log to debug.log in all tests
Diffstat (limited to 'src')
-rw-r--r--src/logging.cpp8
-rw-r--r--src/logging.h2
-rw-r--r--src/qt/test/apptests.cpp2
-rw-r--r--src/qt/test/rpcnestedtests.cpp1
-rw-r--r--src/test/setup_common.cpp7
5 files changed, 19 insertions, 1 deletions
diff --git a/src/logging.cpp b/src/logging.cpp
index 418a701179..dc2d130a2a 100644
--- a/src/logging.cpp
+++ b/src/logging.cpp
@@ -75,6 +75,14 @@ bool BCLog::Logger::StartLogging()
return true;
}
+void BCLog::Logger::DisconnectTestLogger()
+{
+ std::lock_guard<std::mutex> scoped_lock(m_cs);
+ m_buffering = true;
+ if (m_fileout != nullptr) fclose(m_fileout);
+ m_fileout = nullptr;
+}
+
void BCLog::Logger::EnableCategory(BCLog::LogFlags flag)
{
m_categories |= flag;
diff --git a/src/logging.h b/src/logging.h
index 36b1a4045d..75cd5353c0 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -100,6 +100,8 @@ namespace BCLog {
/** Start logging (and flush all buffered messages) */
bool StartLogging();
+ /** Only for testing */
+ void DisconnectTestLogger();
void ShrinkDebugFile();
diff --git a/src/qt/test/apptests.cpp b/src/qt/test/apptests.cpp
index 27f6377bca..22e49b06cb 100644
--- a/src/qt/test/apptests.cpp
+++ b/src/qt/test/apptests.cpp
@@ -64,6 +64,8 @@ void AppTests::appTests()
#endif
ECC_Stop(); // Already started by the common test setup, so stop it to avoid interference
+ LogInstance().DisconnectTestLogger();
+
m_app.parameterSetup();
m_app.createOptionsModel(true /* reset settings */);
QScopedPointer<const NetworkStyle> style(
diff --git a/src/qt/test/rpcnestedtests.cpp b/src/qt/test/rpcnestedtests.cpp
index 7a10ada438..86e5632e2c 100644
--- a/src/qt/test/rpcnestedtests.cpp
+++ b/src/qt/test/rpcnestedtests.cpp
@@ -35,6 +35,7 @@ void RPCNestedTests::rpcNestedTests()
tableRPC.appendCommand("rpcNestedTest", &vRPCCommands[0]);
//mempool.setSanityCheck(1.0);
+ LogInstance().DisconnectTestLogger(); // Already started by the common test setup, so stop it to avoid interference
TestingSetup test;
if (RPCIsInWarmup(nullptr)) SetRPCWarmupFinished();
diff --git a/src/test/setup_common.cpp b/src/test/setup_common.cpp
index fe98a1ceac..aaf69b9575 100644
--- a/src/test/setup_common.cpp
+++ b/src/test/setup_common.cpp
@@ -10,6 +10,7 @@
#include <consensus/params.h>
#include <consensus/validation.h>
#include <crypto/sha256.h>
+#include <init.h>
#include <miner.h>
#include <net_processing.h>
#include <noui.h>
@@ -37,6 +38,10 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
fs::create_directories(m_path_root);
gArgs.ForceSetArg("-datadir", m_path_root.string());
ClearDatadirCache();
+ SelectParams(chainName);
+ gArgs.ForceSetArg("-printtoconsole", "0");
+ InitLogging();
+ LogInstance().StartLogging();
SHA256AutoDetect();
ECC_Start();
SetupEnvironment();
@@ -44,7 +49,6 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
InitSignatureCache();
InitScriptExecutionCache();
fCheckBlockIndex = true;
- SelectParams(chainName);
static bool noui_connected = false;
if (!noui_connected) {
noui_connect();
@@ -54,6 +58,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
BasicTestingSetup::~BasicTestingSetup()
{
+ LogInstance().DisconnectTestLogger();
fs::remove_all(m_path_root);
ECC_Stop();
}