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.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);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <util/time.h>
|
||||
#include <util/translation.h>
|
||||
#include <util/url.h>
|
||||
#include <util/vector.h>
|
||||
#include <validation.h>
|
||||
#include <validationinterface.h>
|
||||
|
||||
|
@ -65,17 +66,34 @@ std::ostream& operator<<(std::ostream& os, const uint256& num)
|
|||
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()}
|
||||
{
|
||||
const std::vector<const char*> arguments = Cat(
|
||||
{
|
||||
"dummy",
|
||||
"-printtoconsole=0",
|
||||
"-logtimemicros",
|
||||
"-debug",
|
||||
"-debugexclude=libevent",
|
||||
"-debugexclude=leveldb",
|
||||
},
|
||||
extra_args);
|
||||
fs::create_directories(m_path_root);
|
||||
gArgs.ForceSetArg("-datadir", m_path_root.string());
|
||||
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);
|
||||
SeedInsecureRand();
|
||||
gArgs.ForceSetArg("-printtoconsole", "0");
|
||||
if (G_TEST_LOG_FUN) LogInstance().PushBackCallback(G_TEST_LOG_FUN);
|
||||
InitLogging();
|
||||
AppInitParameterInteraction();
|
||||
LogInstance().StartLogging();
|
||||
SHA256AutoDetect();
|
||||
ECC_Start();
|
||||
|
@ -95,10 +113,12 @@ BasicTestingSetup::~BasicTestingSetup()
|
|||
{
|
||||
LogInstance().DisconnectTestLogger();
|
||||
fs::remove_all(m_path_root);
|
||||
gArgs.ClearArgs();
|
||||
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();
|
||||
// Ideally we'd move all the RPC tests to the functional testing framework
|
||||
|
|
|
@ -75,7 +75,7 @@ struct BasicTestingSetup {
|
|||
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();
|
||||
|
||||
private:
|
||||
|
@ -88,7 +88,7 @@ private:
|
|||
struct TestingSetup : public BasicTestingSetup {
|
||||
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();
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue