aboutsummaryrefslogtreecommitdiff
path: root/src/test/checkqueue_tests.cpp
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2023-07-07 10:40:13 +0100
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2023-10-03 10:52:15 +0100
commit9cf89f7a5b81197e38f58b24be0793b28fe41477 (patch)
tree35b1e832535ac77684d842f524310e14a837fe94 /src/test/checkqueue_tests.cpp
parentd03eaacbcfb276fb638db1b423113ff43bd7ec41 (diff)
refactor: Make `CCheckQueue` constructor start worker threads
Diffstat (limited to 'src/test/checkqueue_tests.cpp')
-rw-r--r--src/test/checkqueue_tests.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/test/checkqueue_tests.cpp b/src/test/checkqueue_tests.cpp
index 9c2a5d1ae6..023a5e8e70 100644
--- a/src/test/checkqueue_tests.cpp
+++ b/src/test/checkqueue_tests.cpp
@@ -158,8 +158,7 @@ typedef CCheckQueue<FrozenCleanupCheck> FrozenCleanup_Queue;
*/
static void Correct_Queue_range(std::vector<size_t> range)
{
- auto small_queue = std::make_unique<Correct_Queue>(QUEUE_BATCH_SIZE);
- small_queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
+ auto small_queue = std::make_unique<Correct_Queue>(QUEUE_BATCH_SIZE, SCRIPT_CHECK_THREADS);
// Make vChecks here to save on malloc (this test can be slow...)
std::vector<FakeCheckCheckCompletion> vChecks;
vChecks.reserve(9);
@@ -217,9 +216,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Correct_Random)
/** Test that failing checks are caught */
BOOST_AUTO_TEST_CASE(test_CheckQueue_Catches_Failure)
{
- auto fail_queue = std::make_unique<Failing_Queue>(QUEUE_BATCH_SIZE);
- fail_queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
-
+ auto fail_queue = std::make_unique<Failing_Queue>(QUEUE_BATCH_SIZE, SCRIPT_CHECK_THREADS);
for (size_t i = 0; i < 1001; ++i) {
CCheckQueueControl<FailingCheck> control(fail_queue.get());
size_t remaining = i;
@@ -244,9 +241,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Catches_Failure)
// future blocks, ie, the bad state is cleared.
BOOST_AUTO_TEST_CASE(test_CheckQueue_Recovers_From_Failure)
{
- auto fail_queue = std::make_unique<Failing_Queue>(QUEUE_BATCH_SIZE);
- fail_queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
-
+ auto fail_queue = std::make_unique<Failing_Queue>(QUEUE_BATCH_SIZE, SCRIPT_CHECK_THREADS);
for (auto times = 0; times < 10; ++times) {
for (const bool end_fails : {true, false}) {
CCheckQueueControl<FailingCheck> control(fail_queue.get());
@@ -267,9 +262,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Recovers_From_Failure)
// more than once as well
BOOST_AUTO_TEST_CASE(test_CheckQueue_UniqueCheck)
{
- auto queue = std::make_unique<Unique_Queue>(QUEUE_BATCH_SIZE);
- queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
-
+ auto queue = std::make_unique<Unique_Queue>(QUEUE_BATCH_SIZE, SCRIPT_CHECK_THREADS);
size_t COUNT = 100000;
size_t total = COUNT;
{
@@ -301,8 +294,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_UniqueCheck)
// time could leave the data hanging across a sequence of blocks.
BOOST_AUTO_TEST_CASE(test_CheckQueue_Memory)
{
- auto queue = std::make_unique<Memory_Queue>(QUEUE_BATCH_SIZE);
- queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
+ auto queue = std::make_unique<Memory_Queue>(QUEUE_BATCH_SIZE, SCRIPT_CHECK_THREADS);
for (size_t i = 0; i < 1000; ++i) {
size_t total = i;
{
@@ -327,9 +319,8 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Memory)
// have been destructed
BOOST_AUTO_TEST_CASE(test_CheckQueue_FrozenCleanup)
{
- auto queue = std::make_unique<FrozenCleanup_Queue>(QUEUE_BATCH_SIZE);
+ auto queue = std::make_unique<FrozenCleanup_Queue>(QUEUE_BATCH_SIZE, SCRIPT_CHECK_THREADS);
bool fails = false;
- queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
std::thread t0([&]() {
CCheckQueueControl<FrozenCleanupCheck> control(queue.get());
std::vector<FrozenCleanupCheck> vChecks(1);
@@ -362,7 +353,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_FrozenCleanup)
/** Test that CCheckQueueControl is threadsafe */
BOOST_AUTO_TEST_CASE(test_CheckQueueControl_Locks)
{
- auto queue = std::make_unique<Standard_Queue>(QUEUE_BATCH_SIZE);
+ auto queue = std::make_unique<Standard_Queue>(QUEUE_BATCH_SIZE, SCRIPT_CHECK_THREADS);
{
std::vector<std::thread> tg;
std::atomic<int> nThreads {0};