From c92ca6fb935baeb5c412279cf23a7682928deaa0 Mon Sep 17 00:00:00 2001 From: sowle Date: Fri, 31 May 2024 15:51:42 +0200 Subject: [PATCH] chaingen: --run-single-test now accepts specific HF, e.g.: --run-single-test=test_name@4 --- tests/core_tests/chaingen_main.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/core_tests/chaingen_main.cpp b/tests/core_tests/chaingen_main.cpp index aad760ea..6eb28944 100644 --- a/tests/core_tests/chaingen_main.cpp +++ b/tests/core_tests/chaingen_main.cpp @@ -26,7 +26,7 @@ namespace const command_line::arg_descriptor arg_play_test_data ("play-test-data", ""); const command_line::arg_descriptor arg_generate_and_play_test_data ("generate-and-play-test-data", ""); const command_line::arg_descriptor arg_test_transactions ("test-transactions", ""); - const command_line::arg_descriptor arg_run_single_test ("run-single-test", "" ); + const command_line::arg_descriptor arg_run_single_test ("run-single-test", " TEST_NAME -- name of a single test to run, HF -- specific hardfork id to run the test for" ); const command_line::arg_descriptor arg_enable_debug_asserts ("enable-debug-asserts", "" ); const command_line::arg_descriptor 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 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())