mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
test: Add optional extra_args to testing setup
This commit is contained in:
parent
fad4fa7e2f
commit
fa0cbd48c4
3 changed files with 27 additions and 5 deletions
|
@ -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;
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -75,7 +75,7 @@ struct BasicTestingSetup {
|
||||||
ECCVerifyHandle globalVerifyHandle;
|
ECCVerifyHandle globalVerifyHandle;
|
||||||
NodeContext m_node;
|
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:
|
||||||
|
@ -88,7 +88,7 @@ private:
|
||||||
struct TestingSetup : public BasicTestingSetup {
|
struct TestingSetup : public BasicTestingSetup {
|
||||||
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();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue