1
0
Fork 0
forked from lthn/blockchain

chaingen: --run-single-test now accepts specific HF, e.g.: --run-single-test=test_name@4

This commit is contained in:
sowle 2024-05-31 15:51:42 +02:00
parent 092e0f1e60
commit c92ca6fb93
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC

View file

@ -26,7 +26,7 @@ namespace
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_test_transactions ("test-transactions", "");
const command_line::arg_descriptor<std::string> arg_run_single_test ("run-single-test", "" );
const command_line::arg_descriptor<std::string> arg_run_single_test ("run-single-test", "<TEST_NAME[@HF]> TEST_NAME -- name of a single test to run, HF -- specific hardfork id to run the test for" );
const command_line::arg_descriptor<bool> arg_enable_debug_asserts ("enable-debug-asserts", "" );
const command_line::arg_descriptor<bool> arg_stop_on_fail ("stop-on-fail", "");
@ -428,6 +428,8 @@ bool gen_and_play_intermitted_by_blockchain_saveload(const char* const genclass_
CHECK_AND_ASSERT_MES(!hardforks.empty(), false, "invalid hardforks mask: " << hardfork_str_mask); \
for(size_t i = 0; i < hardforks.size() && !skip_all_till_the_end; ++i) \
{ \
if (run_single_test_hardfork != SIZE_MAX && hardforks[i] != run_single_test_hardfork) \
continue; \
std::string tns = std::string(#genclass) + " @ HF " + epee::string_tools::num_to_string_fast(hardforks[i]); \
const char* testname = tns.c_str(); \
TIME_MEASURE_START_MS(t); \
@ -916,9 +918,19 @@ int main(int argc, char* argv[])
epee::debug::get_set_enable_assert(true, command_line::get_arg(g_vm, arg_enable_debug_asserts)); // don't comment out this: many tests have normal-negative checks (i.e. tx with invalid amount shouldn't be created), so be ready for MANY assertion breaks
std::string run_single_test;
size_t run_single_test_hardfork = SIZE_MAX; // SIZE_MAX means all hard forks, other values mean hardfork id
if (command_line::has_arg(g_vm, arg_run_single_test))
{
run_single_test = command_line::get_arg(g_vm, arg_run_single_test);
std::vector<std::string> items;
boost::split(items, command_line::get_arg(g_vm, arg_run_single_test), boost::is_any_of("@"));
CHECK_AND_ASSERT_MES(items.size() > 0, 2, "unable to parse arg_run_single_test");
run_single_test = items[0];
if (items.size() > 1)
{
int64_t val = 0;
epee::string_tools::string_to_num_fast(items[1], val);
run_single_test_hardfork = val;
}
}
if (run_single_test.empty())