bench: add support for custom data directory

Expands the benchmark framework with the existing '-testdatadir' arg,
enabling the ability to change the benchmark data directory.

This is useful for running benchmarks on different storage devices, and
not just under the OS /tmp/ directory.
This commit is contained in:
furszy
2023-12-28 23:51:13 -03:00
parent ad9c2cceda
commit fa66e0887c
5 changed files with 38 additions and 4 deletions

View File

@@ -85,8 +85,7 @@ struct NetworkSetup
};
static NetworkSetup g_networksetup_instance;
/** Register test-only arguments */
static void SetupUnitTestArgs(ArgsManager& argsman)
void SetupCommonTestArgs(ArgsManager& argsman)
{
argsman.AddArg("-testdatadir", strprintf("Custom data directory (default: %s<random_string>)", fs::PathToString(fs::temp_directory_path() / TEST_DIR_PATH_ELEMENT / "")),
ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
@@ -125,7 +124,7 @@ BasicTestingSetup::BasicTestingSetup(const ChainType chainType, TestOpts opts)
gArgs.ClearPathCache();
{
SetupServerArgs(*m_node.args);
SetupUnitTestArgs(*m_node.args);
SetupCommonTestArgs(*m_node.args);
std::string error;
if (!m_node.args->ParseParameters(arguments.size(), arguments.data(), error)) {
m_node.args->ClearArgs();

View File

@@ -45,6 +45,9 @@ extern const std::function<std::string()> G_TEST_GET_FULL_NAME;
static constexpr CAmount CENT{1000000};
/** Register common test args. Shared across binaries that rely on the test framework. */
void SetupCommonTestArgs(ArgsManager& argsman);
struct TestOpts {
std::vector<const char*> extra_args{};
bool coins_db_in_memory{true};