Merge pull request #4110
639ca3b
core_tests: add --filter to select which tests to run (moneromooo-monero)
This commit is contained in:
commit
ff01c3ade4
|
@ -919,4 +919,23 @@ std::string get_nix_version_display_string()
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string glob_to_regex(const std::string &val)
|
||||||
|
{
|
||||||
|
std::string newval;
|
||||||
|
|
||||||
|
bool escape = false;
|
||||||
|
for (char c: val)
|
||||||
|
{
|
||||||
|
if (c == '*')
|
||||||
|
newval += escape ? "*" : ".*";
|
||||||
|
else if (c == '?')
|
||||||
|
newval += escape ? "?" : ".";
|
||||||
|
else if (c == '\\')
|
||||||
|
newval += '\\', escape = !escape;
|
||||||
|
else
|
||||||
|
newval += c;
|
||||||
|
}
|
||||||
|
return newval;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,4 +231,6 @@ namespace tools
|
||||||
bool is_hdd(const char *path);
|
bool is_hdd(const char *path);
|
||||||
|
|
||||||
boost::optional<std::pair<uint32_t, uint32_t>> parse_subaddress_lookahead(const std::string& str);
|
boost::optional<std::pair<uint32_t, uint32_t>> parse_subaddress_lookahead(const std::string& str);
|
||||||
|
|
||||||
|
std::string glob_to_regex(const std::string &val);
|
||||||
}
|
}
|
||||||
|
|
|
@ -664,6 +664,7 @@ inline bool do_replay_file(const std::string& filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GENERATE_AND_PLAY(genclass) \
|
#define GENERATE_AND_PLAY(genclass) \
|
||||||
|
if (filter.empty() || boost::regex_match(std::string(#genclass), match, boost::regex(filter))) \
|
||||||
{ \
|
{ \
|
||||||
std::vector<test_event_entry> events; \
|
std::vector<test_event_entry> events; \
|
||||||
++tests_count; \
|
++tests_count; \
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include "chaingen.h"
|
#include "chaingen.h"
|
||||||
#include "chaingen_tests_list.h"
|
#include "chaingen_tests_list.h"
|
||||||
|
#include "common/util.h"
|
||||||
#include "common/command_line.h"
|
#include "common/command_line.h"
|
||||||
#include "transaction_tests.h"
|
#include "transaction_tests.h"
|
||||||
|
|
||||||
|
@ -42,6 +43,7 @@ namespace
|
||||||
const command_line::arg_descriptor<bool> arg_play_test_data = {"play_test_data", ""};
|
const command_line::arg_descriptor<bool> arg_play_test_data = {"play_test_data", ""};
|
||||||
const command_line::arg_descriptor<bool> arg_generate_and_play_test_data = {"generate_and_play_test_data", ""};
|
const command_line::arg_descriptor<bool> arg_generate_and_play_test_data = {"generate_and_play_test_data", ""};
|
||||||
const command_line::arg_descriptor<bool> arg_test_transactions = {"test_transactions", ""};
|
const command_line::arg_descriptor<bool> arg_test_transactions = {"test_transactions", ""};
|
||||||
|
const command_line::arg_descriptor<std::string> arg_filter = { "filter", "Regular expression filter for which tests to run" };
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
|
@ -61,6 +63,7 @@ int main(int argc, char* argv[])
|
||||||
command_line::add_arg(desc_options, arg_play_test_data);
|
command_line::add_arg(desc_options, arg_play_test_data);
|
||||||
command_line::add_arg(desc_options, arg_generate_and_play_test_data);
|
command_line::add_arg(desc_options, arg_generate_and_play_test_data);
|
||||||
command_line::add_arg(desc_options, arg_test_transactions);
|
command_line::add_arg(desc_options, arg_test_transactions);
|
||||||
|
command_line::add_arg(desc_options, arg_filter);
|
||||||
|
|
||||||
po::variables_map vm;
|
po::variables_map vm;
|
||||||
bool r = command_line::handle_error_helper(desc_options, [&]()
|
bool r = command_line::handle_error_helper(desc_options, [&]()
|
||||||
|
@ -78,6 +81,9 @@ int main(int argc, char* argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string filter = tools::glob_to_regex(command_line::get_arg(vm, arg_filter));
|
||||||
|
boost::smatch match;
|
||||||
|
|
||||||
size_t tests_count = 0;
|
size_t tests_count = 0;
|
||||||
std::vector<std::string> failed_tests;
|
std::vector<std::string> failed_tests;
|
||||||
std::string tests_folder = command_line::get_arg(vm, arg_test_data_path);
|
std::string tests_folder = command_line::get_arg(vm, arg_test_data_path);
|
||||||
|
|
|
@ -54,25 +54,6 @@
|
||||||
|
|
||||||
namespace po = boost::program_options;
|
namespace po = boost::program_options;
|
||||||
|
|
||||||
std::string glob_to_regex(const std::string &val)
|
|
||||||
{
|
|
||||||
std::string newval;
|
|
||||||
|
|
||||||
bool escape = false;
|
|
||||||
for (char c: val)
|
|
||||||
{
|
|
||||||
if (c == '*')
|
|
||||||
newval += escape ? "*" : ".*";
|
|
||||||
else if (c == '?')
|
|
||||||
newval += escape ? "?" : ".";
|
|
||||||
else if (c == '\\')
|
|
||||||
newval += '\\', escape = !escape;
|
|
||||||
else
|
|
||||||
newval += c;
|
|
||||||
}
|
|
||||||
return newval;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
TRY_ENTRY();
|
TRY_ENTRY();
|
||||||
|
@ -97,7 +78,7 @@ int main(int argc, char** argv)
|
||||||
if (!r)
|
if (!r)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
const std::string filter = glob_to_regex(command_line::get_arg(vm, arg_filter));
|
const std::string filter = tools::glob_to_regex(command_line::get_arg(vm, arg_filter));
|
||||||
|
|
||||||
performance_timer timer;
|
performance_timer timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
|
|
Loading…
Reference in New Issue