mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 17:54:19 +02:00
tests: speed up coins_tests by parallelizing
Updates the cmake logic to generate a separate test for each BOOST_FIXTURE_TEST_SUITE declaration in a file, and splits coins_tests.cpp into three separate suites so that they can be run in parallel. Also updates the convention enforced by test/lint/lint-tests.py.
This commit is contained in:
@@ -183,21 +183,20 @@ function(add_boost_test source_file)
|
||||
|
||||
file(READ "${source_file}" source_file_content)
|
||||
string(REGEX
|
||||
MATCH "(BOOST_FIXTURE_TEST_SUITE|BOOST_AUTO_TEST_SUITE)\\(([A-Za-z0-9_]+)"
|
||||
MATCHALL "(BOOST_FIXTURE_TEST_SUITE|BOOST_AUTO_TEST_SUITE)\\(([A-Za-z0-9_]+)"
|
||||
test_suite_macro "${source_file_content}"
|
||||
)
|
||||
string(REGEX
|
||||
list(TRANSFORM test_suite_macro
|
||||
REPLACE "(BOOST_FIXTURE_TEST_SUITE|BOOST_AUTO_TEST_SUITE)\\(" ""
|
||||
test_suite_name "${test_suite_macro}"
|
||||
)
|
||||
if(test_suite_name)
|
||||
foreach(test_suite_name IN LISTS test_suite_macro)
|
||||
add_test(NAME ${test_suite_name}
|
||||
COMMAND test_bitcoin --run_test=${test_suite_name} --catch_system_error=no --log_level=test_suite -- DEBUG_LOG_OUT
|
||||
)
|
||||
set_property(TEST ${test_suite_name} PROPERTY
|
||||
SKIP_REGULAR_EXPRESSION "no test cases matching filter"
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(add_all_test_targets)
|
||||
|
||||
@@ -104,8 +104,6 @@ public:
|
||||
|
||||
} // namespace
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(coins_tests, BasicTestingSetup)
|
||||
|
||||
static const unsigned int NUM_SIMULATION_ITERATIONS = 40000;
|
||||
|
||||
struct CacheTest : BasicTestingSetup {
|
||||
@@ -283,16 +281,29 @@ void SimulationTest(CCoinsView* base, bool fake_best_block)
|
||||
}
|
||||
}; // struct CacheTest
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(coins_tests_base, BasicTestingSetup)
|
||||
|
||||
// Run the above simulation for multiple base types.
|
||||
BOOST_FIXTURE_TEST_CASE(coins_cache_simulation_test, CacheTest)
|
||||
BOOST_FIXTURE_TEST_CASE(coins_cache_base_simulation_test, CacheTest)
|
||||
{
|
||||
CCoinsViewTest base{m_rng};
|
||||
SimulationTest(&base, false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(coins_tests_dbbase, BasicTestingSetup)
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(coins_cache_dbbase_simulation_test, CacheTest)
|
||||
{
|
||||
CCoinsViewDB db_base{{.path = "test", .cache_bytes = 1 << 23, .memory_only = true}, {}};
|
||||
SimulationTest(&db_base, true);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(coins_tests, BasicTestingSetup)
|
||||
|
||||
struct UpdateTest : BasicTestingSetup {
|
||||
// Store of all necessary tx and undo data for next test
|
||||
typedef std::map<COutPoint, std::tuple<CTransaction,CTxUndo,Coin>> UtxoData;
|
||||
|
||||
Reference in New Issue
Block a user