Merge #18571: fuzz: Disable debug log file
fa69f88486fuzz: Disable debug log file (MarcoFalke)fa0cbd48c4test: Add optional extra_args to testing setup (MarcoFalke)fad4fa7e2fnode: Add args alias for gArgs global (MarcoFalke) Pull request description: There are several issues with writing to a debug log file when fuzzing: * Disk access is slow, but fuzzing should be fast (Note: I could not verify this claim with data) * Disks have a limited size and will eventually run out of space, but fuzzing should run continuous Fix both issues by disabling the debug log file for fuzz tests ACKs for top commit: practicalswift: ACKfa69f88486-- patch looks correct Tree-SHA512: f61beb6c94a9ab664deb191685fcad601e228b77bb1c43db6ec40616ae393c9dd35c51474f1b0759ac0bc29b5ca8456a329906a3695bd0f18fa4372210c8b54a
This commit is contained in:
10 files changed
+55
-15
No files matched your search
@@ -73,6 +73,8 @@ int main(int argc, char** argv)
|
|||||||
gArgs.GetArg("-plot-height", DEFAULT_PLOT_HEIGHT)));
|
gArgs.GetArg("-plot-height", DEFAULT_PLOT_HEIGHT)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gArgs.ClearArgs(); // gArgs no longer needed. Clear it here to avoid interactions with the testing setup in the benches
|
||||||
|
|
||||||
benchmark::BenchRunner::RunAll(*printer, evaluations, scaling_factor, regex_filter, is_list_only);
|
benchmark::BenchRunner::RunAll(*printer, evaluations, scaling_factor, regex_filter, is_list_only);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@ static bool AppInit(int argc, char* argv[])
|
|||||||
// Parameters
|
// Parameters
|
||||||
//
|
//
|
||||||
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main()
|
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main()
|
||||||
SetupServerArgs();
|
SetupServerArgs(node);
|
||||||
std::string error;
|
std::string error;
|
||||||
if (!gArgs.ParseParameters(argc, argv, error)) {
|
if (!gArgs.ParseParameters(argc, argv, error)) {
|
||||||
return InitError(strprintf("Error parsing command line arguments: %s\n", error));
|
return InitError(strprintf("Error parsing command line arguments: %s\n", error));
|
||||||
|
|||||||
+5
-1
@@ -297,6 +297,7 @@ void Shutdown(NodeContext& node)
|
|||||||
GetMainSignals().UnregisterBackgroundSignalScheduler();
|
GetMainSignals().UnregisterBackgroundSignalScheduler();
|
||||||
globalVerifyHandle.reset();
|
globalVerifyHandle.reset();
|
||||||
ECC_Stop();
|
ECC_Stop();
|
||||||
|
node.args = nullptr;
|
||||||
if (node.mempool) node.mempool = nullptr;
|
if (node.mempool) node.mempool = nullptr;
|
||||||
node.scheduler.reset();
|
node.scheduler.reset();
|
||||||
|
|
||||||
@@ -360,8 +361,11 @@ static void OnRPCStopped()
|
|||||||
LogPrint(BCLog::RPC, "RPC stopped.\n");
|
LogPrint(BCLog::RPC, "RPC stopped.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupServerArgs()
|
void SetupServerArgs(NodeContext& node)
|
||||||
{
|
{
|
||||||
|
assert(!node.args);
|
||||||
|
node.args = &gArgs;
|
||||||
|
|
||||||
SetupHelpOptions(gArgs);
|
SetupHelpOptions(gArgs);
|
||||||
gArgs.AddArg("-help-debug", "Print help message with debugging options and exit", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); // server-only for now
|
gArgs.AddArg("-help-debug", "Print help message with debugging options and exit", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); // server-only for now
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -54,9 +54,9 @@ bool AppInitLockDataDirectory();
|
|||||||
bool AppInitMain(NodeContext& node);
|
bool AppInitMain(NodeContext& node);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the arguments for gArgs
|
* Register all arguments with the ArgsManager
|
||||||
*/
|
*/
|
||||||
void SetupServerArgs();
|
void SetupServerArgs(NodeContext& node);
|
||||||
|
|
||||||
/** Returns licensing information (for -version) */
|
/** Returns licensing information (for -version) */
|
||||||
std::string LicenseInfo();
|
std::string LicenseInfo();
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public:
|
|||||||
StopMapPort();
|
StopMapPort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void setupServerArgs() override { return SetupServerArgs(); }
|
void setupServerArgs() override { return SetupServerArgs(m_context); }
|
||||||
bool getProxy(Network net, proxyType& proxy_info) override { return GetProxy(net, proxy_info); }
|
bool getProxy(Network net, proxyType& proxy_info) override { return GetProxy(net, proxy_info); }
|
||||||
size_t getNodeCount(CConnman::NumConnections flags) override
|
size_t getNodeCount(CConnman::NumConnections flags) override
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
class ArgsManager;
|
||||||
class BanMan;
|
class BanMan;
|
||||||
class CConnman;
|
class CConnman;
|
||||||
class CScheduler;
|
class CScheduler;
|
||||||
@@ -33,6 +34,7 @@ struct NodeContext {
|
|||||||
CTxMemPool* mempool{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
|
CTxMemPool* mempool{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
|
||||||
std::unique_ptr<PeerLogicValidation> peer_logic;
|
std::unique_ptr<PeerLogicValidation> peer_logic;
|
||||||
std::unique_ptr<BanMan> banman;
|
std::unique_ptr<BanMan> banman;
|
||||||
|
ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
|
||||||
std::unique_ptr<interfaces::Chain> chain;
|
std::unique_ptr<interfaces::Chain> chain;
|
||||||
std::vector<std::unique_ptr<interfaces::ChainClient>> chain_clients;
|
std::vector<std::unique_ptr<interfaces::ChainClient>> chain_clients;
|
||||||
std::unique_ptr<CScheduler> scheduler;
|
std::unique_ptr<CScheduler> scheduler;
|
||||||
|
|||||||
@@ -57,12 +57,17 @@ const std::map<std::string, std::set<std::string>> EXPECTED_DESERIALIZATION_EXCE
|
|||||||
{"Unknown transaction optional data: iostream error", {"block", "blocktxn", "cmpctblock", "tx"}},
|
{"Unknown transaction optional data: iostream error", {"block", "blocktxn", "cmpctblock", "tx"}},
|
||||||
};
|
};
|
||||||
|
|
||||||
const RegTestingSetup* g_setup;
|
const TestingSetup* g_setup;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void initialize()
|
void initialize()
|
||||||
{
|
{
|
||||||
static RegTestingSetup setup{};
|
static TestingSetup setup{
|
||||||
|
CBaseChainParams::REGTEST,
|
||||||
|
{
|
||||||
|
"-nodebuglogfile",
|
||||||
|
},
|
||||||
|
};
|
||||||
g_setup = &setup;
|
g_setup = &setup;
|
||||||
|
|
||||||
for (int i = 0; i < 2 * COINBASE_MATURITY; i++) {
|
for (int i = 0; i < 2 * COINBASE_MATURITY; i++) {
|
||||||
|
|||||||
@@ -16,11 +16,16 @@
|
|||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
#include <validationinterface.h>
|
#include <validationinterface.h>
|
||||||
|
|
||||||
const RegTestingSetup* g_setup;
|
const TestingSetup* g_setup;
|
||||||
|
|
||||||
void initialize()
|
void initialize()
|
||||||
{
|
{
|
||||||
static RegTestingSetup setup{};
|
static TestingSetup setup{
|
||||||
|
CBaseChainParams::REGTEST,
|
||||||
|
{
|
||||||
|
"-nodebuglogfile",
|
||||||
|
},
|
||||||
|
};
|
||||||
g_setup = &setup;
|
g_setup = &setup;
|
||||||
|
|
||||||
for (int i = 0; i < 2 * COINBASE_MATURITY; i++) {
|
for (int i = 0; i < 2 * COINBASE_MATURITY; i++) {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <util/time.h>
|
#include <util/time.h>
|
||||||
#include <util/translation.h>
|
#include <util/translation.h>
|
||||||
#include <util/url.h>
|
#include <util/url.h>
|
||||||
|
#include <util/vector.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
#include <validationinterface.h>
|
#include <validationinterface.h>
|
||||||
|
|
||||||
@@ -65,17 +66,34 @@ std::ostream& operator<<(std::ostream& os, const uint256& num)
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
|
BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::vector<const char*>& extra_args)
|
||||||
: m_path_root{fs::temp_directory_path() / "test_common_" PACKAGE_NAME / g_insecure_rand_ctx_temp_path.rand256().ToString()}
|
: m_path_root{fs::temp_directory_path() / "test_common_" PACKAGE_NAME / g_insecure_rand_ctx_temp_path.rand256().ToString()}
|
||||||
{
|
{
|
||||||
|
const std::vector<const char*> arguments = Cat(
|
||||||
|
{
|
||||||
|
"dummy",
|
||||||
|
"-printtoconsole=0",
|
||||||
|
"-logtimemicros",
|
||||||
|
"-debug",
|
||||||
|
"-debugexclude=libevent",
|
||||||
|
"-debugexclude=leveldb",
|
||||||
|
},
|
||||||
|
extra_args);
|
||||||
fs::create_directories(m_path_root);
|
fs::create_directories(m_path_root);
|
||||||
gArgs.ForceSetArg("-datadir", m_path_root.string());
|
gArgs.ForceSetArg("-datadir", m_path_root.string());
|
||||||
ClearDatadirCache();
|
ClearDatadirCache();
|
||||||
|
{
|
||||||
|
SetupServerArgs(m_node);
|
||||||
|
std::string error;
|
||||||
|
const bool success{m_node.args->ParseParameters(arguments.size(), arguments.data(), error)};
|
||||||
|
assert(success);
|
||||||
|
assert(error.empty());
|
||||||
|
}
|
||||||
SelectParams(chainName);
|
SelectParams(chainName);
|
||||||
SeedInsecureRand();
|
SeedInsecureRand();
|
||||||
gArgs.ForceSetArg("-printtoconsole", "0");
|
|
||||||
if (G_TEST_LOG_FUN) LogInstance().PushBackCallback(G_TEST_LOG_FUN);
|
if (G_TEST_LOG_FUN) LogInstance().PushBackCallback(G_TEST_LOG_FUN);
|
||||||
InitLogging();
|
InitLogging();
|
||||||
|
AppInitParameterInteraction();
|
||||||
LogInstance().StartLogging();
|
LogInstance().StartLogging();
|
||||||
SHA256AutoDetect();
|
SHA256AutoDetect();
|
||||||
ECC_Start();
|
ECC_Start();
|
||||||
@@ -95,10 +113,12 @@ BasicTestingSetup::~BasicTestingSetup()
|
|||||||
{
|
{
|
||||||
LogInstance().DisconnectTestLogger();
|
LogInstance().DisconnectTestLogger();
|
||||||
fs::remove_all(m_path_root);
|
fs::remove_all(m_path_root);
|
||||||
|
gArgs.ClearArgs();
|
||||||
ECC_Stop();
|
ECC_Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
|
TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const char*>& extra_args)
|
||||||
|
: BasicTestingSetup(chainName, extra_args)
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
// Ideally we'd move all the RPC tests to the functional testing framework
|
// Ideally we'd move all the RPC tests to the functional testing framework
|
||||||
@@ -159,6 +179,7 @@ TestingSetup::~TestingSetup()
|
|||||||
g_rpc_node = nullptr;
|
g_rpc_node = nullptr;
|
||||||
m_node.connman.reset();
|
m_node.connman.reset();
|
||||||
m_node.banman.reset();
|
m_node.banman.reset();
|
||||||
|
m_node.args = nullptr;
|
||||||
m_node.mempool = nullptr;
|
m_node.mempool = nullptr;
|
||||||
m_node.scheduler.reset();
|
m_node.scheduler.reset();
|
||||||
UnloadBlockIndex();
|
UnloadBlockIndex();
|
||||||
|
|||||||
@@ -73,9 +73,11 @@ static constexpr CAmount CENT{1000000};
|
|||||||
*/
|
*/
|
||||||
struct BasicTestingSetup {
|
struct BasicTestingSetup {
|
||||||
ECCVerifyHandle globalVerifyHandle;
|
ECCVerifyHandle globalVerifyHandle;
|
||||||
|
NodeContext m_node;
|
||||||
|
|
||||||
explicit BasicTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
|
explicit BasicTestingSetup(const std::string& chainName = CBaseChainParams::MAIN, const std::vector<const char*>& extra_args = {});
|
||||||
~BasicTestingSetup();
|
~BasicTestingSetup();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const fs::path m_path_root;
|
const fs::path m_path_root;
|
||||||
};
|
};
|
||||||
@@ -84,10 +86,9 @@ private:
|
|||||||
* Included are coins database, script check threads setup.
|
* Included are coins database, script check threads setup.
|
||||||
*/
|
*/
|
||||||
struct TestingSetup : public BasicTestingSetup {
|
struct TestingSetup : public BasicTestingSetup {
|
||||||
NodeContext m_node;
|
|
||||||
boost::thread_group threadGroup;
|
boost::thread_group threadGroup;
|
||||||
|
|
||||||
explicit TestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
|
explicit TestingSetup(const std::string& chainName = CBaseChainParams::MAIN, const std::vector<const char*>& extra_args = {});
|
||||||
~TestingSetup();
|
~TestingSetup();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user