diff --git a/contrib/teamcity/builds/build-tsan.sh b/contrib/teamcity/builds/build-tsan.sh --- a/contrib/teamcity/builds/build-tsan.sh +++ b/contrib/teamcity/builds/build-tsan.sh @@ -13,7 +13,9 @@ ) build_with_cmake --Werror --clang -run_test_bitcoin "with thread sanitizer" +# TSAN runs out of memory with the default radix_tests/insert_stress_test values +run_test_bitcoin "with thread sanitizer" \ + -radix_insert_stress_test_threads=16 -radix_insert_stress_test_elements=128 # Libs and utils tests ninja check diff --git a/src/test/main.cpp b/src/test/main.cpp --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -24,6 +24,13 @@ testsuitename, "-phononactivationtime", "-axionactivationtime", + /* + * Radix tests custom arguments. + * TODO find a way to move the test exclusive arguments to the test + * they belong. + */ + "-radix_insert_stress_test_threads", + "-radix_insert_stress_test_elements", }; for (const auto &arg : testArgs) { diff --git a/src/test/radix_tests.cpp b/src/test/radix_tests.cpp --- a/src/test/radix_tests.cpp +++ b/src/test/radix_tests.cpp @@ -307,20 +307,20 @@ CheckConstTree(mytree, false); } -#define THREADS 128 -#define ELEMENTS 65536 - BOOST_AUTO_TEST_CASE(insert_stress_test) { typedef TestElement E; + int nThreads = gArgs.GetArg("-radix_insert_stress_test_threads", 128); + int nElements = gArgs.GetArg("-radix_insert_stress_test_elements", 65536); + RadixTree mytree; std::atomic success{0}; std::vector threads; - for (int i = 0; i < THREADS; i++) { + for (int i = 0; i < nThreads; i++) { threads.push_back(std::thread([&] { MMIXLinearCongruentialGenerator lcg; - for (int j = 0; j < ELEMENTS; j++) { + for (int j = 0; j < nElements; j++) { uint32_t v = lcg.next(); if (mytree.remove(v)) { @@ -352,11 +352,11 @@ t.join(); } - BOOST_CHECK_EQUAL(success.load(), ELEMENTS); + BOOST_CHECK_EQUAL(success.load(), nElements); // All the elements have been inserted into the tree. MMIXLinearCongruentialGenerator lcg; - for (int i = 0; i < ELEMENTS; i++) { + for (int i = 0; i < nElements; i++) { uint32_t v = lcg.next(); BOOST_CHECK_EQUAL(mytree.get(v)->getId(), v); auto ptr = RCUPtr::make(v);